Mercurial > aewl
annotate event.c @ 122:f20cea484900
Added tag 0.4 for changeset eb3165734f00fe7f7da8aeebaed00e60a57caac9
author | arg@10ksloc.org |
---|---|
date | Thu, 20 Jul 2006 10:48:22 +0200 |
parents | eb3165734f00 |
children | 61490330e90a |
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 | |
121 | 23 /* |
111 | 24 const char *browse[] = { "firefox", NULL }; |
25 const char *gimp[] = { "gimp", NULL }; | |
121 | 26 */ |
27 const char *term[] = { "xterm", NULL }; | |
28 /* | |
111 | 29 "urxvtc", "-tr", "+sb", "-bg", "black", "-fg", "white", "-cr", "white", |
30 "-fn", "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", NULL | |
31 }; | |
121 | 32 coonst char *xlock[] = { "xlock", NULL }; |
33 */ | |
75 | 34 |
114 | 35 static Key key[] = { |
75 | 36 /* modifier key function arguments */ |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
37 { 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
|
38 { 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
|
39 { 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
|
40 { ControlMask, XK_3, appendtag, { .i = Twork } }, |
113
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
41 { MODKEY, XK_0, view, { .i = Tscratch } }, |
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
42 { MODKEY, XK_1, view, { .i = Tdev } }, |
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
43 { MODKEY, XK_2, view, { .i = Twww } }, |
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
44 { MODKEY, XK_3, view, { .i = Twork } }, |
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
45 { MODKEY, XK_j, focusnext, { 0 } }, |
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
46 { MODKEY, XK_k, focusprev, { 0 } }, |
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
47 { MODKEY, XK_m, maximize, { 0 } }, |
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
48 { MODKEY, XK_space, dotile, { 0 } }, |
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
49 { MODKEY, 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
|
50 { 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
|
51 { 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
|
52 { 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
|
53 { ControlMask|ShiftMask,XK_3, heretag, { .i = Twork } }, |
113
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
54 { MODKEY|ShiftMask, XK_0, replacetag, { .i = Tscratch } }, |
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
55 { MODKEY|ShiftMask, XK_1, replacetag, { .i = Tdev } }, |
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
56 { MODKEY|ShiftMask, XK_2, replacetag, { .i = Twww } }, |
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
57 { MODKEY|ShiftMask, XK_3, replacetag, { .i = Twork } }, |
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
58 { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, |
121 | 59 /* |
113
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
60 { MODKEY|ShiftMask, XK_g, spawn, { .argv = gimp } }, |
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
61 { MODKEY|ShiftMask, XK_l, spawn, { .argv = xlock } }, |
121 | 62 */ |
113
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
63 { MODKEY|ShiftMask, XK_q, quit, { 0 } }, |
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
64 { MODKEY|ShiftMask, XK_space, dofloat, { 0 } }, |
121 | 65 /*{ MODKEY|ShiftMask, XK_w, spawn, { .argv = browse } },*/ |
113
b2445fd41f5e
applied Jukka's patch with s/ModKeyMask/MODKEY/g
arg@10ksloc.org
parents:
111
diff
changeset
|
66 { MODKEY|ShiftMask, XK_Return, spawn, { .argv = term } }, |
75 | 67 }; |
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 XEvent ev; | |
75 int x1, y1, ocx, ocy, di; | |
76 unsigned int dui; | |
77 Window dummy; | |
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, |
82 None, cursor[CurMove], CurrentTime) != GrabSuccess) | |
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 XEvent ev; | |
109 int ocx, ocy; | |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
110 Corner sticky; |
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; | |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
149 XButtonPressedEvent *ev = &e->xbutton; |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
150 Client *c; |
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: |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
179 if(arrange == dotile && !c->isfloat) { |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
180 if((ev->state & ControlMask) && (ev->button == Button1)) |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
181 zoom(NULL); |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
182 } |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
183 else { |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
184 higher(c); |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
185 movemouse(c); |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
186 } |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
187 break; |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
188 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
|
189 lower(c); |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
190 break; |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
191 case Button3: |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
192 if(arrange == dofloat || c->isfloat) { |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
193 higher(c); |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
194 resizemouse(c); |
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
195 } |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
196 break; |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
197 } |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
198 } |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
199 } |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
200 |
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
201 static void |
5 | 202 configurerequest(XEvent *e) |
203 { | |
204 XConfigureRequestEvent *ev = &e->xconfigurerequest; | |
205 XWindowChanges wc; | |
206 Client *c; | |
207 | |
208 ev->value_mask &= ~CWSibling; | |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
209 if((c = getclient(ev->window))) { |
29 | 210 gravitate(c, True); |
5 | 211 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
|
212 c->x = ev->x; |
5 | 213 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
|
214 c->y = ev->y; |
5 | 215 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
|
216 c->w = ev->width; |
5 | 217 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
|
218 c->h = ev->height; |
29 | 219 if(ev->value_mask & CWBorderWidth) |
55 | 220 c->border = 1; |
29 | 221 gravitate(c, False); |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
222 resize(c, True, TopLeft); |
5 | 223 } |
224 | |
225 wc.x = ev->x; | |
226 wc.y = ev->y; | |
227 wc.width = ev->width; | |
228 wc.height = ev->height; | |
25 | 229 wc.border_width = 1; |
5 | 230 wc.sibling = None; |
231 wc.stack_mode = Above; | |
232 ev->value_mask &= ~CWStackMode; | |
233 ev->value_mask |= CWBorderWidth; | |
234 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
|
235 XSync(dpy, False); |
5 | 236 } |
237 | |
238 static void | |
239 destroynotify(XEvent *e) | |
240 { | |
241 Client *c; | |
242 XDestroyWindowEvent *ev = &e->xdestroywindow; | |
243 | |
11 | 244 if((c = getclient(ev->window))) |
245 unmanage(c); | |
5 | 246 } |
247 | |
248 static void | |
249 enternotify(XEvent *e) | |
250 { | |
251 XCrossingEvent *ev = &e->xcrossing; | |
252 Client *c; | |
253 | |
254 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) | |
255 return; | |
256 | |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
257 if((c = getclient(ev->window))) |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
258 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
|
259 else if(ev->window == root) |
31 | 260 issel = True; |
5 | 261 } |
262 | |
263 static void | |
264 expose(XEvent *e) | |
265 { | |
266 XExposeEvent *ev = &e->xexpose; | |
21
3ef108a5ca0a
implemented draw_client stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
20
diff
changeset
|
267 Client *c; |
5 | 268 |
269 if(ev->count == 0) { | |
70 | 270 if(barwin == ev->window) |
74 | 271 drawstatus(); |
75 | 272 else if((c = getctitle(ev->window))) |
74 | 273 drawtitle(c); |
5 | 274 } |
275 } | |
276 | |
277 static void | |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
278 keypress(XEvent *e) |
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 XKeyEvent *ev = &e->xkey; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
281 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
|
282 unsigned int i; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
283 KeySym keysym; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
284 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
285 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
|
286 for(i = 0; i < len; i++) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
287 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
|
288 if(key[i].func) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
289 key[i].func(&key[i].arg); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
290 return; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
291 } |
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 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
294 static void |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
295 leavenotify(XEvent *e) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
296 { |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
297 XCrossingEvent *ev = &e->xcrossing; |
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 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
|
300 issel = True; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
301 } |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
302 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
303 static void |
5 | 304 maprequest(XEvent *e) |
305 { | |
306 XMapRequestEvent *ev = &e->xmaprequest; | |
307 static XWindowAttributes wa; | |
308 | |
309 if(!XGetWindowAttributes(dpy, ev->window, &wa)) | |
310 return; | |
311 | |
312 if(wa.override_redirect) { | |
313 XSelectInput(dpy, ev->window, | |
314 (StructureNotifyMask | PropertyChangeMask)); | |
315 return; | |
316 } | |
317 | |
10
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
318 if(!getclient(ev->window)) |
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
319 manage(ev->window, &wa); |
5 | 320 } |
321 | |
322 static void | |
323 propertynotify(XEvent *e) | |
324 { | |
325 XPropertyEvent *ev = &e->xproperty; | |
53 | 326 Window trans; |
5 | 327 Client *c; |
328 | |
329 if(ev->state == PropertyDelete) | |
330 return; /* ignore */ | |
331 | |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
332 if((c = getclient(ev->window))) { |
77 | 333 if(ev->atom == wmatom[WMProtocols]) { |
75 | 334 c->proto = getproto(c->win); |
30
2e0fb4130bfb
new stuff, fixed several issues
Anselm R. Garbe <garbeam@wmii.de>
parents:
29
diff
changeset
|
335 return; |
2e0fb4130bfb
new stuff, fixed several issues
Anselm R. Garbe <garbeam@wmii.de>
parents:
29
diff
changeset
|
336 } |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
337 switch (ev->atom) { |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
338 default: break; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
339 case XA_WM_TRANSIENT_FOR: |
53 | 340 XGetTransientForHint(dpy, c->win, &trans); |
80
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
79
diff
changeset
|
341 if(!c->isfloat && (c->isfloat = (trans != 0))) |
53 | 342 arrange(NULL); |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
343 break; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
344 case XA_WM_NORMAL_HINTS: |
74 | 345 setsize(c); |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
346 break; |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
347 } |
77 | 348 if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { |
74 | 349 settitle(c); |
350 drawtitle(c); | |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
351 } |
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
11
diff
changeset
|
352 } |
5 | 353 } |
354 | |
355 static void | |
356 unmapnotify(XEvent *e) | |
357 { | |
358 Client *c; | |
359 XUnmapEvent *ev = &e->xunmap; | |
360 | |
10
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
361 if((c = getclient(ev->window))) |
703255003abb
changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents:
9
diff
changeset
|
362 unmanage(c); |
5 | 363 } |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
364 |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
365 /* extern */ |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
366 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
367 void (*handler[LASTEvent]) (XEvent *) = { |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
368 [ButtonPress] = buttonpress, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
369 [ConfigureRequest] = configurerequest, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
370 [DestroyNotify] = destroynotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
371 [EnterNotify] = enternotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
372 [LeaveNotify] = leavenotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
373 [Expose] = expose, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
374 [KeyPress] = keypress, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
375 [MapRequest] = maprequest, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
376 [PropertyNotify] = propertynotify, |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
377 [UnmapNotify] = unmapnotify |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
378 }; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
379 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
380 void |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
381 grabkeys() |
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 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
|
384 unsigned int i; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
385 KeyCode code; |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
386 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
387 for(i = 0; i < len; i++) { |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
388 code = XKeysymToKeycode(dpy, key[i].keysym); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
389 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
|
390 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
|
391 GrabModeAsync, GrabModeAsync); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
392 } |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
393 } |