summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-14 13:03:53 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-14 13:03:53 +0200
commita1d0f819661f2be48f7a03ddd001f2a1a8f325e4 (patch)
tree94fb44049473e55b93f1d5b6baedd561c4c83a50
parentfocus on view change as well (diff)
downloaddwm-a1d0f819661f2be48f7a03ddd001f2a1a8f325e4.tar.gz
dwm-a1d0f819661f2be48f7a03ddd001f2a1a8f325e4.zip
searching for a better way to discard enter notifies
-rw-r--r--client.c24
-rw-r--r--dwm.h6
-rw-r--r--event.c8
-rw-r--r--util.c28
4 files changed, 12 insertions, 54 deletions
diff --git a/client.c b/client.c
index 029a59c..2a981fc 100644
--- a/client.c
+++ b/client.c
@@ -28,17 +28,19 @@ next(Client *c)
28void 28void
29zoom(Arg *arg) 29zoom(Arg *arg)
30{ 30{
31 Client **l, *old; 31 Client **l;
32 32
33 if(!(old = sel)) 33 if(!sel)
34 return; 34 return;
35 35
36 if(sel == next(clients))
37 sel = next(sel->next);
38
36 for(l = &clients; *l && *l != sel; l = &(*l)->next); 39 for(l = &clients; *l && *l != sel; l = &(*l)->next);
37 *l = sel->next; 40 *l = sel->next;
38 41
39 old->next = clients; /* pop */ 42 sel->next = clients; /* pop */
40 clients = old; 43 clients = sel;
41 sel = old;
42 arrange(NULL); 44 arrange(NULL);
43 focus(sel); 45 focus(sel);
44} 46}
@@ -54,7 +56,6 @@ max(Arg *arg)
54 sel->h = sh - 2 * sel->border - bh; 56 sel->h = sh - 2 * sel->border - bh;
55 craise(sel); 57 craise(sel);
56 resize(sel, False); 58 resize(sel, False);
57 discard_events(EnterWindowMask);
58} 59}
59 60
60void 61void
@@ -65,9 +66,6 @@ view(Arg *arg)
65 tsel = arg->i; 66 tsel = arg->i;
66 arrange(NULL); 67 arrange(NULL);
67 68
68 if((c = next(clients)))
69 focus(c);
70
71 for(c = clients; c; c = next(c->next)) 69 for(c = clients; c; c = next(c->next))
72 draw_client(c); 70 draw_client(c);
73 draw_bar(); 71 draw_bar();
@@ -120,7 +118,6 @@ floating(Arg *arg)
120 focus(sel); 118 focus(sel);
121 } 119 }
122 } 120 }
123 discard_events(EnterWindowMask);
124} 121}
125 122
126void 123void
@@ -171,13 +168,12 @@ tiling(Arg *arg)
171 else 168 else
172 ban_client(c); 169 ban_client(c);
173 } 170 }
174 if(sel && !sel->tags[tsel]) { 171 if(!sel || (sel && !sel->tags[tsel])) {
175 if((sel = next(clients))) { 172 if((sel = next(clients))) {
176 craise(sel); 173 craise(sel);
177 focus(sel); 174 focus(sel);
178 } 175 }
179 } 176 }
180 discard_events(EnterWindowMask);
181} 177}
182 178
183void 179void
@@ -323,14 +319,16 @@ void
323focus(Client *c) 319focus(Client *c)
324{ 320{
325 Client *old = sel; 321 Client *old = sel;
322 XEvent ev;
326 323
324 XFlush(dpy);
327 sel = c; 325 sel = c;
328 if(old && old != c) 326 if(old && old != c)
329 draw_client(old); 327 draw_client(old);
330 draw_client(c); 328 draw_client(c);
331 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); 329 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
332 XFlush(dpy); 330 XFlush(dpy);
333 discard_events(EnterWindowMask); 331 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
334} 332}
335 333
336static void 334static void
diff --git a/dwm.h b/dwm.h
index 29aa6a2..113e861 100644
--- a/dwm.h
+++ b/dwm.h
@@ -137,9 +137,6 @@ extern unsigned int textnw(char *text, unsigned int len);
137extern unsigned int textw(char *text); 137extern unsigned int textw(char *text);
138extern unsigned int texth(void); 138extern unsigned int texth(void);
139 139
140/* event.c */
141extern void discard_events(long even_mask);
142
143/* dev.c */ 140/* dev.c */
144extern void update_keys(void); 141extern void update_keys(void);
145extern void keypress(XEvent *e); 142extern void keypress(XEvent *e);
@@ -155,8 +152,5 @@ extern void quit(Arg *arg);
155/* util.c */ 152/* util.c */
156extern void error(const char *errstr, ...); 153extern void error(const char *errstr, ...);
157extern void *emallocz(unsigned int size); 154extern void *emallocz(unsigned int size);
158extern void *emalloc(unsigned int size);
159extern void *erealloc(void *ptr, unsigned int size);
160extern char *estrdup(const char *str);
161extern void spawn(Arg *arg); 155extern void spawn(Arg *arg);
162extern void swap(void **p1, void **p2); 156extern void swap(void **p1, void **p2);
diff --git a/event.c b/event.c
index 4edf139..b027a3e 100644
--- a/event.c
+++ b/event.c
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#include <fcntl.h> 6#include <fcntl.h>
7#include <stdio.h>
7#include <stdlib.h> 8#include <stdlib.h>
8#include <string.h> 9#include <string.h>
9#include <X11/keysym.h> 10#include <X11/keysym.h>
@@ -37,13 +38,6 @@ void (*handler[LASTEvent]) (XEvent *) = {
37 [UnmapNotify] = unmapnotify 38 [UnmapNotify] = unmapnotify
38}; 39};
39 40
40void
41discard_events(long even_mask)
42{
43 XEvent ev;
44 while(XCheckMaskEvent(dpy, even_mask, &ev));
45}
46
47static void 41static void
48buttonpress(XEvent *e) 42buttonpress(XEvent *e)
49{ 43{
diff --git a/util.c b/util.c
index d8e6612..e95dfc5 100644
--- a/util.c
+++ b/util.c
@@ -6,7 +6,6 @@
6#include <stdarg.h> 6#include <stdarg.h>
7#include <stdio.h> 7#include <stdio.h>
8#include <stdlib.h> 8#include <stdlib.h>
9#include <string.h>
10#include <sys/types.h> 9#include <sys/types.h>
11#include <sys/wait.h> 10#include <sys/wait.h>
12#include <unistd.h> 11#include <unistd.h>
@@ -39,33 +38,6 @@ emallocz(unsigned int size)
39 return res; 38 return res;
40} 39}
41 40
42void *
43emalloc(unsigned int size)
44{
45 void *res = malloc(size);
46 if(!res)
47 bad_malloc(size);
48 return res;
49}
50
51void *
52erealloc(void *ptr, unsigned int size)
53{
54 void *res = realloc(ptr, size);
55 if(!res)
56 bad_malloc(size);
57 return res;
58}
59
60char *
61estrdup(const char *str)
62{
63 char *res = strdup(str);
64 if(!res)
65 bad_malloc(strlen(str));
66 return res;
67}
68
69void 41void
70swap(void **p1, void **p2) 42swap(void **p1, void **p2)
71{ 43{