diff options
author | Bellegarde Cedric <gnumdk@gmail.com> | 2007-04-22 15:17:25 +0200 |
---|---|---|
committer | Bellegarde Cedric <gnumdk@gmail.com> | 2007-04-22 15:17:25 +0200 |
commit | e2d9c6b56559073eefd8f3d78f56a1bb54b4795f (patch) | |
tree | 0e5ecafd811d994dba042bbc3a3602693c6b3220 /src/neg.c | |
parent | 762675fd9e0600070001909908488bb44a442d0c (diff) | |
download | beryl-premerge-e2d9c6b56559073eefd8f3d78f56a1bb54b4795f.tar.gz beryl-premerge-e2d9c6b56559073eefd8f3d78f56a1bb54b4795f.tar.bz2 |
New match option to set windows as neg
Diffstat (limited to 'src/neg.c')
-rw-r--r-- | src/neg.c | 68 |
1 files changed, 64 insertions, 4 deletions
@@ -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; } |