author | arg@mmvi |
Tue, 26 Sep 2006 07:40:19 +0200 | |
changeset 491 | 12395ef46d97 |
parent 490 | 303d3384720e |
child 492 | 5df494262dfd |
permissions | -rw-r--r-- |
491
12395ef46d97
added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents:
490
diff
changeset
|
1 |
#include <stdio.h> |
5 | 2 |
/* |
3 |
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> |
|
4 |
* See LICENSE file for license details. |
|
5 |
*/ |
|
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
6 |
#include "dwm.h" |
5 | 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 |
KEYS |
75 | 21 |
|
291
8e6e0aa5e2ae
removed NUMLOCKMASK, added dynamically calculated numlockmask instead
Anselm R.Garbe <arg@10ksloc.org>
parents:
288
diff
changeset
|
22 |
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) |
75 | 23 |
|
77 | 24 |
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
|
25 |
movemouse(Client *c) { |
77 | 26 |
int x1, y1, ocx, ocy, di; |
27 |
unsigned int dui; |
|
28 |
Window dummy; |
|
123 | 29 |
XEvent ev; |
77 | 30 |
|
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
|
31 |
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
|
32 |
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
|
33 |
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, |
123 | 34 |
None, cursor[CurMove], CurrentTime) != GrabSuccess) |
77 | 35 |
return; |
482 | 36 |
c->ismax = False; |
77 | 37 |
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); |
38 |
for(;;) { |
|
489 | 39 |
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev); |
77 | 40 |
switch (ev.type) { |
490 | 41 |
case ButtonRelease: |
491
12395ef46d97
added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents:
490
diff
changeset
|
42 |
resize(c, True, TopLeft); |
490 | 43 |
XUngrabPointer(dpy, CurrentTime); |
44 |
return; |
|
77 | 45 |
case Expose: |
46 |
handler[Expose](&ev); |
|
47 |
break; |
|
48 |
case MotionNotify: |
|
79
aabebd6e61f3
fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents:
78
diff
changeset
|
49 |
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
|
50 |
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
|
51 |
c->y = ocy + (ev.xmotion.y - y1); |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
52 |
resize(c, False, TopLeft); |
77 | 53 |
break; |
54 |
} |
|
55 |
} |
|
56 |
} |
|
57 |
||
58 |
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
|
59 |
resizemouse(Client *c) { |
77 | 60 |
int ocx, ocy; |
268
a47b3b0d7bf4
applied Sanders LD and resize patches
Anselm R.Garbe <arg@10ksloc.org>
parents:
267
diff
changeset
|
61 |
int nw, nh; |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
62 |
Corner sticky; |
123 | 63 |
XEvent ev; |
77 | 64 |
|
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
|
65 |
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
|
66 |
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
|
67 |
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, |
77 | 68 |
None, cursor[CurResize], CurrentTime) != GrabSuccess) |
69 |
return; |
|
482 | 70 |
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
|
71 |
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h); |
77 | 72 |
for(;;) { |
489 | 73 |
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev); |
77 | 74 |
switch(ev.type) { |
490 | 75 |
case ButtonRelease: |
491
12395ef46d97
added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents:
490
diff
changeset
|
76 |
resize(c, True, TopLeft); |
490 | 77 |
XUngrabPointer(dpy, CurrentTime); |
78 |
return; |
|
77 | 79 |
case Expose: |
80 |
handler[Expose](&ev); |
|
81 |
break; |
|
82 |
case MotionNotify: |
|
79
aabebd6e61f3
fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents:
78
diff
changeset
|
83 |
XSync(dpy, False); |
268
a47b3b0d7bf4
applied Sanders LD and resize patches
Anselm R.Garbe <arg@10ksloc.org>
parents:
267
diff
changeset
|
84 |
if((nw = abs(ocx - ev.xmotion.x))) |
478 | 85 |
c->w = nw; |
268
a47b3b0d7bf4
applied Sanders LD and resize patches
Anselm R.Garbe <arg@10ksloc.org>
parents:
267
diff
changeset
|
86 |
if((nh = abs(ocy - ev.xmotion.y))) |
478 | 87 |
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
|
88 |
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
|
89 |
c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h; |
105 | 90 |
if(ocx <= ev.xmotion.x) |
91 |
sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft; |
|
92 |
else |
|
93 |
sticky = (ocy <= ev.xmotion.y) ? TopRight : BotRight; |
|
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
94 |
resize(c, True, sticky); |
77 | 95 |
break; |
96 |
} |
|
97 |
} |
|
98 |
} |
|
73 | 99 |
|
100 |
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
|
101 |
buttonpress(XEvent *e) { |
73 | 102 |
int x; |
103 |
Arg a; |
|
123 | 104 |
Client *c; |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
105 |
XButtonPressedEvent *ev = &e->xbutton; |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
106 |
|
73 | 107 |
if(barwin == ev->window) { |
362
ba6c55e1b9b2
trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents:
356
diff
changeset
|
108 |
x = 0; |
ba6c55e1b9b2
trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents:
356
diff
changeset
|
109 |
for(a.i = 0; a.i < ntags; a.i++) { |
ba6c55e1b9b2
trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents:
356
diff
changeset
|
110 |
x += textw(tags[a.i]); |
ba6c55e1b9b2
trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents:
356
diff
changeset
|
111 |
if(ev->x < x) { |
399 | 112 |
if(ev->button == Button1) { |
398 | 113 |
if(ev->state & MODKEY) |
114 |
tag(&a); |
|
115 |
else |
|
116 |
view(&a); |
|
399 | 117 |
} |
118 |
else if(ev->button == Button3) { |
|
398 | 119 |
if(ev->state & MODKEY) |
120 |
toggletag(&a); |
|
121 |
else |
|
122 |
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
|
123 |
} |
362
ba6c55e1b9b2
trying a different configuration
Anselm R. Garbe <arg@10kloc.org>
parents:
356
diff
changeset
|
124 |
return; |
73 | 125 |
} |
126 |
} |
|
371
fc9d35252ab4
applied sanders somepatches.patch
Anselm R. Garbe <arg@10kloc.org>
parents:
362
diff
changeset
|
127 |
if(ev->x < x + bmw) { |
fc9d35252ab4
applied sanders somepatches.patch
Anselm R. Garbe <arg@10kloc.org>
parents:
362
diff
changeset
|
128 |
if(ev->button == Button1) |
fc9d35252ab4
applied sanders somepatches.patch
Anselm R. Garbe <arg@10kloc.org>
parents:
362
diff
changeset
|
129 |
togglemode(NULL); |
fc9d35252ab4
applied sanders somepatches.patch
Anselm R. Garbe <arg@10kloc.org>
parents:
362
diff
changeset
|
130 |
} |
73 | 131 |
} |
58
1269bd127551
made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
55
diff
changeset
|
132 |
else if((c = getclient(ev->window))) { |
143 | 133 |
focus(c); |
473
2d8af0d7920d
implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents:
466
diff
changeset
|
134 |
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
|
135 |
return; |
400
052657ff2e7b
applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents:
399
diff
changeset
|
136 |
if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) { |
487 | 137 |
restack(); |
399 | 138 |
movemouse(c); |
139 |
} |
|
140 |
else if(ev->button == Button2) |
|
248
1227c21588e2
applied Sanders zoom_update patch
Anselm R.Garbe <arg@10ksloc.org>
parents:
239
diff
changeset
|
141 |
zoom(NULL); |
400
052657ff2e7b
applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents:
399
diff
changeset
|
142 |
else if(ev->button == Button3 && (arrange == dofloat || c->isfloat)) { |
487 | 143 |
restack(); |
399 | 144 |
resizemouse(c); |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
145 |
} |
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 |
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
|
150 |
configurerequest(XEvent *e) { |
286 | 151 |
unsigned long newmask; |
123 | 152 |
Client *c; |
5 | 153 |
XConfigureRequestEvent *ev = &e->xconfigurerequest; |
489 | 154 |
XEvent synev; |
5 | 155 |
XWindowChanges wc; |
156 |
||
491
12395ef46d97
added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents:
490
diff
changeset
|
157 |
fputs("configurerequest\n", stderr); |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
158 |
if((c = getclient(ev->window))) { |
488 | 159 |
c->ismax = False; |
29 | 160 |
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
|
161 |
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
|
162 |
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
|
163 |
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
|
164 |
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
|
165 |
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
|
166 |
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
|
167 |
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
|
168 |
c->h = ev->height; |
29 | 169 |
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
|
170 |
c->border = ev->border_width; |
29 | 171 |
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
|
172 |
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
|
173 |
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
|
174 |
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
|
175 |
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
|
176 |
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
|
177 |
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
|
178 |
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
|
179 |
else |
12395ef46d97
added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents:
490
diff
changeset
|
180 |
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
|
181 |
XSync(dpy, False); |
385 | 182 |
if(c->isfloat) |
183 |
resize(c, False, TopLeft); |
|
196 | 184 |
else |
185 |
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
|
186 |
} |
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
|
187 |
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
|
188 |
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
|
189 |
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
|
190 |
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
|
191 |
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
|
192 |
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
|
193 |
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
|
194 |
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
|
195 |
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
|
196 |
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
|
197 |
} |
5 | 198 |
} |
199 |
||
200 |
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
|
201 |
destroynotify(XEvent *e) { |
5 | 202 |
Client *c; |
203 |
XDestroyWindowEvent *ev = &e->xdestroywindow; |
|
204 |
||
11 | 205 |
if((c = getclient(ev->window))) |
206 |
unmanage(c); |
|
5 | 207 |
} |
208 |
||
209 |
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
|
210 |
enternotify(XEvent *e) { |
123 | 211 |
Client *c; |
5 | 212 |
XCrossingEvent *ev = &e->xcrossing; |
213 |
||
491
12395ef46d97
added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents:
490
diff
changeset
|
214 |
fputs("enternotify\n", stderr); |
232
98e9901b1dbb
disallow zoom on maximized clients
Anselm R.Garbe <arg@10ksloc.org>
parents:
231
diff
changeset
|
215 |
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) |
5 | 216 |
return; |
217 |
||
466 | 218 |
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
|
219 |
focus(c); |
239
e5390f8e06b9
applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents:
238
diff
changeset
|
220 |
else if(ev->window == root) { |
31 | 221 |
issel = True; |
239
e5390f8e06b9
applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents:
238
diff
changeset
|
222 |
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
e5390f8e06b9
applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents:
238
diff
changeset
|
223 |
drawall(); |
e5390f8e06b9
applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents:
238
diff
changeset
|
224 |
} |
5 | 225 |
} |
226 |
||
227 |
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
|
228 |
expose(XEvent *e) { |
123 | 229 |
Client *c; |
5 | 230 |
XExposeEvent *ev = &e->xexpose; |
231 |
||
232 |
if(ev->count == 0) { |
|
70 | 233 |
if(barwin == ev->window) |
74 | 234 |
drawstatus(); |
75 | 235 |
else if((c = getctitle(ev->window))) |
74 | 236 |
drawtitle(c); |
5 | 237 |
} |
238 |
} |
|
239 |
||
240 |
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
|
241 |
keypress(XEvent *e) { |
138
c1185dc7a36e
some cleanups/fixes inspired by Jukka Salmi's feedback
arg@10ksloc.org
parents:
137
diff
changeset
|
242 |
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
|
243 |
unsigned int i; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
244 |
KeySym keysym; |
123 | 245 |
XKeyEvent *ev = &e->xkey; |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
246 |
|
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
247 |
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); |
275 | 248 |
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
|
249 |
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
|
250 |
&& CLEANMASK(key[i].mod) == CLEANMASK(ev->state)) |
275 | 251 |
{ |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
252 |
if(key[i].func) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
253 |
key[i].func(&key[i].arg); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
254 |
return; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
255 |
} |
275 | 256 |
} |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
257 |
} |
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 |
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
|
260 |
leavenotify(XEvent *e) { |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
261 |
XCrossingEvent *ev = &e->xcrossing; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
262 |
|
239
e5390f8e06b9
applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents:
238
diff
changeset
|
263 |
if((ev->window == root) && !ev->same_screen) { |
e5390f8e06b9
applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents:
238
diff
changeset
|
264 |
issel = False; |
e5390f8e06b9
applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents:
238
diff
changeset
|
265 |
drawall(); |
e5390f8e06b9
applied sumik's multihead patch
Anselm R.Garbe <arg@10ksloc.org>
parents:
238
diff
changeset
|
266 |
} |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
267 |
} |
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 |
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
|
270 |
mappingnotify(XEvent *e) { |
279
2cedfbefd025
added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents:
278
diff
changeset
|
271 |
XMappingEvent *ev = &e->xmapping; |
2cedfbefd025
added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents:
278
diff
changeset
|
272 |
|
2cedfbefd025
added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents:
278
diff
changeset
|
273 |
XRefreshKeyboardMapping(ev); |
2cedfbefd025
added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents:
278
diff
changeset
|
274 |
if(ev->request == MappingKeyboard) |
2cedfbefd025
added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents:
278
diff
changeset
|
275 |
grabkeys(); |
2cedfbefd025
added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents:
278
diff
changeset
|
276 |
} |
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 |
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
|
279 |
maprequest(XEvent *e) { |
123 | 280 |
static XWindowAttributes wa; |
5 | 281 |
XMapRequestEvent *ev = &e->xmaprequest; |
282 |
||
283 |
if(!XGetWindowAttributes(dpy, ev->window, &wa)) |
|
284 |
return; |
|
285 |
||
286 |
if(wa.override_redirect) { |
|
287 |
XSelectInput(dpy, ev->window, |
|
288 |
(StructureNotifyMask | PropertyChangeMask)); |
|
289 |
return; |
|
290 |
} |
|
291 |
||
10
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
292 |
if(!getclient(ev->window)) |
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
293 |
manage(ev->window, &wa); |
5 | 294 |
} |
295 |
||
296 |
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
|
297 |
propertynotify(XEvent *e) { |
123 | 298 |
Client *c; |
53 | 299 |
Window trans; |
123 | 300 |
XPropertyEvent *ev = &e->xproperty; |
5 | 301 |
|
491
12395ef46d97
added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents:
490
diff
changeset
|
302 |
fputs("propertynotify\n", stderr); |
5 | 303 |
if(ev->state == PropertyDelete) |
304 |
return; /* ignore */ |
|
305 |
||
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
306 |
if((c = getclient(ev->window))) { |
77 | 307 |
if(ev->atom == wmatom[WMProtocols]) { |
75 | 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 | 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 | 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 | 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); |
74 | 324 |
drawtitle(c); |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
325 |
} |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
326 |
} |
5 | 327 |
} |
328 |
||
329 |
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
|
330 |
unmapnotify(XEvent *e) { |
5 | 331 |
Client *c; |
332 |
XUnmapEvent *ev = &e->xunmap; |
|
333 |
||
10
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
334 |
if((c = getclient(ev->window))) |
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
335 |
unmanage(c); |
5 | 336 |
} |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
337 |
|
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
338 |
/* extern */ |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
339 |
|
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
340 |
void (*handler[LASTEvent]) (XEvent *) = { |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
341 |
[ButtonPress] = buttonpress, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
342 |
[ConfigureRequest] = configurerequest, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
343 |
[DestroyNotify] = destroynotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
344 |
[EnterNotify] = enternotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
345 |
[LeaveNotify] = leavenotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
346 |
[Expose] = expose, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
347 |
[KeyPress] = keypress, |
279
2cedfbefd025
added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents:
278
diff
changeset
|
348 |
[MappingNotify] = mappingnotify, |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
349 |
[MapRequest] = maprequest, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
350 |
[PropertyNotify] = propertynotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
351 |
[UnmapNotify] = unmapnotify |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
352 |
}; |
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 |
void |
487 | 355 |
grabkeys(void) { |
138
c1185dc7a36e
some cleanups/fixes inspired by Jukka Salmi's feedback
arg@10ksloc.org
parents:
137
diff
changeset
|
356 |
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
|
357 |
unsigned int i; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
358 |
KeyCode code; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
359 |
|
279
2cedfbefd025
added mappingnotify event for kb refreshes
Anselm R.Garbe <arg@10ksloc.org>
parents:
278
diff
changeset
|
360 |
XUngrabKey(dpy, AnyKey, AnyModifier, root); |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
361 |
for(i = 0; i < len; i++) { |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
362 |
code = XKeysymToKeycode(dpy, key[i].keysym); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
363 |
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
|
364 |
GrabModeAsync, GrabModeAsync); |
160 | 365 |
XGrabKey(dpy, code, key[i].mod | LockMask, root, True, |
366 |
GrabModeAsync, GrabModeAsync); |
|
291
8e6e0aa5e2ae
removed NUMLOCKMASK, added dynamically calculated numlockmask instead
Anselm R.Garbe <arg@10ksloc.org>
parents:
288
diff
changeset
|
367 |
XGrabKey(dpy, code, key[i].mod | numlockmask, root, True, |
146
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
145
diff
changeset
|
368 |
GrabModeAsync, GrabModeAsync); |
291
8e6e0aa5e2ae
removed NUMLOCKMASK, added dynamically calculated numlockmask instead
Anselm R.Garbe <arg@10ksloc.org>
parents:
288
diff
changeset
|
369 |
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
|
370 |
GrabModeAsync, GrabModeAsync); |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
371 |
} |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
372 |
} |
292 | 373 |
|
374 |
void |
|
487 | 375 |
procevent(void) { |
292 | 376 |
XEvent ev; |
377 |
||
378 |
while(XPending(dpy)) { |
|
379 |
XNextEvent(dpy, &ev); |
|
380 |
if(handler[ev.type]) |
|
381 |
(handler[ev.type])(&ev); /* call handler */ |
|
382 |
} |
|
383 |
} |