David Reveman
2007-Mar-29 10:59 UTC
[compiz] replace notify functions with functions that apply changes
I've been thinking about removing all existing notification functions in favor of just having functions that apply changes. This is better as it allow each plugin to execute something both before and after the change has been applied. Example: Instead of wrapping a windowStateChangeNotify function you would wrap a changeWindowState function static void pluginChangeWindowState (CompWindow *w, int state) { int oldState = w->state; PLUGIN_SCREEN (w->screen); if ((oldState ^ state) & STATE_PLUGIN_CARE_ABOUT_MASK) { /* do something interesting */ } UNWRAP (ps, w->screen, changeWindowState); (*w->screen->changeWindowState) (w, state); WRAP (ps, w->screen, changeWindowState, pluginChangeWindowState); if ((oldState ^ state) & STATE_PLUGIN_CARE_ABOUT_MASK) { /* do something else interesting */ } } This makes even more sense for move and resize notify functions and before we add another notify function I'd like us to decide if we want to do this or not. I'm strongly in favor of making this change. - David
Erkin Bahceci
2007-Mar-29 11:48 UTC
[compiz] replace notify functions with functions that apply changes
I think it makes sense to allow code execution before and after the change. Regards, Erkin On 3/29/07, David Reveman <davidr@novell.com> wrote:> I've been thinking about removing all existing notification functions in > favor of just having functions that apply changes. This is better as it > allow each plugin to execute something both before and after the change > has been applied. Example: > > Instead of wrapping a windowStateChangeNotify function you would wrap a > changeWindowState function > > static void > pluginChangeWindowState (CompWindow *w, int state) > { > int oldState = w->state; > > PLUGIN_SCREEN (w->screen); > > if ((oldState ^ state) & STATE_PLUGIN_CARE_ABOUT_MASK) > { > /* do something interesting */ > } > > UNWRAP (ps, w->screen, changeWindowState); > (*w->screen->changeWindowState) (w, state); > WRAP (ps, w->screen, changeWindowState, pluginChangeWindowState); > > if ((oldState ^ state) & STATE_PLUGIN_CARE_ABOUT_MASK) > { > /* do something else interesting */ > } > } > > This makes even more sense for move and resize notify functions and > before we add another notify function I'd like us to decide if we want > to do this or not. I'm strongly in favor of making this change. > > - David > > _______________________________________________ > compiz mailing list > compiz@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/compiz >