searching for a better way to discard enter notifies a1d0f819
Anselm R. Garbe · 2006-07-14 13:03 4 file(s) · +12 −54
client.c +11 −13
28 28
void
29 29
zoom(Arg *arg)
30 30
{
31 -
	Client **l, *old;
31 +
	Client **l;
32 32
33 -
	if(!(old = sel))
33 +
	if(!sel)
34 34
		return;
35 35
36 +
	if(sel == next(clients)) 
37 +
		sel = next(sel->next);
38 +
36 39
	for(l = &clients; *l && *l != sel; l = &(*l)->next);
37 40
	*l = sel->next;
38 41
39 -
	old->next = clients; /* pop */
40 -
	clients = old;
41 -
	sel = old;
42 +
	sel->next = clients; /* pop */
43 +
	clients = sel;
42 44
	arrange(NULL);
43 45
	focus(sel);
44 46
}
54 56
	sel->h = sh - 2 * sel->border - bh;
55 57
	craise(sel);
56 58
	resize(sel, False);
57 -
	discard_events(EnterWindowMask);
58 59
}
59 60
60 61
void
64 65
65 66
	tsel = arg->i;
66 67
	arrange(NULL);
67 -
68 -
	if((c = next(clients)))
69 -
		focus(c);
70 68
71 69
	for(c = clients; c; c = next(c->next))
72 70
		draw_client(c);
120 118
			focus(sel);
121 119
		}
122 120
	}
123 -
	discard_events(EnterWindowMask);
124 121
}
125 122
126 123
void
171 168
		else
172 169
			ban_client(c);
173 170
	}
174 -
	if(sel && !sel->tags[tsel]) {
171 +
	if(!sel || (sel && !sel->tags[tsel])) {
175 172
		if((sel = next(clients))) {
176 173
			craise(sel);
177 174
			focus(sel);
178 175
		}
179 176
	}
180 -
	discard_events(EnterWindowMask);
181 177
}
182 178
183 179
void
323 319
focus(Client *c)
324 320
{
325 321
	Client *old = sel;
322 +
	XEvent ev;
326 323
324 +
	XFlush(dpy);
327 325
	sel = c;
328 326
	if(old && old != c)
329 327
		draw_client(old);
330 328
	draw_client(c);
331 329
	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
332 330
	XFlush(dpy);
333 -
	discard_events(EnterWindowMask);
331 +
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
334 332
}
335 333
336 334
static void
dwm.h +0 −6
137 137
extern unsigned int textw(char *text);
138 138
extern unsigned int texth(void);
139 139
140 -
/* event.c */
141 -
extern void discard_events(long even_mask);
142 -
143 140
/* dev.c */
144 141
extern void update_keys(void);
145 142
extern void keypress(XEvent *e);
155 152
/* util.c */
156 153
extern void error(const char *errstr, ...);
157 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 155
extern void spawn(Arg *arg);
162 156
extern void swap(void **p1, void **p2);
event.c +1 −7
4 4
 */
5 5
6 6
#include <fcntl.h>
7 +
#include <stdio.h>
7 8
#include <stdlib.h>
8 9
#include <string.h>
9 10
#include <X11/keysym.h>
36 37
	[PropertyNotify] = propertynotify,
37 38
	[UnmapNotify] = unmapnotify
38 39
};
39 -
40 -
void
41 -
discard_events(long even_mask)
42 -
{
43 -
	XEvent ev;
44 -
	while(XCheckMaskEvent(dpy, even_mask, &ev));
45 -
}
46 40
47 41
static void
48 42
buttonpress(XEvent *e)
util.c +0 −28
6 6
#include <stdarg.h>
7 7
#include <stdio.h>
8 8
#include <stdlib.h>
9 -
#include <string.h>
10 9
#include <sys/types.h>
11 10
#include <sys/wait.h>
12 11
#include <unistd.h>
36 35
	void *res = calloc(1, size);
37 36
	if(!res)
38 37
		bad_malloc(size);
39 -
	return res;
40 -
}
41 -
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 38
	return res;
67 39
}
68 40