summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@opencompositing.org>2008-05-01 18:09:48 +0200
committerDennis kasprzyk <onestone@opencompositing.org>2008-05-01 18:09:48 +0200
commit35794e8bf31d5125eeba334b19ef8d459baae8dc (patch)
tree8596205474b14b2012f9788b241a061da1d101c9
parent8eaddbf175eecf3b225ddf5481084c81a014d281 (diff)
downloadmswitch-master.tar.gz
mswitch-master.tar.bz2
Don't crash if s == NULL;HEADmaster
-rw-r--r--mswitch.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/mswitch.c b/mswitch.c
index 83a6cee..6fa4e71 100644
--- a/mswitch.c
+++ b/mswitch.c
@@ -22,7 +22,7 @@
#include "mswitch_options.h"
static int x,y;
-static CompScreen *s;
+static CompScreen *s = NULL;
static void mswitchMove(CompScreen *s, int dx, int dy)
@@ -51,7 +51,8 @@ static Bool mswitchBegin(CompDisplay *d, CompAction * action,
Window xid;
xid = getIntOptionNamed(option, nOption, "root", 0);
- s = findScreenAtDisplay(d, xid);
+ if (xid)
+ s = findScreenAtDisplay(d, xid);
if (state & CompActionStateInitButton)
action->state |= CompActionStateTermButton;
@@ -68,7 +69,8 @@ static Bool mswitchTerminate(CompDisplay *d, CompAction * action,
CompActionState state, CompOption * option,
int nOption)
{
-
+ Window xid;
+
int mx = MAX(pointerX,x)-MIN(pointerX,x);
int my = MAX(pointerY,y)-MIN(pointerY,y);
@@ -92,8 +94,12 @@ static Bool mswitchTerminate(CompDisplay *d, CompAction * action,
dx *= -1;
if (pointerY < y)
dy *= -1;
-
- mswitchMove(s, dx, dy);
+
+ xid = getIntOptionNamed(option, nOption, "root", 0);
+ if (xid && s == findScreenAtDisplay(d, xid))
+ mswitchMove(s, dx, dy);
+
+ s = NULL;
action->state &= ~(CompActionStateTermKey | CompActionStateTermButton);