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