49 |
49 |
50 /********** CUSTOMIZE **********/ |
50 /********** CUSTOMIZE **********/ |
51 |
51 |
52 /* static functions */ |
52 /* static functions */ |
53 |
53 |
54 static void movemouse(Client *c); |
54 static void |
55 static void resizemouse(Client *c); |
55 movemouse(Client *c) |
|
56 { |
|
57 XEvent ev; |
|
58 int x1, y1, ocx, ocy, di; |
|
59 unsigned int dui; |
|
60 Window dummy; |
|
61 |
|
62 ocx = c->x; |
|
63 ocy = c->y; |
|
64 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
|
65 None, cursor[CurMove], CurrentTime) != GrabSuccess) |
|
66 return; |
|
67 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); |
|
68 for(;;) { |
|
69 XMaskEvent(dpy, MouseMask | ExposureMask, &ev); |
|
70 switch (ev.type) { |
|
71 default: break; |
|
72 case Expose: |
|
73 handler[Expose](&ev); |
|
74 break; |
|
75 case MotionNotify: |
|
76 XFlush(dpy); |
|
77 c->x = ocx + (ev.xmotion.x - x1); |
|
78 c->y = ocy + (ev.xmotion.y - y1); |
|
79 resize(c, False); |
|
80 break; |
|
81 case ButtonRelease: |
|
82 XUngrabPointer(dpy, CurrentTime); |
|
83 return; |
|
84 } |
|
85 } |
|
86 } |
|
87 |
|
88 static void |
|
89 resizemouse(Client *c) |
|
90 { |
|
91 XEvent ev; |
|
92 int ocx, ocy; |
|
93 |
|
94 ocx = c->x; |
|
95 ocy = c->y; |
|
96 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
|
97 None, cursor[CurResize], CurrentTime) != GrabSuccess) |
|
98 return; |
|
99 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); |
|
100 for(;;) { |
|
101 XMaskEvent(dpy, MouseMask | ExposureMask, &ev); |
|
102 switch(ev.type) { |
|
103 default: break; |
|
104 case Expose: |
|
105 handler[Expose](&ev); |
|
106 break; |
|
107 case MotionNotify: |
|
108 XFlush(dpy); |
|
109 c->w = abs(ocx - ev.xmotion.x); |
|
110 c->h = abs(ocy - ev.xmotion.y); |
|
111 c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w; |
|
112 c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h; |
|
113 resize(c, True); |
|
114 break; |
|
115 case ButtonRelease: |
|
116 XUngrabPointer(dpy, CurrentTime); |
|
117 return; |
|
118 } |
|
119 } |
|
120 } |
56 |
121 |
57 static void |
122 static void |
58 buttonpress(XEvent *e) |
123 buttonpress(XEvent *e) |
59 { |
124 { |
60 int x; |
125 int x; |
212 if(!getclient(ev->window)) |
277 if(!getclient(ev->window)) |
213 manage(ev->window, &wa); |
278 manage(ev->window, &wa); |
214 } |
279 } |
215 |
280 |
216 static void |
281 static void |
217 movemouse(Client *c) |
|
218 { |
|
219 XEvent ev; |
|
220 int x1, y1, ocx, ocy, di; |
|
221 unsigned int dui; |
|
222 Window dummy; |
|
223 |
|
224 ocx = c->x; |
|
225 ocy = c->y; |
|
226 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
|
227 None, cursor[CurMove], CurrentTime) != GrabSuccess) |
|
228 return; |
|
229 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); |
|
230 for(;;) { |
|
231 XMaskEvent(dpy, MouseMask | ExposureMask, &ev); |
|
232 switch (ev.type) { |
|
233 default: break; |
|
234 case Expose: |
|
235 handler[Expose](&ev); |
|
236 break; |
|
237 case MotionNotify: |
|
238 XFlush(dpy); |
|
239 c->x = ocx + (ev.xmotion.x - x1); |
|
240 c->y = ocy + (ev.xmotion.y - y1); |
|
241 resize(c, False); |
|
242 break; |
|
243 case ButtonRelease: |
|
244 XUngrabPointer(dpy, CurrentTime); |
|
245 return; |
|
246 } |
|
247 } |
|
248 } |
|
249 |
|
250 static void |
|
251 propertynotify(XEvent *e) |
282 propertynotify(XEvent *e) |
252 { |
283 { |
253 XPropertyEvent *ev = &e->xproperty; |
284 XPropertyEvent *ev = &e->xproperty; |
254 Window trans; |
285 Window trans; |
255 Client *c; |
286 Client *c; |
256 |
287 |
257 if(ev->state == PropertyDelete) |
288 if(ev->state == PropertyDelete) |
258 return; /* ignore */ |
289 return; /* ignore */ |
259 |
290 |
260 if((c = getclient(ev->window))) { |
291 if((c = getclient(ev->window))) { |
261 if(ev->atom == wm_atom[WMProtocols]) { |
292 if(ev->atom == wmatom[WMProtocols]) { |
262 c->proto = getproto(c->win); |
293 c->proto = getproto(c->win); |
263 return; |
294 return; |
264 } |
295 } |
265 switch (ev->atom) { |
296 switch (ev->atom) { |
266 default: break; |
297 default: break; |
271 break; |
302 break; |
272 case XA_WM_NORMAL_HINTS: |
303 case XA_WM_NORMAL_HINTS: |
273 setsize(c); |
304 setsize(c); |
274 break; |
305 break; |
275 } |
306 } |
276 if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) { |
307 if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { |
277 settitle(c); |
308 settitle(c); |
278 drawtitle(c); |
309 drawtitle(c); |
279 } |
|
280 } |
|
281 } |
|
282 |
|
283 static void |
|
284 resizemouse(Client *c) |
|
285 { |
|
286 XEvent ev; |
|
287 int ocx, ocy; |
|
288 |
|
289 ocx = c->x; |
|
290 ocy = c->y; |
|
291 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
|
292 None, cursor[CurResize], CurrentTime) != GrabSuccess) |
|
293 return; |
|
294 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); |
|
295 for(;;) { |
|
296 XMaskEvent(dpy, MouseMask | ExposureMask, &ev); |
|
297 switch(ev.type) { |
|
298 default: break; |
|
299 case Expose: |
|
300 handler[Expose](&ev); |
|
301 break; |
|
302 case MotionNotify: |
|
303 XFlush(dpy); |
|
304 c->w = abs(ocx - ev.xmotion.x); |
|
305 c->h = abs(ocy - ev.xmotion.y); |
|
306 c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w; |
|
307 c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h; |
|
308 resize(c, True); |
|
309 break; |
|
310 case ButtonRelease: |
|
311 XUngrabPointer(dpy, CurrentTime); |
|
312 return; |
|
313 } |
310 } |
314 } |
311 } |
315 } |
312 } |
316 |
313 |
317 static void |
314 static void |