Mercurial > dwm-meillo
annotate event.c @ 146:f328ce9c558c
centralized/externalized configuration to config.h
author | arg@10ksloc.org |
---|---|
date | Tue, 01 Aug 2006 13:59:13 +0200 |
parents | 774754477c35 |
children | 5267e1204367 |
rev | line source |
---|---|
5 | 1 /* |
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> | |
3 * See LICENSE file for license details. | |
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 | 6 |
7 #include <stdlib.h> | |
8 #include <X11/keysym.h> | |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
9 #include <X11/Xatom.h> |
5 | 10 |
146
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
145
diff
changeset
|
11 /* static */ |
114 | 12 |
13 typedef struct { | |
14 unsigned long mod; | |
15 KeySym keysym; | |
16 void (*func)(Arg *arg); | |
17 Arg arg; | |
18 } Key; | |
19 | |
146
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
145
diff
changeset
|
20 CMDS |
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
145
diff
changeset
|
21 KEYS |
75 | 22 |
146
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
145
diff
changeset
|
23 static unsigned int valid_mask = 255 & ~(NUMLOCKMASK | LockMask); |
75 | 24 |
77 | 25 static void |
26 movemouse(Client *c) | |
27 { | |
28 int x1, y1, ocx, ocy, di; | |
29 unsigned int dui; | |
30 Window dummy; | |
123 | 31 XEvent ev; |
77 | 32 |
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
|
33 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
|
34 ocy = c->y; |
77 | 35 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
123 | 36 None, cursor[CurMove], CurrentTime) != GrabSuccess) |
77 | 37 return; |
38 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); | |
39 for(;;) { | |
40 XMaskEvent(dpy, MouseMask | ExposureMask, &ev); | |
41 switch (ev.type) { | |
42 default: break; | |
43 case Expose: | |
44 handler[Expose](&ev); | |
45 break; | |
46 case MotionNotify: | |
79
aabebd6e61f3
fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents:
78
diff
changeset
|
47 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
|
48 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
|
49 c->y = ocy + (ev.xmotion.y - y1); |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
50 resize(c, False, TopLeft); |
77 | 51 break; |
52 case ButtonRelease: | |
53 XUngrabPointer(dpy, CurrentTime); | |
54 return; | |
55 } | |
56 } | |
57 } | |
58 | |
59 static void | |
60 resizemouse(Client *c) | |
61 { | |
62 int ocx, ocy; | |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
63 Corner sticky; |
123 | 64 XEvent ev; |
77 | 65 |
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
|
66 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
|
67 ocy = c->y; |
77 | 68 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
69 None, cursor[CurResize], CurrentTime) != GrabSuccess) | |
70 return; | |
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
|
71 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); |
77 | 72 for(;;) { |
73 XMaskEvent(dpy, MouseMask | ExposureMask, &ev); | |
74 switch(ev.type) { | |
75 default: break; | |
76 case Expose: | |
77 handler[Expose](&ev); | |
78 break; | |
79 case MotionNotify: | |
79
aabebd6e61f3
fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents:
78
diff
changeset
|
80 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
|
81 c->w = abs(ocx - ev.xmotion.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
|
82 c->h = abs(ocy - ev.xmotion.y); |
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
|
83 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
|
84 c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h; |
105 | 85 if(ocx <= ev.xmotion.x) |
86 sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft; | |
87 else | |
88 sticky = (ocy <= ev.xmotion.y) ? TopRight : BotRight; | |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
89 resize(c, True, sticky); |
77 | 90 break; |
91 case ButtonRelease: | |
92 XUngrabPointer(dpy, CurrentTime); | |
93 return; | |
94 } | |
95 } | |
96 } | |
73 | 97 |
98 static void | |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
99 buttonpress(XEvent *e) |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
100 { |
73 | 101 int x; |
102 Arg a; | |
123 | 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 | 106 if(barwin == ev->window) { |
80
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
107 switch(ev->button) { |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
108 default: |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
109 x = 0; |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
110 for(a.i = 0; a.i < TLast; a.i++) { |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
111 x += textw(tags[a.i]); |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
112 if(ev->x < x) { |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
113 view(&a); |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
114 break; |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
115 } |
73 | 116 } |
80
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
117 break; |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
118 case Button4: |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
119 a.i = (tsel + 1 < TLast) ? tsel + 1 : 0; |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
120 view(&a); |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
121 break; |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
122 case Button5: |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
123 a.i = (tsel - 1 >= 0) ? tsel - 1 : TLast - 1; |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
124 view(&a); |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
125 break; |
73 | 126 } |
127 } | |
58
1269bd127551
made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
55
diff
changeset
|
128 else if((c = getclient(ev->window))) { |
143 | 129 focus(c); |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
130 switch(ev->button) { |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
131 default: |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
132 break; |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
133 case Button1: |
133 | 134 if(!c->ismax && (arrange == dofloat || c->isfloat)) { |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
135 higher(c); |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
136 movemouse(c); |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
137 } |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
138 break; |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
139 case Button2: |
26
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
25
diff
changeset
|
140 lower(c); |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
141 break; |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
142 case Button3: |
133 | 143 if(!c->ismax && (arrange == dofloat || c->isfloat)) { |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
144 higher(c); |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
145 resizemouse(c); |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
146 } |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
147 break; |
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 } |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
151 |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
152 static void |
5 | 153 configurerequest(XEvent *e) |
154 { | |
123 | 155 Client *c; |
5 | 156 XConfigureRequestEvent *ev = &e->xconfigurerequest; |
157 XWindowChanges wc; | |
158 | |
159 ev->value_mask &= ~CWSibling; | |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
160 if((c = getclient(ev->window))) { |
29 | 161 gravitate(c, True); |
5 | 162 if(ev->value_mask & CWX) |
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
|
163 c->x = ev->x; |
5 | 164 if(ev->value_mask & CWY) |
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
|
165 c->y = ev->y; |
5 | 166 if(ev->value_mask & CWWidth) |
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
|
167 c->w = ev->width; |
5 | 168 if(ev->value_mask & CWHeight) |
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
|
169 c->h = ev->height; |
29 | 170 if(ev->value_mask & CWBorderWidth) |
55 | 171 c->border = 1; |
29 | 172 gravitate(c, False); |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
173 resize(c, True, TopLeft); |
5 | 174 } |
175 | |
176 wc.x = ev->x; | |
177 wc.y = ev->y; | |
178 wc.width = ev->width; | |
179 wc.height = ev->height; | |
25 | 180 wc.border_width = 1; |
5 | 181 wc.sibling = None; |
182 wc.stack_mode = Above; | |
183 ev->value_mask &= ~CWStackMode; | |
184 ev->value_mask |= CWBorderWidth; | |
185 XConfigureWindow(dpy, ev->window, ev->value_mask, &wc); | |
79
aabebd6e61f3
fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents:
78
diff
changeset
|
186 XSync(dpy, False); |
5 | 187 } |
188 | |
189 static void | |
190 destroynotify(XEvent *e) | |
191 { | |
192 Client *c; | |
193 XDestroyWindowEvent *ev = &e->xdestroywindow; | |
194 | |
11 | 195 if((c = getclient(ev->window))) |
196 unmanage(c); | |
5 | 197 } |
198 | |
199 static void | |
200 enternotify(XEvent *e) | |
201 { | |
123 | 202 Client *c; |
5 | 203 XCrossingEvent *ev = &e->xcrossing; |
204 | |
143 | 205 if(ev->detail == NotifyInferior) |
5 | 206 return; |
207 | |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
208 if((c = getclient(ev->window))) |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
209 focus(c); |
26
e8f627998d6f
simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
Anselm R. Garbe <garbeam@wmii.de>
parents:
25
diff
changeset
|
210 else if(ev->window == root) |
31 | 211 issel = True; |
5 | 212 } |
213 | |
214 static void | |
215 expose(XEvent *e) | |
216 { | |
123 | 217 Client *c; |
5 | 218 XExposeEvent *ev = &e->xexpose; |
219 | |
220 if(ev->count == 0) { | |
70 | 221 if(barwin == ev->window) |
74 | 222 drawstatus(); |
75 | 223 else if((c = getctitle(ev->window))) |
74 | 224 drawtitle(c); |
5 | 225 } |
226 } | |
227 | |
228 static void | |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
229 keypress(XEvent *e) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
230 { |
138
c1185dc7a36e
some cleanups/fixes inspired by Jukka Salmi's feedback
arg@10ksloc.org
parents:
137
diff
changeset
|
231 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
|
232 unsigned int i; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
233 KeySym keysym; |
123 | 234 XKeyEvent *ev = &e->xkey; |
145 | 235 ev->state &= valid_mask; |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
236 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
237 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
238 for(i = 0; i < len; i++) |
145 | 239 if((keysym == key[i].keysym) && ((key[i].mod & valid_mask) == ev->state)) { |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
240 if(key[i].func) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
241 key[i].func(&key[i].arg); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
242 return; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
243 } |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
244 } |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
245 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
246 static void |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
247 leavenotify(XEvent *e) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
248 { |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
249 XCrossingEvent *ev = &e->xcrossing; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
250 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
251 if((ev->window == root) && !ev->same_screen) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
252 issel = True; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
253 } |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
254 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
255 static void |
5 | 256 maprequest(XEvent *e) |
257 { | |
123 | 258 static XWindowAttributes wa; |
5 | 259 XMapRequestEvent *ev = &e->xmaprequest; |
260 | |
261 if(!XGetWindowAttributes(dpy, ev->window, &wa)) | |
262 return; | |
263 | |
264 if(wa.override_redirect) { | |
265 XSelectInput(dpy, ev->window, | |
266 (StructureNotifyMask | PropertyChangeMask)); | |
267 return; | |
268 } | |
269 | |
10
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
270 if(!getclient(ev->window)) |
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
271 manage(ev->window, &wa); |
5 | 272 } |
273 | |
274 static void | |
275 propertynotify(XEvent *e) | |
276 { | |
123 | 277 Client *c; |
53 | 278 Window trans; |
123 | 279 XPropertyEvent *ev = &e->xproperty; |
5 | 280 |
281 if(ev->state == PropertyDelete) | |
282 return; /* ignore */ | |
283 | |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
284 if((c = getclient(ev->window))) { |
77 | 285 if(ev->atom == wmatom[WMProtocols]) { |
75 | 286 c->proto = getproto(c->win); |
30
2e0fb4130bfb
new stuff, fixed several issues
Anselm R. Garbe <garbeam@wmii.de>
parents:
29
diff
changeset
|
287 return; |
2e0fb4130bfb
new stuff, fixed several issues
Anselm R. Garbe <garbeam@wmii.de>
parents:
29
diff
changeset
|
288 } |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
289 switch (ev->atom) { |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
290 default: break; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
291 case XA_WM_TRANSIENT_FOR: |
53 | 292 XGetTransientForHint(dpy, c->win, &trans); |
80
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
293 if(!c->isfloat && (c->isfloat = (trans != 0))) |
53 | 294 arrange(NULL); |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
295 break; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
296 case XA_WM_NORMAL_HINTS: |
74 | 297 setsize(c); |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
298 break; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
299 } |
77 | 300 if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { |
74 | 301 settitle(c); |
302 drawtitle(c); | |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
303 } |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
304 } |
5 | 305 } |
306 | |
307 static void | |
308 unmapnotify(XEvent *e) | |
309 { | |
310 Client *c; | |
311 XUnmapEvent *ev = &e->xunmap; | |
312 | |
10
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
313 if((c = getclient(ev->window))) |
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
314 unmanage(c); |
5 | 315 } |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
316 |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
317 /* extern */ |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
318 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
319 void (*handler[LASTEvent]) (XEvent *) = { |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
320 [ButtonPress] = buttonpress, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
321 [ConfigureRequest] = configurerequest, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
322 [DestroyNotify] = destroynotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
323 [EnterNotify] = enternotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
324 [LeaveNotify] = leavenotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
325 [Expose] = expose, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
326 [KeyPress] = keypress, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
327 [MapRequest] = maprequest, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
328 [PropertyNotify] = propertynotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
329 [UnmapNotify] = unmapnotify |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
330 }; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
331 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
332 void |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
333 grabkeys() |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
334 { |
138
c1185dc7a36e
some cleanups/fixes inspired by Jukka Salmi's feedback
arg@10ksloc.org
parents:
137
diff
changeset
|
335 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
|
336 unsigned int i; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
337 KeyCode code; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
338 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
339 for(i = 0; i < len; i++) { |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
340 code = XKeysymToKeycode(dpy, key[i].keysym); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
341 XUngrabKey(dpy, code, key[i].mod, root); |
146
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
145
diff
changeset
|
342 XUngrabKey(dpy, code, key[i].mod | NUMLOCKMASK, root); |
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
145
diff
changeset
|
343 XUngrabKey(dpy, code, key[i].mod | NUMLOCKMASK | LockMask, root); |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
344 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
|
345 GrabModeAsync, GrabModeAsync); |
146
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
145
diff
changeset
|
346 XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK, root, True, |
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
145
diff
changeset
|
347 GrabModeAsync, GrabModeAsync); |
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
145
diff
changeset
|
348 XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK | LockMask, root, True, |
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
145
diff
changeset
|
349 GrabModeAsync, GrabModeAsync); |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
350 } |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
351 } |