summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2008-01-09 09:20:00 +0100
committerDanny Baumann <dannybaumann@web.de>2008-01-09 09:20:00 +0100
commitb6822ac137da46df2a94ce4f50273cc9e0c73d3f (patch)
tree84abaffb0cc266696afe81bb471b30a78428a131
parent6a82a7062a410bbbf5e9c1066991742fa21b94d5 (diff)
downloadmousegestures-b6822ac137da46df2a94ce4f50273cc9e0c73d3f.tar.gz
mousegestures-b6822ac137da46df2a94ce4f50273cc9e0c73d3f.tar.bz2
Cleanup.
-rw-r--r--mousegestures.c92
1 files changed, 32 insertions, 60 deletions
diff --git a/mousegestures.c b/mousegestures.c
index 8358d4e..36a2350 100644
--- a/mousegestures.c
+++ b/mousegestures.c
@@ -90,8 +90,6 @@ mousegesturesDisplayActionInitiate (CompDisplay *d,
char *pluginName,
char *actionName)
{
- CompOption *argument = NULL;
- int nArgument = 0;
CompPlugin *p;
CompOption *option = NULL;
@@ -128,40 +126,26 @@ mousegesturesDisplayActionInitiate (CompDisplay *d,
if (option && option->value.action.initiate)
{
- CompOption *a;
+ CompOption args[4];
- a = realloc (argument,
- sizeof (CompOption) * (nArgument + 4));
- if (a)
- {
- argument = a;
-
- argument[nArgument].name = "root";
- argument[nArgument].type = CompOptionTypeInt;
- argument[nArgument].value.i = currentRoot;
- nArgument++;
-
- argument[nArgument].name = "window";
- argument[nArgument].type = CompOptionTypeInt;
- argument[nArgument].value.i = d->activeWindow;
- nArgument++;
-
- argument[nArgument].name = "x";
- argument[nArgument].type = CompOptionTypeInt;
- argument[nArgument].value.i = pointerX;
- nArgument++;
-
- argument[nArgument].name = "y";
- argument[nArgument].type = CompOptionTypeInt;
- argument[nArgument].value.i = pointerY;
- nArgument++;
- }
+ args[0].name = "root";
+ args[0].type = CompOptionTypeInt;
+ args[0].value.i = currentRoot;
+
+ args[1].name = "window";
+ args[1].type = CompOptionTypeInt;
+ args[1].value.i = d->activeWindow;
+
+ args[2].name = "x";
+ args[2].type = CompOptionTypeInt;
+ args[2].value.i = pointerX;
- (*option->value.action.initiate) (d,
- &option->value.action,
- 0,
- argument,
- nArgument);
+ args[3].name = "y";
+ args[3].type = CompOptionTypeInt;
+ args[3].value.i = pointerY;
+
+ (*option->value.action.initiate) (d, &option->value.action,
+ 0, args, 4);
}
else
{
@@ -217,9 +201,8 @@ mousegesturesTerminate (CompDisplay *d,
int nOption)
{
CompScreen *s;
- int ng, ns, xid;
+ int ng, xid;
Mousegesture mg;
- Bool match = TRUE;
MOUSEGESTURES_DISPLAY (d);
@@ -230,28 +213,17 @@ mousegesturesTerminate (CompDisplay *d,
return FALSE;
ng = md->nGesture;
-
while (ng--)
{
mg = md->gesture[ng];
- if (mg.nStrokes == md->nCurrentGesture)
- {
- match = TRUE;
+ if (mg.nStrokes != md->nCurrentGesture)
+ continue;
- for (ns = 0;ns < mg.nStrokes;ns++)
- {
- if (md->currentGesture[ns] != mg.stroke[ns])
- match = FALSE;
- }
+ if (strcmp (md->currentGesture, mg.stroke) != 0)
+ continue;
- if (match)
- {
- mousegesturesDisplayActionInitiate (d,
- mg.pluginName,
- mg.actionName);
- }
- }
+ mousegesturesDisplayActionInitiate (d, mg.pluginName, mg.actionName);
}
removeScreenGrab (s, md->grabIndex, NULL);
@@ -339,22 +311,22 @@ mousegesturesHandleEvent (CompDisplay *d,
break;
}
- if (currentStroke != '\0' && md->currentStroke != currentStroke)
+ if (currentStroke && md->currentStroke != currentStroke)
{
md->currentStroke = currentStroke;
if (md->currentStroke != md->lastStroke)
{
- md->lastStroke = md->currentStroke;
- if (md->nCurrentGesture<MOUSEGESTURES_MAX_STROKE)
- {
- md->currentGesture[md->nCurrentGesture] = md->currentStroke;
- md->nCurrentGesture++;
- }
+ md->lastStroke = md->currentStroke;
+ if (md->nCurrentGesture<MOUSEGESTURES_MAX_STROKE)
+ {
+ md->currentGesture[md->nCurrentGesture] = md->currentStroke;
+ md->nCurrentGesture++;
+ }
}
md->deltaX = 0;
md->deltaY = 0;
}
- else if (md->currentStroke != '\0' && md->currentStroke == currentStroke)
+ else if (md->currentStroke && md->currentStroke == currentStroke)
{
md->deltaX = 0;
md->deltaY = 0;