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