summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-11 21:41:49 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-11 21:41:49 +0200
commit48b6e9a3968e54a87f022c8e68b5bec5423cb75f (patch)
tree0c2fccdc7b2b18996840e8043bc1a95a1c897f40
parentadded mouse-based resizals (diff)
downloaddwm-48b6e9a3968e54a87f022c8e68b5bec5423cb75f.tar.gz
dwm-48b6e9a3968e54a87f022c8e68b5bec5423cb75f.zip
added basic mouse support (actually we don't need more)
Diffstat (limited to '')
-rw-r--r--client.c11
-rw-r--r--event.c2
-rw-r--r--mouse.c12
-rw-r--r--wm.h14
4 files changed, 15 insertions, 24 deletions
diff --git a/client.c b/client.c
index e05fdd7..c11d5d5 100644
--- a/client.c
+++ b/client.c
@@ -70,8 +70,7 @@ manage(Window w, XWindowAttributes *wa)
70 c->r[RFloat].y = wa->y; 70 c->r[RFloat].y = wa->y;
71 c->r[RFloat].width = wa->width; 71 c->r[RFloat].width = wa->width;
72 c->r[RFloat].height = wa->height; 72 c->r[RFloat].height = wa->height;
73 c->border = wa->border_width; 73 XSetWindowBorderWidth(dpy, c->win, 1);
74 XSetWindowBorderWidth(dpy, c->win, 0);
75 XSelectInput(dpy, c->win, CLIENT_MASK); 74 XSelectInput(dpy, c->win, CLIENT_MASK);
76 XGetTransientForHint(dpy, c->win, &c->trans); 75 XGetTransientForHint(dpy, c->win, &c->trans);
77 if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags) 76 if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags)
@@ -97,7 +96,11 @@ manage(Window w, XWindowAttributes *wa)
97 c->snext = stack; 96 c->snext = stack;
98 stack = c; 97 stack = c;
99 XMapWindow(dpy, c->win); 98 XMapWindow(dpy, c->win);
100 XGrabButton(dpy, AnyButton, Mod1Mask, c->win, False, ButtonPressMask, 99 XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask,
100 GrabModeAsync, GrabModeSync, None, None);
101 XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask,
102 GrabModeAsync, GrabModeSync, None, None);
103 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
101 GrabModeAsync, GrabModeSync, None, None); 104 GrabModeAsync, GrabModeSync, None, None);
102 focus(c); 105 focus(c);
103} 106}
@@ -116,7 +119,7 @@ resize(Client *c)
116 e.y = c->r[RFloat].y; 119 e.y = c->r[RFloat].y;
117 e.width = c->r[RFloat].width; 120 e.width = c->r[RFloat].width;
118 e.height = c->r[RFloat].height; 121 e.height = c->r[RFloat].height;
119 e.border_width = c->border; 122 e.border_width = 0;
120 e.above = None; 123 e.above = None;
121 e.override_redirect = False; 124 e.override_redirect = False;
122 XSelectInput(dpy, c->win, CLIENT_MASK & ~StructureNotifyMask); 125 XSelectInput(dpy, c->win, CLIENT_MASK & ~StructureNotifyMask);
diff --git a/event.c b/event.c
index ad4a16b..b8b39a4 100644
--- a/event.c
+++ b/event.c
@@ -86,8 +86,6 @@ configurerequest(XEvent *e)
86 c->r[RFloat].width = ev->width; 86 c->r[RFloat].width = ev->width;
87 if(ev->value_mask & CWHeight) 87 if(ev->value_mask & CWHeight)
88 c->r[RFloat].height = ev->height; 88 c->r[RFloat].height = ev->height;
89 if(ev->value_mask & CWBorderWidth)
90 c->border = ev->border_width;
91 } 89 }
92 90
93 wc.x = ev->x; 91 wc.x = ev->x;
diff --git a/mouse.c b/mouse.c
index 2b5d63b..07b533c 100644
--- a/mouse.c
+++ b/mouse.c
@@ -42,7 +42,7 @@ mresize(Client *c)
42 42
43 old_cx = c->r[RFloat].x; 43 old_cx = c->r[RFloat].x;
44 old_cy = c->r[RFloat].y; 44 old_cy = c->r[RFloat].y;
45 if(XGrabPointer(dpy, c->win, False, MouseMask, GrabModeAsync, GrabModeAsync, 45 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
46 None, cursor[CurResize], CurrentTime) != GrabSuccess) 46 None, cursor[CurResize], CurrentTime) != GrabSuccess)
47 return; 47 return;
48 XGrabServer(dpy); 48 XGrabServer(dpy);
@@ -55,10 +55,12 @@ mresize(Client *c)
55 case MotionNotify: 55 case MotionNotify:
56 XUngrabServer(dpy); 56 XUngrabServer(dpy);
57 mmatch(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y); 57 mmatch(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y);
58 resize(c); 58 XResizeWindow(dpy, c->win, c->r[RFloat].width, c->r[RFloat].height);
59 XGrabServer(dpy); 59 XGrabServer(dpy);
60 break; 60 break;
61 case ButtonRelease: 61 case ButtonRelease:
62 resize(c);
63 XUngrabServer(dpy);
62 XUngrabPointer(dpy, CurrentTime); 64 XUngrabPointer(dpy, CurrentTime);
63 return; 65 return;
64 } 66 }
@@ -75,7 +77,7 @@ mmove(Client *c)
75 77
76 old_cx = c->r[RFloat].x; 78 old_cx = c->r[RFloat].x;
77 old_cy = c->r[RFloat].y; 79 old_cy = c->r[RFloat].y;
78 if(XGrabPointer(dpy, c->win, False, MouseMask, GrabModeAsync, GrabModeAsync, 80 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
79 None, cursor[CurMove], CurrentTime) != GrabSuccess) 81 None, cursor[CurMove], CurrentTime) != GrabSuccess)
80 return; 82 return;
81 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); 83 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
@@ -88,10 +90,12 @@ mmove(Client *c)
88 XUngrabServer(dpy); 90 XUngrabServer(dpy);
89 c->r[RFloat].x = old_cx + (ev.xmotion.x - x1); 91 c->r[RFloat].x = old_cx + (ev.xmotion.x - x1);
90 c->r[RFloat].y = old_cy + (ev.xmotion.y - y1); 92 c->r[RFloat].y = old_cy + (ev.xmotion.y - y1);
91 resize(c); 93 XMoveResizeWindow(dpy, c->win, c->r[RFloat].x, c->r[RFloat].y,
94 c->r[RFloat].width, c->r[RFloat].height);
92 XGrabServer(dpy); 95 XGrabServer(dpy);
93 break; 96 break;
94 case ButtonRelease: 97 case ButtonRelease:
98 resize(c);
95 XUngrabServer(dpy); 99 XUngrabServer(dpy);
96 XUngrabPointer(dpy, CurrentTime); 100 XUngrabPointer(dpy, CurrentTime);
97 return; 101 return;
diff --git a/wm.h b/wm.h
index 7ee6103..b647a3e 100644
--- a/wm.h
+++ b/wm.h
@@ -13,19 +13,6 @@
13 13
14typedef struct Client Client; 14typedef struct Client Client;
15typedef struct Key Key; 15typedef struct Key Key;
16typedef enum Align Align;
17
18enum Align {
19 NORTH = 0x01,
20 EAST = 0x02,
21 SOUTH = 0x04,
22 WEST = 0x08,
23 NEAST = NORTH | EAST,
24 NWEST = NORTH | WEST,
25 SEAST = SOUTH | EAST,
26 SWEST = SOUTH | WEST,
27 CENTER = NEAST | SWEST
28};
29 16
30/* atoms */ 17/* atoms */
31enum { WMProtocols, WMDelete, WMLast }; 18enum { WMProtocols, WMDelete, WMLast };
@@ -40,7 +27,6 @@ enum { RFloat, RGrid, RLast };
40struct Client { 27struct Client {
41 char name[256]; 28 char name[256];
42 char tag[256]; 29 char tag[256];
43 unsigned int border;
44 int proto; 30 int proto;
45 Bool fixedsize; 31 Bool fixedsize;
46 Window win; 32 Window win;