diff --git a/include/compiz-core.h b/include/compiz-core.h index 7f2c4c5..0e12711 100644 --- a/include/compiz-core.h +++ b/include/compiz-core.h @@ -28,7 +28,7 @@ #include -#define CORE_ABIVERSION 20080310 +#define CORE_ABIVERSION 20080312 #include #include @@ -1856,6 +1856,8 @@ typedef Bool (*PlaceWindowProc) (CompWindow *window, int *newX, int *newY); +typedef void (*ActivateWindowProc) (CompWindow *w); + typedef void (*ValidateWindowResizeRequestProc) (CompWindow *window, unsigned int *mask, XWindowChanges *xwc); @@ -2188,6 +2190,7 @@ struct _CompScreen { GetAllowedActionsForWindowProc getAllowedActionsForWindow; FocusWindowProc focusWindow; PlaceWindowProc placeWindow; + ActivateWindowProc activateWindow; ValidateWindowResizeRequestProc validateWindowResizeRequest; PaintCursorProc paintCursor; diff --git a/plugins/plane.c b/plugins/plane.c index 0c3d9c6..81eddef 100644 --- a/plugins/plane.c +++ b/plugins/plane.c @@ -71,6 +71,7 @@ typedef struct _PlaneScreen { PreparePaintScreenProc preparePaintScreen; DonePaintScreenProc donePaintScreen; PaintOutputProc paintOutput; + ActivateWindowProc activateWindow; CompTimeoutHandle timeoutHandle; int timer; @@ -358,7 +359,6 @@ planeHandleEvent (CompDisplay *d, XEvent *event) { CompScreen *s; - Window activeWindow = d->activeWindow; PLANE_DISPLAY (d); @@ -392,28 +392,30 @@ planeHandleEvent (CompDisplay *d, UNWRAP (pd, d, handleEvent); (*d->handleEvent) (d, event); WRAP (pd, d, handleEvent, planeHandleEvent); +} - if (activeWindow != d->activeWindow) - { - CompWindow *w; +static void +planeActivateWindow (CompWindow *w) +{ + CompScreen *s = w->screen; - w = findWindowAtDisplay (d, d->activeWindow); - if (w && w->placed) - { - s = w->screen; + PLANE_SCREEN (s); - if (!otherScreenGrabExist (s, "plane", "switcher", "cube", 0)) - { - int dx, dy; + if (w->placed && + !otherScreenGrabExist (s, "plane", "switcher", "cube", 0)) + { + int dx, dy; - defaultViewportForWindow (w, &dx, &dy); - dx -= s->x; - dy -= s->y; + defaultViewportForWindow (w, &dx, &dy); + dx -= s->x; + dy -= s->y; - moveViewport (s, dx, dy); - } - } + moveViewport (s, dx, dy); } + + UNWRAP (ps, s, activateWindow); + (*s->activateWindow) (w); + WRAP (ps, s, activateWindow, planeActivateWindow); } static CompOption * @@ -634,6 +636,7 @@ planeInitScreen (CompPlugin *p, WRAP (ps, s, preparePaintScreen, planePreparePaintScreen); WRAP (ps, s, donePaintScreen, planeDonePaintScreen); WRAP (ps, s, paintOutput, planePaintOutput); + WRAP (ps, s, activateWindow, planeActivateWindow); s->base.privates[pd->screenPrivateIndex].ptr = ps; @@ -650,6 +653,7 @@ planeFiniScreen (CompPlugin *p, UNWRAP (ps, s, preparePaintScreen); UNWRAP (ps, s, donePaintScreen); UNWRAP (ps, s, paintOutput); + UNWRAP (ps, s, activateWindow); free (ps); } diff --git a/plugins/rotate.c b/plugins/rotate.c index bce82cc..c52c911 100644 --- a/plugins/rotate.c +++ b/plugins/rotate.c @@ -110,6 +110,7 @@ typedef struct _RotateScreen { PaintOutputProc paintOutput; WindowGrabNotifyProc windowGrabNotify; WindowUngrabNotifyProc windowUngrabNotify; + ActivateWindowProc activateWindow; CubeGetRotationProc getRotation; @@ -1472,7 +1473,6 @@ rotateHandleEvent (CompDisplay *d, XEvent *event) { CompScreen *s; - Window activeWindow = d->activeWindow; ROTATE_DISPLAY (d); @@ -1579,63 +1579,63 @@ rotateHandleEvent (CompDisplay *d, UNWRAP (rd, d, handleEvent); (*d->handleEvent) (d, event); WRAP (rd, d, handleEvent, rotateHandleEvent); +} - if (activeWindow != d->activeWindow) - { - CompWindow *w; - - w = findWindowAtDisplay (d, d->activeWindow); - if (w && w->placed) - { - s = w->screen; +static void +rotateActivateWindow (CompWindow *w) +{ + CompScreen *s = w->screen; - if (!otherScreenGrabExist (s, "rotate", "switcher", "cube", 0)) - { - int dx; + ROTATE_SCREEN (s); - ROTATE_SCREEN (s); + if (w->placed && + !otherScreenGrabExist (s, "rotate", "switcher", "cube", 0)) + { + int dx; - /* reset movement */ - rs->moveTo = 0.0f; + /* reset movement */ + rs->moveTo = 0.0f; - defaultViewportForWindow (w, &dx, NULL); - dx -= s->x; - if (dx) - { - Window win; - int i, x, y; - unsigned int ui; - CompOption o[4]; + defaultViewportForWindow (w, &dx, NULL); + dx -= s->x; + if (dx) + { + Window win; + int i, x, y; + unsigned int ui; + CompOption o[4]; - XQueryPointer (d->display, s->root, - &win, &win, &x, &y, &i, &i, &ui); + XQueryPointer (s->display->display, s->root, + &win, &win, &x, &y, &i, &i, &ui); - if (dx * 2 > s->hsize) - dx -= s->hsize; - else if (dx * 2 < -s->hsize) - dx += s->hsize; + if (dx * 2 > s->hsize) + dx -= s->hsize; + else if (dx * 2 < -s->hsize) + dx += s->hsize; - o[0].type = CompOptionTypeInt; - o[0].name = "x"; - o[0].value.i = x; + o[0].type = CompOptionTypeInt; + o[0].name = "x"; + o[0].value.i = x; - o[1].type = CompOptionTypeInt; - o[1].name = "y"; - o[1].value.i = y; + o[1].type = CompOptionTypeInt; + o[1].name = "y"; + o[1].value.i = y; - o[2].type = CompOptionTypeInt; - o[2].name = "root"; - o[2].value.i = s->root; + o[2].type = CompOptionTypeInt; + o[2].name = "root"; + o[2].value.i = s->root; - o[3].type = CompOptionTypeInt; - o[3].name = "direction"; - o[3].value.i = dx; + o[3].type = CompOptionTypeInt; + o[3].name = "direction"; + o[3].value.i = dx; - rotate (d, NULL, 0, o, 4); - } - } + rotate (s->display, NULL, 0, o, 4); } } + + UNWRAP (rs, s, activateWindow); + (*s->activateWindow) (w); + WRAP (rs, s, activateWindow, rotateActivateWindow); } static void @@ -1880,6 +1880,7 @@ rotateInitScreen (CompPlugin *p, WRAP (rs, s, paintOutput, rotatePaintOutput); WRAP (rs, s, windowGrabNotify, rotateWindowGrabNotify); WRAP (rs, s, windowUngrabNotify, rotateWindowUngrabNotify); + WRAP (rs, s, activateWindow, rotateActivateWindow); WRAP (rs, cs, getRotation, rotateGetRotation); diff --git a/plugins/scale.c b/plugins/scale.c index 0d7eeb2..b536288 100644 --- a/plugins/scale.c +++ b/plugins/scale.c @@ -1102,7 +1102,7 @@ scaleTerminate (CompDisplay *d, { int x, y; - activateWindow (w); + (*s->activateWindow) (w); defaultViewportForWindow (w, &x, &y); diff --git a/src/event.c b/src/event.c index 171ace0..a129d95 100644 --- a/src/event.c +++ b/src/event.c @@ -1549,7 +1549,7 @@ handleEvent (CompDisplay *d, if (event->xclient.data.l[0] != 1 || allowWindowFocus (w, 0, event->xclient.data.l[1])) { - activateWindow (w); + (*w->screen->activateWindow) (w); } } } diff --git a/src/screen.c b/src/screen.c index 41dea6d..38c084b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -1712,6 +1712,7 @@ addScreen (CompDisplay *display, s->getAllowedActionsForWindow = getAllowedActionsForWindow; s->focusWindow = focusWindow; s->placeWindow = placeWindow; + s->activateWindow = activateWindow; s->validateWindowResizeRequest = validateWindowResizeRequest; s->paintCursor = paintCursor;