summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2010-11-22 10:55:35 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2010-11-22 10:55:35 +0800
commit2c3804f02558504971a6700e06f9e515a840e94d (patch)
treef1049f5bd38b08e6606936e9b68d5ecda3d26576
parentb55054fd0acc529d6e6d9fee7c9199e6a7eff4cb (diff)
downloadgroup-2c3804f02558504971a6700e06f9e515a840e94d.tar.gz
group-2c3804f02558504971a6700e06f9e515a840e94d.tar.bz2
Add some documentation and also handle when another plugin wants to register
matches on our windows
-rw-r--r--src/group.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/group.cpp b/src/group.cpp
index 7a6d34f..1cbc5ba 100644
--- a/src/group.cpp
+++ b/src/group.cpp
@@ -26,6 +26,15 @@
#include "group.h"
+/*
+ * GroupExp class
+ *
+ * A custom subclass of CompMatch::Expression which we can create
+ * on matchInitExp to evaluate whether or not a window is actually
+ * grouped.
+ *
+ */
+
class GroupExp :
public CompMatch::Expression
{
@@ -37,12 +46,28 @@ class GroupExp :
bool value;
};
+/*
+ * GroupExp::GroupExp
+ *
+ * Internal value here is the "1" or "0" of group=
+ * (eg we pass str.substr (6) to get that). Compare whether
+ * the window is actually in a group against this value when
+ * evaluating the match
+ *
+ */
GroupExp::GroupExp (const CompString &str) :
value (strtol (str.c_str (), NULL, 0))
{
}
+/*
+ * GroupExp::evaluate
+ *
+ * Compare if we wanted a window to be grouped and whether or not
+ * the window is actually in fact grouped
+ */
+
bool
GroupExp::evaluate (CompWindow *w)
{
@@ -51,6 +76,18 @@ GroupExp::evaluate (CompWindow *w)
return ((value && gw->mGroup) || (!value && !gw->mGroup));
}
+/*
+ * GroupScreen::matchInitExp
+ *
+ * Every time a match option is initialized, this wrapped function gets
+ * called so that we can create an expression if we need to.
+ *
+ * Note here that core parses each match string and tokenizes them
+ * based on spaces, so we only need to worry about matching
+ * "group=" and nothing else.
+ *
+ */
+
CompMatch::Expression *
GroupScreen::matchInitExp (const CompString &str)
{
@@ -62,10 +99,24 @@ GroupScreen::matchInitExp (const CompString &str)
return screen->matchInitExp (str);
}
+/*
+ * GroupScreen::matchExpHandlerChanged
+ *
+ * This gets called whenever some plugin needs to check all windows
+ * again to see if they still match, so go ahead and update match
+ * properties for windows if they are relevant here
+ */
+
void
GroupScreen::matchExpHandlerChanged ()
{
screen->matchExpHandlerChanged ();
+
+ foreach (CompWindow *w, screen->windows ())
+ {
+ if (GroupWindow::get (w)->mGroup)
+ screen->matchPropertyChanged (w);
+ }
}
/*