diff options
| author | Anselm R. Garbe <garbeam@wmii.de> | 2006-07-14 13:03:53 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <garbeam@wmii.de> | 2006-07-14 13:03:53 +0200 |
| commit | a1d0f819661f2be48f7a03ddd001f2a1a8f325e4 (patch) | |
| tree | 94fb44049473e55b93f1d5b6baedd561c4c83a50 | |
| parent | focus on view change as well (diff) | |
| download | dwm-a1d0f819661f2be48f7a03ddd001f2a1a8f325e4.tar.gz dwm-a1d0f819661f2be48f7a03ddd001f2a1a8f325e4.zip | |
searching for a better way to discard enter notifies
| -rw-r--r-- | client.c | 24 | ||||
| -rw-r--r-- | dwm.h | 6 | ||||
| -rw-r--r-- | event.c | 8 | ||||
| -rw-r--r-- | util.c | 28 |
4 files changed, 12 insertions, 54 deletions
| @@ -28,17 +28,19 @@ next(Client *c) | |||
| 28 | void | 28 | void |
| 29 | zoom(Arg *arg) | 29 | zoom(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 | ||
| 60 | void | 61 | void |
| @@ -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 | ||
| 126 | void | 123 | void |
| @@ -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 | ||
| 183 | void | 179 | void |
| @@ -323,14 +319,16 @@ void | |||
| 323 | focus(Client *c) | 319 | focus(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 | ||
| 336 | static void | 334 | static void |
| @@ -137,9 +137,6 @@ extern unsigned int textnw(char *text, unsigned int len); | |||
| 137 | extern unsigned int textw(char *text); | 137 | extern unsigned int textw(char *text); |
| 138 | extern unsigned int texth(void); | 138 | extern unsigned int texth(void); |
| 139 | 139 | ||
| 140 | /* event.c */ | ||
| 141 | extern void discard_events(long even_mask); | ||
| 142 | |||
| 143 | /* dev.c */ | 140 | /* dev.c */ |
| 144 | extern void update_keys(void); | 141 | extern void update_keys(void); |
| 145 | extern void keypress(XEvent *e); | 142 | extern void keypress(XEvent *e); |
| @@ -155,8 +152,5 @@ extern void quit(Arg *arg); | |||
| 155 | /* util.c */ | 152 | /* util.c */ |
| 156 | extern void error(const char *errstr, ...); | 153 | extern void error(const char *errstr, ...); |
| 157 | extern void *emallocz(unsigned int size); | 154 | extern void *emallocz(unsigned int size); |
| 158 | extern void *emalloc(unsigned int size); | ||
| 159 | extern void *erealloc(void *ptr, unsigned int size); | ||
| 160 | extern char *estrdup(const char *str); | ||
| 161 | extern void spawn(Arg *arg); | 155 | extern void spawn(Arg *arg); |
| 162 | extern void swap(void **p1, void **p2); | 156 | extern void swap(void **p1, void **p2); |
| @@ -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 | ||
| 40 | void | ||
| 41 | discard_events(long even_mask) | ||
| 42 | { | ||
| 43 | XEvent ev; | ||
| 44 | while(XCheckMaskEvent(dpy, even_mask, &ev)); | ||
| 45 | } | ||
| 46 | |||
| 47 | static void | 41 | static void |
| 48 | buttonpress(XEvent *e) | 42 | buttonpress(XEvent *e) |
| 49 | { | 43 | { |
| @@ -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 | ||
| 42 | void * | ||
| 43 | emalloc(unsigned int size) | ||
| 44 | { | ||
| 45 | void *res = malloc(size); | ||
| 46 | if(!res) | ||
| 47 | bad_malloc(size); | ||
| 48 | return res; | ||
| 49 | } | ||
| 50 | |||
| 51 | void * | ||
| 52 | erealloc(void *ptr, unsigned int size) | ||
| 53 | { | ||
| 54 | void *res = realloc(ptr, size); | ||
| 55 | if(!res) | ||
| 56 | bad_malloc(size); | ||
| 57 | return res; | ||
| 58 | } | ||
| 59 | |||
| 60 | char * | ||
| 61 | estrdup(const char *str) | ||
| 62 | { | ||
| 63 | char *res = strdup(str); | ||
| 64 | if(!res) | ||
| 65 | bad_malloc(strlen(str)); | ||
| 66 | return res; | ||
| 67 | } | ||
| 68 | |||
| 69 | void | 41 | void |
| 70 | swap(void **p1, void **p2) | 42 | swap(void **p1, void **p2) |
| 71 | { | 43 | { |
