summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBellegarde Cedric <gnumdk@gmail.com>2007-04-22 15:17:25 +0200
committerBellegarde Cedric <gnumdk@gmail.com>2007-04-22 15:17:25 +0200
commite2d9c6b56559073eefd8f3d78f56a1bb54b4795f (patch)
tree0e5ecafd811d994dba042bbc3a3602693c6b3220
parent762675fd9e0600070001909908488bb44a442d0c (diff)
downloadberyl-premerge-e2d9c6b56559073eefd8f3d78f56a1bb54b4795f.tar.gz
beryl-premerge-e2d9c6b56559073eefd8f3d78f56a1bb54b4795f.tar.bz2
New match option to set windows as neg
-rw-r--r--metadata/neg.xml7
-rw-r--r--src/neg.c68
2 files changed, 71 insertions, 4 deletions
diff --git a/metadata/neg.xml b/metadata/neg.xml
index 4cf35ab..4e0bb0c 100644
--- a/metadata/neg.xml
+++ b/metadata/neg.xml
@@ -20,6 +20,13 @@
</option>
</display>
<screen>
+ <option name="neg_match" type="match">
+ <short>Neg Windows</short>
+ <long>Windows to be negative by default</long>
+ <default></default>
+ </option>
+ </screen>
+ <screen>
<option name="exclude_match" type="match">
<short>Exclude Windows</short>
<long>Windows to exclude from negating</long>
diff --git a/src/neg.c b/src/neg.c
index bd117ac..31f4fad 100644
--- a/src/neg.c
+++ b/src/neg.c
@@ -34,6 +34,7 @@ static int displayPrivateIndex;
typedef struct _NEGDisplay
{
+ HandleEventProc handleEvent;
int screenPrivateIndex;
} NEGDisplay;
@@ -52,6 +53,7 @@ typedef struct _NEGSCreen
typedef struct _NEGWindow
{
Bool isNeg; /* negative window flag */
+ Bool createEvent;
} NEGWindow;
#define GET_NEG_DISPLAY(d) ((NEGDisplay *) (d)->privates[displayPrivateIndex].ptr)
@@ -159,7 +161,6 @@ getNegFragmentFunction (CompScreen *s, CompTexture *texture, Bool alpha)
{
Bool ok = TRUE;
int handle = 0;
- printf("Using Data\n");
if (alpha)
{
@@ -539,6 +540,60 @@ static Bool NEGDamageWindowRect(CompWindow * w, Bool initial, BoxPtr rect)
return status;
}
+static void
+NEGHandleEvent (CompDisplay *d,
+ XEvent *event)
+{
+ CompWindow *w;
+
+ NEG_DISPLAY (d);
+ /* Only apply at window creation.
+ * Using CreateNotify not working.
+ */
+ if (event->type == MapNotify)
+ {
+ w = findWindowAtDisplay (d, event->xmap.window);
+ if (w)
+ {
+ NEG_WINDOW (w);
+ if (nw->createEvent)
+ {
+ if (w && matchEval(negGetNegMatch(w->screen), w))
+ NEGToggle (w);
+ nw->createEvent = FALSE;
+ }
+ }
+ }
+
+ UNWRAP (nd, d, handleEvent);
+ (*d->handleEvent) (d, event);
+ WRAP (nd, d, handleEvent, NEGHandleEvent);
+}
+
+static void NEGScreenOptionChanged(CompScreen *s, CompOption *opt, NegScreenOptions num)
+{
+ switch (num)
+ {
+ case NegScreenOptionNegMatch:
+ {
+ CompWindow *w;
+ for (w = s->windows; w; w = w->next)
+ {
+ NEG_WINDOW (w);
+ if (matchEval(negGetNegMatch(s), w) && !nw->isNeg)
+ NEGToggle (w);
+ else if (! matchEval(negGetNegMatch(s), w) && nw->isNeg)
+ NEGToggle (w);
+ }
+ }
+ break;
+
+ default:
+ break;
+
+ }
+}
+
static Bool NEGInitDisplay(CompPlugin * p, CompDisplay * d)
{
NEGDisplay *nd;
@@ -557,6 +612,7 @@ static Bool NEGInitDisplay(CompPlugin * p, CompDisplay * d)
negSetWindowToggleInitiate(d, negToggle);
negSetScreenToggleInitiate(d, negToggleAll);
+ WRAP (nd, d, handleEvent, NEGHandleEvent);
d->privates[displayPrivateIndex].ptr = nd;
return TRUE;
@@ -566,6 +622,7 @@ static void NEGFiniDisplay(CompPlugin * p, CompDisplay * d)
{
NEG_DISPLAY(d);
freeScreenPrivateIndex(d, nd->screenPrivateIndex);
+ UNWRAP (nd, d, handleEvent);
free(nd);
}
@@ -590,7 +647,9 @@ static Bool NEGInitScreen(CompPlugin * p, CompScreen * s)
* you know what happens if you don't
*/
ns->isNeg = FALSE;
-
+
+ negSetNegMatchNotify (s, NEGScreenOptionChanged);
+
/* wrap overloaded functions */
WRAP(ns, s, drawWindowTexture, NEGDrawWindowTexture);
WRAP(ns, s, damageWindowRect, NEGDamageWindowRect);
@@ -631,9 +690,10 @@ static Bool NEGInitWindow(CompPlugin * p, CompWindow * w)
return FALSE;
nw->isNeg = FALSE;
-
+ nw->createEvent = TRUE;
+
w->privates[ns->windowPrivateIndex].ptr = nw;
-
+
return TRUE;
}