summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2007-08-16 17:40:27 +0200
committerDanny Baumann <dannybaumann@web.de>2007-08-16 17:40:27 +0200
commit31d8932283d6fa10cfba6f5d304fe63faee2b03b (patch)
treeb22d81353f6aa5dbcc35b9be0bd57ef4d9a68a60
parentfcd7963d59736da92d47ee00fd9e951f6a838dd9 (diff)
downloadneg-31d8932283d6fa10cfba6f5d304fe63faee2b03b.tar.gz
neg-31d8932283d6fa10cfba6f5d304fe63faee2b03b.tar.bz2
Cleaned up initial neg state assignment for windows and fixed exclude match change handling.
-rw-r--r--neg.c94
1 files changed, 34 insertions, 60 deletions
diff --git a/neg.c b/neg.c
index 4edf3ad..dcec100 100644
--- a/neg.c
+++ b/neg.c
@@ -34,8 +34,6 @@ static int displayPrivateIndex;
typedef struct _NEGDisplay
{
- HandleEventProc handleEvent;
-
int screenPrivateIndex;
} NEGDisplay;
@@ -45,7 +43,7 @@ typedef struct _NEGSCreen
int windowPrivateIndex;
DrawWindowTextureProc drawWindowTexture;
- DamageWindowRectProc damageWindowRect;
+ WindowAddNotifyProc windowAddNotify;
Bool isNeg; /* negative screen flag */
@@ -56,7 +54,6 @@ typedef struct _NEGSCreen
typedef struct _NEGWindow
{
Bool isNeg; /* negative window flag */
- Bool createEvent;
} NEGWindow;
#define GET_NEG_DISPLAY(d) \
@@ -543,59 +540,21 @@ NEGDrawWindowTexture (CompWindow *w,
}
}
-static Bool
-NEGDamageWindowRect (CompWindow *w,
- Bool initial,
- BoxPtr rect)
+static void
+NEGWindowAddNotify (CompWindow *w)
{
- int status;
-
- NEG_SCREEN (w->screen);
- NEG_WINDOW (w);
-
- /* the window is initial when it is being mapped */
- if (initial)
- {
- /* if the screen is negative, negate the new window */
- if (ns->isNeg && !nw->isNeg)
- NEGToggle (w);
- }
+ CompScreen *s = w->screen;
- UNWRAP (ns, w->screen, damageWindowRect);
- status = (*w->screen->damageWindowRect) (w, initial, rect);
- WRAP (ns, w->screen, damageWindowRect, NEGDamageWindowRect);
-
- return status;
-}
+ NEG_SCREEN (s);
-static void
-NEGHandleEvent (CompDisplay *d,
- XEvent *event)
-{
- CompWindow *w;
+ UNWRAP (ns, s, windowAddNotify);
+ (*s->windowAddNotify) (w);
+ WRAP (ns, s, windowAddNotify, NEGWindowAddNotify);
- 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);
+ /* nw->isNeg is initialized to FALSE in InitWindow, so we only
+ have to toggle it to TRUE if necessary */
+ if (ns->isNeg && matchEval (negGetNegMatch (s), w))
+ NEGToggle (w);
}
static void
@@ -608,12 +567,30 @@ NEGScreenOptionChanged (CompScreen *s,
case NegScreenOptionNegMatch:
{
CompWindow *w;
+ NEG_SCREEN (s);
+
for (w = s->windows; w; w = w->next)
{
+ Bool isNeg;
NEG_WINDOW (w);
- if (matchEval (negGetNegMatch (s), w) && !nw->isNeg)
+
+ isNeg = matchEval (negGetNegMatch (s), w);
+ if (isNeg && ns->isNeg && !nw->isNeg)
NEGToggle (w);
- else if (!matchEval (negGetNegMatch (s), w) && nw->isNeg)
+ else if (!isNeg && nw->isNeg)
+ NEGToggle (w);
+ }
+ }
+ break;
+ case NegScreenOptionExcludeMatch:
+ {
+ CompWindow *w;
+
+ for (w = s->windows; w; w = w->next)
+ {
+ NEG_WINDOW (w);
+
+ if (matchEval (negGetExcludeMatch (s), w) && nw->isNeg)
NEGToggle (w);
}
}
@@ -643,7 +620,6 @@ NEGInitDisplay (CompPlugin *p,
negSetWindowToggleInitiate (d, negToggle);
negSetScreenToggleInitiate (d, negToggleAll);
- WRAP (nd, d, handleEvent, NEGHandleEvent);
d->privates[displayPrivateIndex].ptr = nd;
return TRUE;
@@ -656,7 +632,6 @@ NEGFiniDisplay (CompPlugin *p,
NEG_DISPLAY (d);
freeScreenPrivateIndex (d, nd->screenPrivateIndex);
- UNWRAP (nd, d, handleEvent);
free (nd);
}
@@ -692,7 +667,7 @@ NEGInitScreen (CompPlugin *p,
/* wrap overloaded functions */
WRAP (ns, s, drawWindowTexture, NEGDrawWindowTexture);
- WRAP (ns, s, damageWindowRect, NEGDamageWindowRect);
+ WRAP (ns, s, windowAddNotify, NEGWindowAddNotify);
s->privates[nd->screenPrivateIndex].ptr = ns;
@@ -708,7 +683,7 @@ NEGFiniScreen (CompPlugin *p,
freeWindowPrivateIndex (s, ns->windowPrivateIndex);
UNWRAP (ns, s, drawWindowTexture);
- UNWRAP (ns, s, damageWindowRect);
+ UNWRAP (ns, s, windowAddNotify);
if (ns->negFunction)
destroyFragmentFunction (s, ns->negFunction);
@@ -731,7 +706,6 @@ NEGInitWindow (CompPlugin *p,
return FALSE;
nw->isNeg = FALSE;
- nw->createEvent = TRUE;
w->privates[ns->windowPrivateIndex].ptr = nw;