Mike Dransfield
2007-Jan-28 08:27 UTC
[compiz] [PATCH] Allow plugins to wrap enterShowDesktopMode
I wrote this so that the plugins can wrap enter/leaveShowDesktopMode. This means that there will be consistency with keybindings and plugins which initiate showdesktop will always use the same effect. My idea is that the plugin will wrap each function and then set w->inShowDesktopMode for all the windows that it moves/modifies. It should then call the core function which will hide any windows that do not have inShowDesktopMode set and then set the hint on the root window. This should make it slightly easier to write show desktop plugins. Other plugins could also wrap this if they want early notification of entering showdesktop mode. They could also prevent certain windows being hidden by setting inShowDesktopMode so that any following plugins will not modify that window. Regards Mike -------------- next part -------------->From 56505ebbff22dbbdda9b0e9d7405e403cb80f0c8 Mon Sep 17 00:00:00 2001From: mike@blueroot.co.uk <mike@localhost.(none)> Date: Sat, 27 Jan 2007 20:52:38 +0000 Subject: [PATCH] Allow plugins to wrap enter/leaveShowDesktopMode --- include/compiz.h | 15 +++-- plugins/scale.c | 2 +- src/display.c | 4 +- src/event.c | 6 +- src/screen.c | 169 +++++++++++++++++++++++++++-------------------------- src/window.c | 2 +- 6 files changed, 101 insertions(+), 97 deletions(-) diff --git a/include/compiz.h b/include/compiz.h index 175d285..4f49792 100644 --- a/include/compiz.h +++ b/include/compiz.h @@ -1404,6 +1404,11 @@ typedef Bool (*InitPluginForScreenProc) (CompPlugin *plugin, typedef void (*FiniPluginForScreenProc) (CompPlugin *plugin, CompScreen *screen); +typedef void (*EnterShowDesktopModeProc) (CompScreen *screen); + +typedef void (*LeaveShowDesktopModeProc) (CompScreen *screen, + CompWindow *window); + typedef Bool (*DamageWindowRectProc) (CompWindow *w, Bool initial, BoxPtr rect); @@ -1695,6 +1700,9 @@ struct _CompScreen { WindowGrabNotifyProc windowGrabNotify; WindowUngrabNotifyProc windowUngrabNotify; + EnterShowDesktopModeProc enterShowDesktopMode; + LeaveShowDesktopModeProc leaveShowDesktopMode; + WindowStateChangeNotifyProc windowStateChangeNotify; OutputChangeNotifyProc outputChangeNotify; @@ -1852,13 +1860,6 @@ applyStartupProperties (CompScreen *screen, CompWindow *window); void -enterShowDesktopMode (CompScreen *s); - -void -leaveShowDesktopMode (CompScreen *s, - CompWindow *window); - -void sendWindowActivationRequest (CompScreen *s, Window id); diff --git a/plugins/scale.c b/plugins/scale.c index 335055f..5780da8 100644 --- a/plugins/scale.c +++ b/plugins/scale.c @@ -1700,7 +1700,7 @@ scaleHandleEvent (CompDisplay *d, s->workArea.height)) { scaleTerminate (d, action, 0, &o, 1); - enterShowDesktopMode (s); + (*s->enterShowDesktopMode) (s); } } } diff --git a/src/display.c b/src/display.c index 4e1db83..2d0a09e 100644 --- a/src/display.c +++ b/src/display.c @@ -390,9 +390,9 @@ showDesktop (CompDisplay *d, if (s) { if (s->showingDesktopMask == 0) - enterShowDesktopMode (s); + (*s->enterShowDesktopMode) (s); else - leaveShowDesktopMode (s, NULL); + (*s->leaveShowDesktopMode) (s, NULL); } return TRUE; diff --git a/src/event.c b/src/event.c index 3c0521c..132721f 100644 --- a/src/event.c +++ b/src/event.c @@ -1836,9 +1836,9 @@ handleEvent (CompDisplay *d, event->xclient.window == None) { if (event->xclient.data.l[0]) - enterShowDesktopMode (s); + (*s->enterShowDesktopMode) (s); else - leaveShowDesktopMode (s, NULL); + (*s->leaveShowDesktopMode) (s, NULL); } } } @@ -1877,7 +1877,7 @@ handleEvent (CompDisplay *d, if (w->minimized) unminimizeWindow (w); - leaveShowDesktopMode (w->screen, w); + (*w->screen->leaveShowDesktopMode) (w->screen, w); w->managed = TRUE; diff --git a/src/screen.c b/src/screen.c index 538d724..a480f1b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -1281,7 +1281,7 @@ getDesktopHints (CompScreen *s) XFree (propData); if (data[0]) - enterShowDesktopMode (s); + (*s->enterShowDesktopMode) (s); } data[0] = s->currentDesktop; @@ -1367,6 +1367,88 @@ makeOutputWindow (CompScreen *s) showOutputWindow (s); } +static void +enterShowDesktopMode (CompScreen *s) +{ + CompDisplay *d = s->display; + CompWindow *w; + unsigned long data = 1; + int count = 0; + CompOption *st = &d->opt[COMP_DISPLAY_OPTION_HIDE_SKIP_TASKBAR_WINDOWS]; + + s->showingDesktopMask = ~(CompWindowTypeDesktopMask | + CompWindowTypeDockMask); + + for (w = s->windows; w; w = w->next) + { + if ((s->showingDesktopMask & w->type) && + (!(w->state & CompWindowStateSkipTaskbarMask) || st->value.b)) + { + if (!w->inShowDesktopMode && (*s->focusWindow) (w)) + { + w->inShowDesktopMode = TRUE; + hideWindow (w); + } + } + + if (w->inShowDesktopMode) + count++; + } + + if (!count) + { + s->showingDesktopMask = 0; + data = 0; + } + + XChangeProperty (s->display->display, s->root, + s->display->showingDesktopAtom, + XA_CARDINAL, 32, PropModeReplace, + (unsigned char *) &data, 1); +} + +static void +leaveShowDesktopMode (CompScreen *s, + CompWindow *window) +{ + CompWindow *w; + unsigned long data = 0; + + if (window) + { + if (!window->inShowDesktopMode) + return; + + window->inShowDesktopMode = FALSE; + showWindow (window); + + /* return if some other window is still in show desktop mode */ + for (w = s->windows; w; w = w->next) + if (w->inShowDesktopMode) + return; + + s->showingDesktopMask = 0; + } + else + { + s->showingDesktopMask = 0; + + for (w = s->windows; w; w = w->next) + { + if (!w->inShowDesktopMode) + continue; + + w->inShowDesktopMode = FALSE; + showWindow (w); + } + } + + XChangeProperty (s->display->display, s->root, + s->display->showingDesktopAtom, + XA_CARDINAL, 32, PropModeReplace, + (unsigned char *) &data, 1); +} + Bool addScreen (CompDisplay *display, int screenNum, @@ -1541,6 +1623,9 @@ addScreen (CompDisplay *display, s->windowGrabNotify = windowGrabNotify; s->windowUngrabNotify = windowUngrabNotify; + s->enterShowDesktopMode = enterShowDesktopMode; + s->leaveShowDesktopMode = leaveShowDesktopMode; + s->windowStateChangeNotify = windowStateChangeNotify; s->outputChangeNotify = outputChangeNotify; @@ -3313,88 +3398,6 @@ applyStartupProperties (CompScreen *screen, } void -enterShowDesktopMode (CompScreen *s) -{ - CompDisplay *d = s->display; - CompWindow *w; - unsigned long data = 1; - int count = 0; - CompOption *st = &d->opt[COMP_DISPLAY_OPTION_HIDE_SKIP_TASKBAR_WINDOWS]; - - s->showingDesktopMask = ~(CompWindowTypeDesktopMask | - CompWindowTypeDockMask); - - for (w = s->windows; w; w = w->next) - { - if ((s->showingDesktopMask & w->type) && - (!(w->state & CompWindowStateSkipTaskbarMask) || st->value.b)) - { - if ((*s->focusWindow) (w)) - { - w->inShowDesktopMode = TRUE; - hideWindow (w); - } - } - - if (w->inShowDesktopMode) - count++; - } - - if (!count) - { - s->showingDesktopMask = 0; - data = 0; - } - - XChangeProperty (s->display->display, s->root, - s->display->showingDesktopAtom, - XA_CARDINAL, 32, PropModeReplace, - (unsigned char *) &data, 1); -} - -void -leaveShowDesktopMode (CompScreen *s, - CompWindow *window) -{ - CompWindow *w; - unsigned long data = 0; - - if (window) - { - if (!window->inShowDesktopMode) - return; - - window->inShowDesktopMode = FALSE; - showWindow (window); - - /* return if some other window is still in show desktop mode */ - for (w = s->windows; w; w = w->next) - if (w->inShowDesktopMode) - return; - - s->showingDesktopMask = 0; - } - else - { - s->showingDesktopMask = 0; - - for (w = s->windows; w; w = w->next) - { - if (!w->inShowDesktopMode) - continue; - - w->inShowDesktopMode = FALSE; - showWindow (w); - } - } - - XChangeProperty (s->display->display, s->root, - s->display->showingDesktopAtom, - XA_CARDINAL, 32, PropModeReplace, - (unsigned char *) &data, 1); -} - -void sendWindowActivationRequest (CompScreen *s, Window id) { diff --git a/src/window.c b/src/window.c index aecb1d7..1713b26 100644 --- a/src/window.c +++ b/src/window.c @@ -3677,7 +3677,7 @@ revealWindow (CompWindow *w) if (w->minimized) unminimizeWindow (w); - leaveShowDesktopMode (w->screen, w); + (*w->screen->leaveShowDesktopMode) (w->screen, w); } static void -- 1.4.4.3
David Reveman
2007-Feb-06 17:33 UTC
[compiz] [PATCH] Allow plugins to wrap enterShowDesktopMode
On Sun, 2007-01-28 at 16:48 +0000, Mike Dransfield wrote:> I wrote this so that the plugins can wrap > enter/leaveShowDesktopMode. This means that > there will be consistency with keybindings and > plugins which initiate showdesktop will always > use the same effect. > > My idea is that the plugin will wrap each function > and then set w->inShowDesktopMode for all the windows > that it moves/modifies. It should then call the core > function which will hide any windows that do not have > inShowDesktopMode set and then set the hint on the root > window. This should make it slightly easier to write > show desktop plugins.Sounds good. Thanks, - David