summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2010-11-22 10:42:13 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2010-11-22 10:42:13 +0800
commitb55054fd0acc529d6e6d9fee7c9199e6a7eff4cb (patch)
tree5321b4ac145ad85e3b2f58014cb70afce03aca2f
parent9ffe98391aa86c990dee58cfb5b1fdea3c6a2b56 (diff)
downloadgroup-b55054fd0acc529d6e6d9fee7c9199e6a7eff4cb.tar.gz
group-b55054fd0acc529d6e6d9fee7c9199e6a7eff4cb.tar.bz2
Add a simple matching system (group=1) to grouped windows.
Specify group=1 to a window match property on another plugin (for example, animation) and it will match all windows that are in a group. You can also combine that with other things (eg group=1 & type=Dialog) to specify which windows to match if they are grouped.
-rw-r--r--src/group.cpp48
-rw-r--r--src/group.h5
-rw-r--r--src/init.cpp3
3 files changed, 54 insertions, 2 deletions
diff --git a/src/group.cpp b/src/group.cpp
index 321142b..7a6d34f 100644
--- a/src/group.cpp
+++ b/src/group.cpp
@@ -26,6 +26,48 @@
#include "group.h"
+class GroupExp :
+ public CompMatch::Expression
+{
+ public:
+ GroupExp (const CompString &str);
+
+ bool evaluate (CompWindow *w);
+
+ bool value;
+};
+
+
+GroupExp::GroupExp (const CompString &str) :
+ value (strtol (str.c_str (), NULL, 0))
+{
+}
+
+bool
+GroupExp::evaluate (CompWindow *w)
+{
+ GROUP_WINDOW (w);
+
+ return ((value && gw->mGroup) || (!value && !gw->mGroup));
+}
+
+CompMatch::Expression *
+GroupScreen::matchInitExp (const CompString &str)
+{
+ /* Create a new match object */
+
+ if (str.find ("group=") == 0)
+ return new GroupExp (str.substr (6));
+
+ return screen->matchInitExp (str);
+}
+
+void
+GroupScreen::matchExpHandlerChanged ()
+{
+ screen->matchExpHandlerChanged ();
+}
+
/*
* GroupWindow::isGroupWindow
*
@@ -548,6 +590,8 @@ GroupWindow::deleteGroupWindow ()
}
mGroup = NULL;
+
+ screen->matchPropertyChanged (window);
cWindow->damageOutputExtents ();
window->updateWindowOutputExtents ();
gs->writeSerializedData ();
@@ -684,6 +728,8 @@ GroupSelection::fini ()
CompositeWindow::get (cw)->damageOutputExtents ();
gw->mGroup = NULL;
+
+ screen->matchPropertyChanged (cw);
cw->updateWindowOutputExtents ();
gs->writeSerializedData ();
@@ -867,6 +913,8 @@ GroupWindow::addWindowToGroup (GroupSelection *group)
cWindow->addDamage ();
}
}
+
+ screen->matchPropertyChanged (window);
}
gs->writeSerializedData ();
diff --git a/src/group.h b/src/group.h
index 71c4bea..2c7fdf2 100644
--- a/src/group.h
+++ b/src/group.h
@@ -587,6 +587,11 @@ class GroupScreen :
CompOutput *,
unsigned int );
+ CompMatch::Expression *
+ matchInitExp (const CompString &str);
+
+ void
+ matchExpHandlerChanged ();
public:
diff --git a/src/init.cpp b/src/init.cpp
index e20df39..b1d43fd 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -370,7 +370,6 @@ GroupScreen::GroupScreen (CompScreen *s) :
mPendingMoves (NULL),
mPendingGrabs (NULL),
mPendingUngrabs (NULL),
- mGroups (NULL),
mQueued (false),
mGrabState (ScreenGrabNone),
mGrabIndex (0),
@@ -378,7 +377,7 @@ GroupScreen::GroupScreen (CompScreen *s) :
mDraggedSlot (NULL),
mDragged (false),
mPrevX (0),
- mPrevY (0) ,
+ mPrevY (0),
mLastGrabbedWindow (None)
{
ScreenInterface::setHandler (screen);