annotate event.c @ 525:7433954e80af

final fix for man page
author Anselm R. Garbe <arg@10kloc.org>
date Thu, 05 Oct 2006 13:44:48 +0200
parents 834a77509a64
children 451f19d48845
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1 /*
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
3 * See LICENSE file for license details.
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
4 */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
5 #include "dwm.h"
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
6 #include <stdlib.h>
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
7 #include <X11/keysym.h>
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
8 #include <X11/Xatom.h>
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
9
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
10 /* static */
114
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
11
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
12 typedef struct {
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
13 unsigned long mod;
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
14 KeySym keysym;
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
15 void (*func)(Arg *arg);
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
16 Arg arg;
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
17 } Key;
dfa5cd0969a6 implemented regexp matching for rules
arg@10ksloc.org
parents: 113
diff changeset
18
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
19 KEYS
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
20
291
8e6e0aa5e2ae removed NUMLOCKMASK, added dynamically calculated numlockmask instead
Anselm R.Garbe <arg@10ksloc.org>
parents: 288
diff changeset
21 #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
22
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
23 static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
24 movemouse(Client *c) {
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
25 int x1, y1, ocx, ocy, di;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
26 unsigned int dui;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
27 Window dummy;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
28 XEvent ev;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
29
115
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
30 ocx = c->x;
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
31 ocy = c->y;
148
5267e1204367 uppercasing all define'd values (uppercase-prefixed should only be enum field qualifiers)
arg@10ksloc.org
parents: 146
diff changeset
32 if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
33 None, cursor[CurMove], CurrentTime) != GrabSuccess)
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
34 return;
482
acb1fc729a8c ismax toggling on mouse based action
arg@mmvi
parents: 478
diff changeset
35 c->ismax = False;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
36 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
37 for(;;) {
489
d34374cbe926 simplified mouse resizals
arg@mmvi
parents: 488
diff changeset
38 XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
39 switch (ev.type) {
490
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
40 case ButtonRelease:
491
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 490
diff changeset
41 resize(c, True, TopLeft);
490
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
42 XUngrabPointer(dpy, CurrentTime);
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
43 return;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
44 case Expose:
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
45 handler[Expose](&ev);
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
46 break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
47 case MotionNotify:
79
aabebd6e61f3 fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents: 78
diff changeset
48 XSync(dpy, False);
115
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
49 c->x = ocx + (ev.xmotion.x - x1);
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
50 c->y = ocy + (ev.xmotion.y - y1);
99
a19556fe83b5 applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents: 95
diff changeset
51 resize(c, False, TopLeft);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
52 break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
53 }
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
54 }
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
55 }
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
56
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
57 static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
58 resizemouse(Client *c) {
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
59 int ocx, ocy;
268
a47b3b0d7bf4 applied Sanders LD and resize patches
Anselm R.Garbe <arg@10ksloc.org>
parents: 267
diff changeset
60 int nw, nh;
99
a19556fe83b5 applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents: 95
diff changeset
61 Corner sticky;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
62 XEvent ev;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
63
115
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
64 ocx = c->x;
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
65 ocy = c->y;
148
5267e1204367 uppercasing all define'd values (uppercase-prefixed should only be enum field qualifiers)
arg@10ksloc.org
parents: 146
diff changeset
66 if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
67 None, cursor[CurResize], CurrentTime) != GrabSuccess)
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
68 return;
482
acb1fc729a8c ismax toggling on mouse based action
arg@mmvi
parents: 478
diff changeset
69 c->ismax = False;
115
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
70 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
71 for(;;) {
489
d34374cbe926 simplified mouse resizals
arg@mmvi
parents: 488
diff changeset
72 XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
73 switch(ev.type) {
490
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
74 case ButtonRelease:
491
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 490
diff changeset
75 resize(c, True, TopLeft);
490
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
76 XUngrabPointer(dpy, CurrentTime);
303d3384720e slight change of event handling order
arg@mmvi
parents: 489
diff changeset
77 return;
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
78 case Expose:
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
79 handler[Expose](&ev);
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
80 break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
81 case MotionNotify:
79
aabebd6e61f3 fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents: 78
diff changeset
82 XSync(dpy, False);
268
a47b3b0d7bf4 applied Sanders LD and resize patches
Anselm R.Garbe <arg@10ksloc.org>
parents: 267
diff changeset
83 if((nw = abs(ocx - ev.xmotion.x)))
478
635b58a87d20 patched resizemouse according to sanders remark
arg@mmvi
parents: 476
diff changeset
84 c->w = nw;
268
a47b3b0d7bf4 applied Sanders LD and resize patches
Anselm R.Garbe <arg@10ksloc.org>
parents: 267
diff changeset
85 if((nh = abs(ocy - ev.xmotion.y)))
478
635b58a87d20 patched resizemouse according to sanders remark
arg@mmvi
parents: 476
diff changeset
86 c->h = nh;
115
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
87 c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
329fd7dae530 removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents: 114
diff changeset
88 c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
105
3e74cc981e9b refactored Sanders code somewhat
arg@10ksloc.org
parents: 99
diff changeset
89 if(ocx <= ev.xmotion.x)
3e74cc981e9b refactored Sanders code somewhat
arg@10ksloc.org
parents: 99
diff changeset
90 sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft;
3e74cc981e9b refactored Sanders code somewhat
arg@10ksloc.org
parents: 99
diff changeset
91 else
3e74cc981e9b refactored Sanders code somewhat
arg@10ksloc.org
parents: 99
diff changeset
92 sticky = (ocy <= ev.xmotion.y) ? TopRight : BotRight;
99
a19556fe83b5 applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents: 95
diff changeset
93 resize(c, True, sticky);
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
94 break;
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
95 }
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
96 }
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
97 }
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
98
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
99 static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
100 buttonpress(XEvent *e) {
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
101 int x;
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
102 Arg a;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
103 Client *c;
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
104 XButtonPressedEvent *ev = &e->xbutton;
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
105
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
106 if(barwin == ev->window) {
362
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 356
diff changeset
107 x = 0;
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 356
diff changeset
108 for(a.i = 0; a.i < ntags; a.i++) {
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 356
diff changeset
109 x += textw(tags[a.i]);
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 356
diff changeset
110 if(ev->x < x) {
399
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
111 if(ev->button == Button1) {
398
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
112 if(ev->state & MODKEY)
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
113 tag(&a);
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
114 else
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
115 view(&a);
399
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
116 }
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
117 else if(ev->button == Button3) {
398
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
118 if(ev->state & MODKEY)
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
119 toggletag(&a);
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
120 else
9c703e528e58 applied sanders patch
Anselm R. Garbe <arg@10kloc.org>
parents: 394
diff changeset
121 toggleview(&a);
394
1da9a6b94ca9 implemented Button2 press on tags for toggletag on the focused client
Anselm R. Garbe <arg@10kloc.org>
parents: 387
diff changeset
122 }
362
ba6c55e1b9b2 trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents: 356
diff changeset
123 return;
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
124 }
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
125 }
371
fc9d35252ab4 applied sanders somepatches.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 362
diff changeset
126 if(ev->x < x + bmw) {
fc9d35252ab4 applied sanders somepatches.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 362
diff changeset
127 if(ev->button == Button1)
fc9d35252ab4 applied sanders somepatches.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 362
diff changeset
128 togglemode(NULL);
520
834a77509a64 Button3 click on mode label toggles stack position now
Anselm R. Garbe <arg@10kloc.org>
parents: 508
diff changeset
129 else if(ev->button == Button3)
834a77509a64 Button3 click on mode label toggles stack position now
Anselm R. Garbe <arg@10kloc.org>
parents: 508
diff changeset
130 togglestackpos(NULL);
371
fc9d35252ab4 applied sanders somepatches.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 362
diff changeset
131 }
73
c2ddb9dbbd10 rearranged
Anselm R. Garbe <garbeam@wmii.de>
parents: 70
diff changeset
132 }
58
1269bd127551 made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents: 55
diff changeset
133 else if((c = getclient(ev->window))) {
143
36cabfe408cd applied Sanders patches
arg@10ksloc.org
parents: 139
diff changeset
134 focus(c);
473
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 466
diff changeset
135 if(CLEANMASK(ev->state) != MODKEY)
318
1b45d6f14fca applied Sanders focus_* patches, removed the unnecessary clean-prefix from the new function names
Anselm R.Garbe <arg@10ksloc.org>
parents: 292
diff changeset
136 return;
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 399
diff changeset
137 if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 482
diff changeset
138 restack();
399
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
139 movemouse(c);
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
140 }
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
141 else if(ev->button == Button2)
248
1227c21588e2 applied Sanders zoom_update patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 239
diff changeset
142 zoom(NULL);
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 399
diff changeset
143 else if(ev->button == Button3 && (arrange == dofloat || c->isfloat)) {
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 482
diff changeset
144 restack();
399
74739798b0b2 simplified buttonpress
Anselm R. Garbe <arg@10kloc.org>
parents: 398
diff changeset
145 resizemouse(c);
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
146 }
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
147 }
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
148 }
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
149
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
150 static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
151 configurerequest(XEvent *e) {
286
Anselm R.Garbe <arg@10ksloc.org>
parents: 282
diff changeset
152 unsigned long newmask;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
153 Client *c;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
154 XConfigureRequestEvent *ev = &e->xconfigurerequest;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
155 XWindowChanges wc;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
156
18
1efa34c6e1b6 added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents: 16
diff changeset
157 if((c = getclient(ev->window))) {
488
0d2559f46b9e applied sanders jukka patch
arg@mmvi
parents: 487
diff changeset
158 c->ismax = False;
29
8ad86d0a6a53 added gravity stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 26
diff changeset
159 gravitate(c, True);
195
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
160 if(ev->value_mask & CWX)
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
161 c->x = ev->x;
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
162 if(ev->value_mask & CWY)
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
163 c->y = ev->y;
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
164 if(ev->value_mask & CWWidth)
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
165 c->w = ev->width;
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
166 if(ev->value_mask & CWHeight)
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
167 c->h = ev->height;
29
8ad86d0a6a53 added gravity stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 26
diff changeset
168 if(ev->value_mask & CWBorderWidth)
164
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
169 c->border = ev->border_width;
29
8ad86d0a6a53 added gravity stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 26
diff changeset
170 gravitate(c, False);
164
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
171 wc.x = c->x;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
172 wc.y = c->y;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
173 wc.width = c->w;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
174 wc.height = c->h;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
175 newmask = ev->value_mask & (~(CWSibling | CWStackMode | CWBorderWidth));
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
176 if(newmask)
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
177 XConfigureWindow(dpy, c->win, newmask, &wc);
491
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 490
diff changeset
178 else
12395ef46d97 added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents: 490
diff changeset
179 configure(c);
195
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
180 XSync(dpy, False);
505
2c29d74b11dc first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents: 500
diff changeset
181 if(c->isfloat) {
508
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 506
diff changeset
182 resize(c, False, TopLeft);
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 506
diff changeset
183 if(!isvisible(c))
ede48935f2b3 added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents: 506
diff changeset
184 ban(c);
505
2c29d74b11dc first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents: 500
diff changeset
185 }
196
d560e796f7fe small performance tweak ;)
arg@10ksloc.org
parents: 195
diff changeset
186 else
d560e796f7fe small performance tweak ;)
arg@10ksloc.org
parents: 195
diff changeset
187 arrange(NULL);
164
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
188 }
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
189 else {
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
190 wc.x = ev->x;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
191 wc.y = ev->y;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
192 wc.width = ev->width;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
193 wc.height = ev->height;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
194 wc.border_width = ev->border_width;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
195 wc.sibling = ev->above;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
196 wc.stack_mode = ev->detail;
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
197 XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
195
97960220eb77 fixed xterm font change (all other related apps should work fine with this fix as well)
arg@10ksloc.org
parents: 178
diff changeset
198 XSync(dpy, False);
164
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 163
diff changeset
199 }
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
200 }
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
201
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
202 static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
203 destroynotify(XEvent *e) {
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
204 Client *c;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
205 XDestroyWindowEvent *ev = &e->xdestroywindow;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
206
11
ea9c08ec4b48 added gridsel to gridwm
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
207 if((c = getclient(ev->window)))
ea9c08ec4b48 added gridsel to gridwm
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
208 unmanage(c);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
209 }
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
210
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
211 static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
212 enternotify(XEvent *e) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
213 Client *c;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
214 XCrossingEvent *ev = &e->xcrossing;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
215
232
98e9901b1dbb disallow zoom on maximized clients
Anselm R.Garbe <arg@10ksloc.org>
parents: 231
diff changeset
216 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
217 return;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
218
466
ad3fa2d18542 added visibility check to enternotify as well
arg@mmvi
parents: 461
diff changeset
219 if(((c = getclient(ev->window)) || (c = getctitle(ev->window))) && isvisible(c))
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
220 focus(c);
239
e5390f8e06b9 applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 238
diff changeset
221 else if(ev->window == root) {
31
386649deb651 before leaning things up
Anselm R. Garbe <garbeam@wmii.de>
parents: 30
diff changeset
222 issel = True;
239
e5390f8e06b9 applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 238
diff changeset
223 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
e5390f8e06b9 applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 238
diff changeset
224 drawall();
e5390f8e06b9 applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 238
diff changeset
225 }
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
226 }
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
227
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
228 static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
229 expose(XEvent *e) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
230 Client *c;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
231 XExposeEvent *ev = &e->xexpose;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
232
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
233 if(ev->count == 0) {
70
e5fff8249705 draw bar on exposure ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 63
diff changeset
234 if(barwin == ev->window)
74
5370ef170cc9 sanitized names
Anselm R. Garbe <garbeam@wmii.de>
parents: 73
diff changeset
235 drawstatus();
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
236 else if((c = getctitle(ev->window)))
74
5370ef170cc9 sanitized names
Anselm R. Garbe <garbeam@wmii.de>
parents: 73
diff changeset
237 drawtitle(c);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
238 }
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
239 }
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
240
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
241 static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
242 keypress(XEvent *e) {
138
c1185dc7a36e some cleanups/fixes inspired by Jukka Salmi's feedback
arg@10ksloc.org
parents: 137
diff changeset
243 static unsigned int len = sizeof(key) / sizeof(key[0]);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
244 unsigned int i;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
245 KeySym keysym;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
246 XKeyEvent *ev = &e->xkey;
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
247
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
248 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
275
425cd4490c1e some other small fixes
Anselm R.Garbe <arg@10ksloc.org>
parents: 274
diff changeset
249 for(i = 0; i < len; i++) {
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
250 if(keysym == key[i].keysym
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
251 && CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
275
425cd4490c1e some other small fixes
Anselm R.Garbe <arg@10ksloc.org>
parents: 274
diff changeset
252 {
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
253 if(key[i].func)
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
254 key[i].func(&key[i].arg);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
255 return;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
256 }
275
425cd4490c1e some other small fixes
Anselm R.Garbe <arg@10ksloc.org>
parents: 274
diff changeset
257 }
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
258 }
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
259
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
260 static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
261 leavenotify(XEvent *e) {
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
262 XCrossingEvent *ev = &e->xcrossing;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
263
239
e5390f8e06b9 applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 238
diff changeset
264 if((ev->window == root) && !ev->same_screen) {
e5390f8e06b9 applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 238
diff changeset
265 issel = False;
e5390f8e06b9 applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 238
diff changeset
266 drawall();
e5390f8e06b9 applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents: 238
diff changeset
267 }
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
268 }
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
269
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
270 static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
271 mappingnotify(XEvent *e) {
279
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
272 XMappingEvent *ev = &e->xmapping;
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
273
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
274 XRefreshKeyboardMapping(ev);
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
275 if(ev->request == MappingKeyboard)
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
276 grabkeys();
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
277 }
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
278
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
279 static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
280 maprequest(XEvent *e) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
281 static XWindowAttributes wa;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
282 XMapRequestEvent *ev = &e->xmaprequest;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
283
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
284 if(!XGetWindowAttributes(dpy, ev->window, &wa))
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
285 return;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
286
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
287 if(wa.override_redirect) {
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
288 XSelectInput(dpy, ev->window,
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
289 (StructureNotifyMask | PropertyChangeMask));
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
290 return;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
291 }
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
292
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
293 if(!getclient(ev->window))
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
294 manage(ev->window, &wa);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
295 }
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
296
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
297 static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
298 propertynotify(XEvent *e) {
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
299 Client *c;
53
529901e6a227 added mini stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 43
diff changeset
300 Window trans;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 121
diff changeset
301 XPropertyEvent *ev = &e->xproperty;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
302
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
303 if(ev->state == PropertyDelete)
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
304 return; /* ignore */
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
305
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
306 if((c = getclient(ev->window))) {
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
307 if(ev->atom == wmatom[WMProtocols]) {
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
308 c->proto = getproto(c->win);
30
2e0fb4130bfb new stuff, fixed several issues
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
309 return;
2e0fb4130bfb new stuff, fixed several issues
Anselm R. Garbe <garbeam@wmii.de>
parents: 29
diff changeset
310 }
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
311 switch (ev->atom) {
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
312 default: break;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
313 case XA_WM_TRANSIENT_FOR:
53
529901e6a227 added mini stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 43
diff changeset
314 XGetTransientForHint(dpy, c->win, &trans);
80
8125f908c80c several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
315 if(!c->isfloat && (c->isfloat = (trans != 0)))
53
529901e6a227 added mini stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 43
diff changeset
316 arrange(NULL);
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
317 break;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
318 case XA_WM_NORMAL_HINTS:
454
ffb462fb7903 small change to comments, renamed two set* functions in client.c into update*
Anselm R. Garbe <arg@10kloc.org>
parents: 400
diff changeset
319 updatesize(c);
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
320 break;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
321 }
77
38c8f7f7d401 sanitized other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 76
diff changeset
322 if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
454
ffb462fb7903 small change to comments, renamed two set* functions in client.c into update*
Anselm R. Garbe <arg@10kloc.org>
parents: 400
diff changeset
323 updatetitle(c);
500
d5ad819f2a66 fixing the settags issue, preparing 1.7.1
Anselm R. Garbe <arg@10kloc.org>
parents: 499
diff changeset
324 resizetitle(c);
74
5370ef170cc9 sanitized names
Anselm R. Garbe <garbeam@wmii.de>
parents: 73
diff changeset
325 drawtitle(c);
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
326 }
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 11
diff changeset
327 }
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
328 }
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
329
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
330 static void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 454
diff changeset
331 unmapnotify(XEvent *e) {
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
332 Client *c;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
333 XUnmapEvent *ev = &e->xunmap;
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
334
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
335 if((c = getclient(ev->window)))
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
336 unmanage(c);
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
337 }
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
338
84
052fe7498930 ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents: 80
diff changeset
339 /* extern */
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
340
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
341 void (*handler[LASTEvent]) (XEvent *) = {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
342 [ButtonPress] = buttonpress,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
343 [ConfigureRequest] = configurerequest,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
344 [DestroyNotify] = destroynotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
345 [EnterNotify] = enternotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
346 [LeaveNotify] = leavenotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
347 [Expose] = expose,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
348 [KeyPress] = keypress,
279
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
349 [MappingNotify] = mappingnotify,
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
350 [MapRequest] = maprequest,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
351 [PropertyNotify] = propertynotify,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
352 [UnmapNotify] = unmapnotify
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
353 };
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
354
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
355 void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 482
diff changeset
356 grabkeys(void) {
138
c1185dc7a36e some cleanups/fixes inspired by Jukka Salmi's feedback
arg@10ksloc.org
parents: 137
diff changeset
357 static unsigned int len = sizeof(key) / sizeof(key[0]);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
358 unsigned int i;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
359 KeyCode code;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
360
279
2cedfbefd025 added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents: 278
diff changeset
361 XUngrabKey(dpy, AnyKey, AnyModifier, root);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
362 for(i = 0; i < len; i++) {
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
363 code = XKeysymToKeycode(dpy, key[i].keysym);
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
364 XGrabKey(dpy, code, key[i].mod, root, True,
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
365 GrabModeAsync, GrabModeAsync);
160
c8db0a825775 applied Sanders patches (numlock2)
arg@10ksloc.org
parents: 159
diff changeset
366 XGrabKey(dpy, code, key[i].mod | LockMask, root, True,
c8db0a825775 applied Sanders patches (numlock2)
arg@10ksloc.org
parents: 159
diff changeset
367 GrabModeAsync, GrabModeAsync);
291
8e6e0aa5e2ae removed NUMLOCKMASK, added dynamically calculated numlockmask instead
Anselm R.Garbe <arg@10ksloc.org>
parents: 288
diff changeset
368 XGrabKey(dpy, code, key[i].mod | numlockmask, root, True,
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
369 GrabModeAsync, GrabModeAsync);
291
8e6e0aa5e2ae removed NUMLOCKMASK, added dynamically calculated numlockmask instead
Anselm R.Garbe <arg@10ksloc.org>
parents: 288
diff changeset
370 XGrabKey(dpy, code, key[i].mod | numlockmask | LockMask, root, True,
146
f328ce9c558c centralized/externalized configuration to config.h
arg@10ksloc.org
parents: 145
diff changeset
371 GrabModeAsync, GrabModeAsync);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
372 }
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
373 }
292
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
374
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
375 void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 482
diff changeset
376 procevent(void) {
292
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
377 XEvent ev;
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
378
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
379 while(XPending(dpy)) {
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
380 XNextEvent(dpy, &ev);
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
381 if(handler[ev.type])
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
382 (handler[ev.type])(&ev); /* call handler */
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
383 }
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
384 }