Danny Baumann
2007-Jul-12 08:16 UTC
[PATCH] Also use delayed edge setting for DnD edge bindings.
--- include/compiz.h | 3 +- src/event.c | 113 +++++++++++++++++++++++++++++------------------------- 2 files changed, 63 insertions(+), 53 deletions(-) diff --git a/include/compiz.h b/include/compiz.h index f5d6e95..e66649f 100644 --- a/include/compiz.h +++ b/include/compiz.h @@ -1118,7 +1118,8 @@ typedef struct _CompDelayedEdgeSettings unsigned int edge; unsigned int state; - CompOption option[7]; + CompOption option[7]; + unsigned int nOption; } CompDelayedEdgeSettings; void diff --git a/src/event.c b/src/event.c index c12d55d..2eaacbd 100644 --- a/src/event.c +++ b/src/event.c @@ -739,7 +739,8 @@ delayedEdgeTimeout (void *closure) settings->state, ~CompActionStateIgnoreEdgeDelay, settings->edge, - settings->option, 7); + settings->option, + settings->nOption); free (settings); @@ -747,6 +748,60 @@ delayedEdgeTimeout (void *closure) } static Bool +triggerEdgeEnter (CompDisplay *d, + unsigned int edge, + CompActionState state, + CompOption *argument, + unsigned int nArgument) +{ + int delay; + CompDelayedEdgeSettings *delayedSettings = NULL; + + delay = d->opt[COMP_DISPLAY_OPTION_EDGE_DELAY].value.i; + + if (nArgument > 7) + nArgument = 7; + + if (delay > 0) + { + delayedSettings = malloc (sizeof (CompDelayedEdgeSettings)); + if (delayedSettings) + { + delayedSettings->d = d; + delayedSettings->edge = edge; + delayedSettings->state = state; + delayedSettings->nOption = nArgument; + } + } + + if (delayedSettings) + { + CompActionState ignoreState; + int i; + + for (i = 0; i < nArgument; i++) + delayedSettings->option[i] = argument[i]; + + d->edgeDelayHandle = compAddTimeout (delay, + delayedEdgeTimeout, + delayedSettings); + + ignoreState = CompActionStateIgnoreEdgeDelay; + if (triggerAllEdgeEnterBindings (d, state, ignoreState, + edge, argument, nArgument)) + return TRUE; + } + else + { + if (triggerAllEdgeEnterBindings (d, state, 0, edge, + argument, nArgument)) + return TRUE; + } + + return FALSE; +} + +static Bool handleActionEvent (CompDisplay *d, XEvent *event) { @@ -980,10 +1035,6 @@ handleActionEvent (CompDisplay *d, if (edge) { - int delay; - CompDelayedEdgeSettings *delayedSettings = NULL; - - delay = d->opt[COMP_DISPLAY_OPTION_EDGE_DELAY].value.i; state = CompActionStateInitEdge; if (edgeWindow && @@ -1000,17 +1051,6 @@ handleActionEvent (CompDisplay *d, edgeWindow = event->xcrossing.window; - if (delay > 0) - { - delayedSettings = malloc (sizeof (CompDelayedEdgeSettings)); - if (delayedSettings) - { - delayedSettings->d = d; - delayedSettings->edge = edge; - delayedSettings->state = state; - } - } - o[0].value.i = event->xcrossing.window; o[1].value.i = d->activeWindow; o[2].value.i = event->xcrossing.state; @@ -1022,29 +1062,11 @@ handleActionEvent (CompDisplay *d, o[6].name = "time"; o[6].value.i = event->xcrossing.time; - if (delayedSettings) - { - CompActionState ignoreState; - - for (i = 0; i < 7; i++) - delayedSettings->option[i] = o[i]; - - d->edgeDelayHandle = compAddTimeout (delay, - delayedEdgeTimeout, - delayedSettings); - - ignoreState = CompActionStateIgnoreEdgeDelay; - if (triggerAllEdgeEnterBindings (d, state, ignoreState, - edge, o, 7)) - return TRUE; - } - else - { - if (triggerAllEdgeEnterBindings (d, state, 0, edge, o, 7)) - return TRUE; - } + if (triggerEdgeEnter (d, edge, state, o, 7)) + return TRUE; } - } break; + } + break; case ClientMessage: if (event->xclient.message_type == d->xdndEnterAtom) { @@ -1145,20 +1167,7 @@ handleActionEvent (CompDisplay *d, o[4].value.i = event->xclient.data.l[2] & 0xffff; o[5].value.i = root; - for (p = getPlugins (); p; p = p->next) - { - if (p->vTable->getDisplayOptions) - { - option = (*p->vTable->getDisplayOptions) (p, d, &nOption); - if (triggerEdgeEnterBindings (d, option, nOption, state, - 0, edge, o, 6)) - return TRUE; - } - } - - option = compGetDisplayOptions (d, &nOption); - if (triggerEdgeEnterBindings (d, option, nOption, state, - 0, edge, o, 6)) + if (triggerEdgeEnter (d, edge, state, o, 6)) return TRUE; } -- 1.5.2.2 --=-x8OTMg0wWYf/MMFSKHv3--