From 9bd43db63a9bf890cb6ed170796c0dc7002aae8e Mon Sep 17 00:00:00 2001 From: "Enno Boland (tox)" Date: Tue, 8 Sep 2009 07:34:15 +0200 Subject: reparenting works. --- tabbed.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'tabbed.c') diff --git a/tabbed.c b/tabbed.c index 47f0215..836b5b7 100644 --- a/tabbed.c +++ b/tabbed.c @@ -83,6 +83,7 @@ static void run(void); static void setup(void); static int textnw(const char *text, unsigned int len); static void updatenumlockmask(void); +static int xerror(Display *dpy, XErrorEvent *ee); /* variables */ static int screen; @@ -261,8 +262,9 @@ spawntab(const Arg *arg) { } void -reparent(Window win) { - puts("reparent window"); +reparent(Window w) { + XSync(dpy, False); + XReparentWindow(dpy, w, win, 0, 0); } void @@ -361,6 +363,7 @@ setup(void) { ButtonPressMask|ExposureMask|KeyPressMask| LeaveWindowMask); XMapRaised(dpy, win); + XSetErrorHandler(xerror); } int @@ -394,6 +397,18 @@ updatenumlockmask(void) { XFreeModifiermap(modmap); } +/* There's no way to check accesses to destroyed windows, thus those cases are + * ignored (especially on UnmapNotify's). Other types of errors call Xlibs + * default error handler, which may call exit. */ +int +xerror(Display *dpy, XErrorEvent *ee) { + if(ee->error_code == BadWindow) + return 0; + die("dwm: fatal error: request code=%d, error code=%d\n", + ee->request_code, ee->error_code); + return 1; +} + int main(int argc, char *argv[]) { if(argc == 2 && !strcmp("-v", argv[1])) -- cgit v1.2.3