Mercurial > dwm-meillo
annotate event.c @ 109:00309fb2b4d8
Added tag 0.3 for changeset 7e66082e5092fb0bccd18a3695a0bec52c80fdb2
author | arg@10ksloc.org |
---|---|
date | Wed, 19 Jul 2006 14:44:44 +0200 |
parents | f5b0c3d22d93 |
children | 2a1879e05d5a |
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 |
73 | 11 #define ButtonMask (ButtonPressMask | ButtonReleaseMask) |
12 #define MouseMask (ButtonMask | PointerMotionMask) | |
13 | |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
14 /* CUSTOMIZE */ |
107 | 15 const char *term[] = { "xterm", NULL }; |
75 | 16 |
17 Key key[] = { | |
18 /* modifier key function arguments */ | |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
19 { ControlMask, XK_0, appendtag, { .i = Tscratch } }, |
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
20 { ControlMask, XK_1, appendtag, { .i = Tdev } }, |
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
21 { ControlMask, XK_2, appendtag, { .i = Twww } }, |
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
22 { ControlMask, XK_3, appendtag, { .i = Twork } }, |
75 | 23 { Mod1Mask, XK_0, view, { .i = Tscratch } }, |
24 { Mod1Mask, XK_1, view, { .i = Tdev } }, | |
25 { Mod1Mask, XK_2, view, { .i = Twww } }, | |
26 { Mod1Mask, XK_3, view, { .i = Twork } }, | |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
27 { Mod1Mask, XK_j, focusnext, { 0 } }, |
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
28 { Mod1Mask, XK_k, focusprev, { 0 } }, |
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
29 { Mod1Mask, XK_m, maximize, { 0 } }, |
75 | 30 { Mod1Mask, XK_space, dotile, { 0 } }, |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
31 { Mod1Mask, XK_Return, zoom, { 0 } }, |
93
c498da7520c7
added heretag command which allows to tag a client of a foreign tag with current tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
84
diff
changeset
|
32 { ControlMask|ShiftMask,XK_0, heretag, { .i = Tscratch } }, |
c498da7520c7
added heretag command which allows to tag a client of a foreign tag with current tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
84
diff
changeset
|
33 { ControlMask|ShiftMask,XK_1, heretag, { .i = Tdev } }, |
c498da7520c7
added heretag command which allows to tag a client of a foreign tag with current tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
84
diff
changeset
|
34 { ControlMask|ShiftMask,XK_2, heretag, { .i = Twww } }, |
c498da7520c7
added heretag command which allows to tag a client of a foreign tag with current tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
84
diff
changeset
|
35 { ControlMask|ShiftMask,XK_3, heretag, { .i = Twork } }, |
75 | 36 { Mod1Mask|ShiftMask, XK_0, replacetag, { .i = Tscratch } }, |
37 { Mod1Mask|ShiftMask, XK_1, replacetag, { .i = Tdev } }, | |
38 { Mod1Mask|ShiftMask, XK_2, replacetag, { .i = Twww } }, | |
39 { Mod1Mask|ShiftMask, XK_3, replacetag, { .i = Twork } }, | |
40 { Mod1Mask|ShiftMask, XK_c, killclient, { 0 } }, | |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
41 { Mod1Mask|ShiftMask, XK_q, quit, { 0 } }, |
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
42 { Mod1Mask|ShiftMask, XK_space, dofloat, { 0 } }, |
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
43 { Mod1Mask|ShiftMask, XK_Return, spawn, { .argv = term } }, |
75 | 44 }; |
45 | |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
46 /* static */ |
75 | 47 |
77 | 48 static void |
49 movemouse(Client *c) | |
50 { | |
51 XEvent ev; | |
52 int x1, y1, ocx, ocy, di; | |
53 unsigned int dui; | |
54 Window dummy; | |
55 | |
95
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
56 ocx = *c->x; |
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
57 ocy = *c->y; |
77 | 58 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
59 None, cursor[CurMove], CurrentTime) != GrabSuccess) | |
60 return; | |
61 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); | |
62 for(;;) { | |
63 XMaskEvent(dpy, MouseMask | ExposureMask, &ev); | |
64 switch (ev.type) { | |
65 default: break; | |
66 case Expose: | |
67 handler[Expose](&ev); | |
68 break; | |
69 case MotionNotify: | |
79
aabebd6e61f3
fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents:
78
diff
changeset
|
70 XSync(dpy, False); |
95
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
71 *c->x = ocx + (ev.xmotion.x - x1); |
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
72 *c->y = ocy + (ev.xmotion.y - y1); |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
73 resize(c, False, TopLeft); |
77 | 74 break; |
75 case ButtonRelease: | |
76 XUngrabPointer(dpy, CurrentTime); | |
77 return; | |
78 } | |
79 } | |
80 } | |
81 | |
82 static void | |
83 resizemouse(Client *c) | |
84 { | |
85 XEvent ev; | |
86 int ocx, ocy; | |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
87 Corner sticky; |
77 | 88 |
95
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
89 ocx = *c->x; |
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
90 ocy = *c->y; |
77 | 91 if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync, |
92 None, cursor[CurResize], CurrentTime) != GrabSuccess) | |
93 return; | |
95
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
94 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, *c->w, *c->h); |
77 | 95 for(;;) { |
96 XMaskEvent(dpy, MouseMask | ExposureMask, &ev); | |
97 switch(ev.type) { | |
98 default: break; | |
99 case Expose: | |
100 handler[Expose](&ev); | |
101 break; | |
102 case MotionNotify: | |
79
aabebd6e61f3
fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents:
78
diff
changeset
|
103 XSync(dpy, False); |
95
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
104 *c->w = abs(ocx - ev.xmotion.x); |
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
105 *c->h = abs(ocy - ev.xmotion.y); |
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
106 *c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - *c->w; |
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
107 *c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - *c->h; |
105 | 108 if(ocx <= ev.xmotion.x) |
109 sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft; | |
110 else | |
111 sticky = (ocy <= ev.xmotion.y) ? TopRight : BotRight; | |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
112 resize(c, True, sticky); |
77 | 113 break; |
114 case ButtonRelease: | |
115 XUngrabPointer(dpy, CurrentTime); | |
116 return; | |
117 } | |
118 } | |
119 } | |
73 | 120 |
121 static void | |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
122 buttonpress(XEvent *e) |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
123 { |
73 | 124 int x; |
125 Arg a; | |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
126 XButtonPressedEvent *ev = &e->xbutton; |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
127 Client *c; |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
128 |
73 | 129 if(barwin == ev->window) { |
80
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
130 switch(ev->button) { |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
131 default: |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
132 x = 0; |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
133 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
|
134 x += textw(tags[a.i]); |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
135 if(ev->x < x) { |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
136 view(&a); |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
137 break; |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
138 } |
73 | 139 } |
80
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
140 break; |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
141 case Button4: |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
142 a.i = (tsel + 1 < TLast) ? tsel + 1 : 0; |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
143 view(&a); |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
144 break; |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
145 case Button5: |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
146 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
|
147 view(&a); |
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
148 break; |
73 | 149 } |
150 } | |
58
1269bd127551
made barclick to select the specific tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
55
diff
changeset
|
151 else if((c = getclient(ev->window))) { |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
152 switch(ev->button) { |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
153 default: |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
154 break; |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
155 case Button1: |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
156 if(arrange == dotile && !c->isfloat) { |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
157 if((ev->state & ControlMask) && (ev->button == Button1)) |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
158 zoom(NULL); |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
159 } |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
160 else { |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
161 higher(c); |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
162 movemouse(c); |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
163 } |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
164 break; |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
165 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
|
166 lower(c); |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
167 break; |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
168 case Button3: |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
169 if(arrange == dofloat || c->isfloat) { |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
170 higher(c); |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
171 resizemouse(c); |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
172 } |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
173 break; |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
174 } |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
175 } |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
176 } |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
177 |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
178 static void |
5 | 179 configurerequest(XEvent *e) |
180 { | |
181 XConfigureRequestEvent *ev = &e->xconfigurerequest; | |
182 XWindowChanges wc; | |
183 Client *c; | |
184 | |
185 ev->value_mask &= ~CWSibling; | |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
186 if((c = getclient(ev->window))) { |
29 | 187 gravitate(c, True); |
5 | 188 if(ev->value_mask & CWX) |
95
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
189 *c->x = ev->x; |
5 | 190 if(ev->value_mask & CWY) |
95
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
191 *c->y = ev->y; |
5 | 192 if(ev->value_mask & CWWidth) |
95
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
193 *c->w = ev->width; |
5 | 194 if(ev->value_mask & CWHeight) |
95
5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
Anselm R. Garbe <garbeam@wmii.de>
parents:
93
diff
changeset
|
195 *c->h = ev->height; |
29 | 196 if(ev->value_mask & CWBorderWidth) |
55 | 197 c->border = 1; |
29 | 198 gravitate(c, False); |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
199 resize(c, True, TopLeft); |
5 | 200 } |
201 | |
202 wc.x = ev->x; | |
203 wc.y = ev->y; | |
204 wc.width = ev->width; | |
205 wc.height = ev->height; | |
25 | 206 wc.border_width = 1; |
5 | 207 wc.sibling = None; |
208 wc.stack_mode = Above; | |
209 ev->value_mask &= ~CWStackMode; | |
210 ev->value_mask |= CWBorderWidth; | |
211 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
|
212 XSync(dpy, False); |
5 | 213 } |
214 | |
215 static void | |
216 destroynotify(XEvent *e) | |
217 { | |
218 Client *c; | |
219 XDestroyWindowEvent *ev = &e->xdestroywindow; | |
220 | |
11 | 221 if((c = getclient(ev->window))) |
222 unmanage(c); | |
5 | 223 } |
224 | |
225 static void | |
226 enternotify(XEvent *e) | |
227 { | |
228 XCrossingEvent *ev = &e->xcrossing; | |
229 Client *c; | |
230 | |
231 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) | |
232 return; | |
233 | |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
234 if((c = getclient(ev->window))) |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
235 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
|
236 else if(ev->window == root) |
31 | 237 issel = True; |
5 | 238 } |
239 | |
240 static void | |
241 expose(XEvent *e) | |
242 { | |
243 XExposeEvent *ev = &e->xexpose; | |
21
3ef108a5ca0a
implemented draw_client stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
20
diff
changeset
|
244 Client *c; |
5 | 245 |
246 if(ev->count == 0) { | |
70 | 247 if(barwin == ev->window) |
74 | 248 drawstatus(); |
75 | 249 else if((c = getctitle(ev->window))) |
74 | 250 drawtitle(c); |
5 | 251 } |
252 } | |
253 | |
254 static void | |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
255 keypress(XEvent *e) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
256 { |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
257 XKeyEvent *ev = &e->xkey; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
258 static unsigned int len = key ? sizeof(key) / sizeof(key[0]) : 0; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
259 unsigned int i; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
260 KeySym keysym; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
261 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
262 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
|
263 for(i = 0; i < len; i++) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
264 if((keysym == key[i].keysym) && (key[i].mod == ev->state)) { |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
265 if(key[i].func) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
266 key[i].func(&key[i].arg); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
267 return; |
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 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
271 static void |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
272 leavenotify(XEvent *e) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
273 { |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
274 XCrossingEvent *ev = &e->xcrossing; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
275 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
276 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
|
277 issel = True; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
278 } |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
279 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
280 static void |
5 | 281 maprequest(XEvent *e) |
282 { | |
283 XMapRequestEvent *ev = &e->xmaprequest; | |
284 static XWindowAttributes wa; | |
285 | |
286 if(!XGetWindowAttributes(dpy, ev->window, &wa)) | |
287 return; | |
288 | |
289 if(wa.override_redirect) { | |
290 XSelectInput(dpy, ev->window, | |
291 (StructureNotifyMask | PropertyChangeMask)); | |
292 return; | |
293 } | |
294 | |
10
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
295 if(!getclient(ev->window)) |
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
296 manage(ev->window, &wa); |
5 | 297 } |
298 | |
299 static void | |
300 propertynotify(XEvent *e) | |
301 { | |
302 XPropertyEvent *ev = &e->xproperty; | |
53 | 303 Window trans; |
5 | 304 Client *c; |
305 | |
306 if(ev->state == PropertyDelete) | |
307 return; /* ignore */ | |
308 | |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
309 if((c = getclient(ev->window))) { |
77 | 310 if(ev->atom == wmatom[WMProtocols]) { |
75 | 311 c->proto = getproto(c->win); |
30
2e0fb4130bfb
new stuff, fixed several issues
Anselm R. Garbe <garbeam@wmii.de>
parents:
29
diff
changeset
|
312 return; |
2e0fb4130bfb
new stuff, fixed several issues
Anselm R. Garbe <garbeam@wmii.de>
parents:
29
diff
changeset
|
313 } |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
314 switch (ev->atom) { |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
315 default: break; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
316 case XA_WM_TRANSIENT_FOR: |
53 | 317 XGetTransientForHint(dpy, c->win, &trans); |
80
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
318 if(!c->isfloat && (c->isfloat = (trans != 0))) |
53 | 319 arrange(NULL); |
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 case XA_WM_NORMAL_HINTS: |
74 | 322 setsize(c); |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
323 break; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
324 } |
77 | 325 if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { |
74 | 326 settitle(c); |
327 drawtitle(c); | |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
328 } |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
329 } |
5 | 330 } |
331 | |
332 static void | |
333 unmapnotify(XEvent *e) | |
334 { | |
335 Client *c; | |
336 XUnmapEvent *ev = &e->xunmap; | |
337 | |
10
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
338 if((c = getclient(ev->window))) |
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
339 unmanage(c); |
5 | 340 } |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
341 |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
342 /* extern */ |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
343 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
344 void (*handler[LASTEvent]) (XEvent *) = { |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
345 [ButtonPress] = buttonpress, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
346 [ConfigureRequest] = configurerequest, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
347 [DestroyNotify] = destroynotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
348 [EnterNotify] = enternotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
349 [LeaveNotify] = leavenotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
350 [Expose] = expose, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
351 [KeyPress] = keypress, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
352 [MapRequest] = maprequest, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
353 [PropertyNotify] = propertynotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
354 [UnmapNotify] = unmapnotify |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
355 }; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
356 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
357 void |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
358 grabkeys() |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
359 { |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
360 static unsigned int len = key ? sizeof(key) / sizeof(key[0]) : 0; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
361 unsigned int i; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
362 KeyCode code; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
363 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
364 for(i = 0; i < len; i++) { |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
365 code = XKeysymToKeycode(dpy, key[i].keysym); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
366 XUngrabKey(dpy, code, key[i].mod, root); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
367 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
|
368 GrabModeAsync, GrabModeAsync); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
369 } |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
370 } |