[PATCH] Also use edge delay setting for DnD actions.

Danny Baumann dannybaumann at web.de
Thu Jul 12 04:36:13 PDT 2007


---
 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 7d13ad8..6a8fe4e 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,25 +1035,10 @@ handleActionEvent (CompDisplay *d,
 
 	    if (edge)
 	    {
-		int                     delay;
-		CompDelayedEdgeSettings *delayedSettings = NULL;
-
-		delay = d->opt[COMP_DISPLAY_OPTION_EDGE_DELAY].value.i;
 		state = CompActionStateInitEdge;
 
 		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;
@@ -1010,29 +1050,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)
 	{
@@ -1133,20 +1155,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


--=-6B8vdMXn+vBOTdKrS7o1--



More information about the compiz mailing list