From 051a91a1739e19981a7169afef7d85af4de8e62f Mon Sep 17 00:00:00 2001 From: grodriguez Date: Fri, 31 Jan 2014 10:14:08 +0100 Subject: Fixes race condition XSelectInput must be called before XMapRaised. --- src/xlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xlib.c b/src/xlib.c index ebc3a4c..e46e358 100644 --- a/src/xlib.c +++ b/src/xlib.c @@ -184,8 +184,8 @@ void backend_init(){ backend_setaspect(1, 1); gc = XCreateGC(display, window, 0, NULL); - XMapRaised(display, window); XSelectInput(display, window, StructureNotifyMask | ExposureMask | KeyPressMask); + XMapRaised(display, window); XFlush(display); XSetIOErrorHandler(xquit); XFlush(display); -- cgit v1.2.3 From 0c55ec7edac2a4ffaba9eb617a5de2ca197b4bbe Mon Sep 17 00:00:00 2001 From: grodriguez Date: Fri, 31 Jan 2014 10:20:36 +0100 Subject: Fix for use without window manager Handle MapNotify event to make sure we have valid width and height in case we never get a ConfigureNotify event (for example when there's no window manager) --- src/xlib.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/xlib.c b/src/xlib.c index e46e358..07b50d6 100644 --- a/src/xlib.c +++ b/src/xlib.c @@ -226,6 +226,16 @@ void handlekeypress(XEvent *event){ void handleevent(XEvent *event){ switch(event->type){ + /* Might not get ConfigureNotify, for example if there's no window manager */ + case MapNotify: + if (!width || !height) + { + XWindowAttributes attr; + XGetWindowAttributes(event->xmap.display, event->xmap.window, &attr); + width = attr.width; + height = attr.height; + } + break; case ConfigureNotify: if(width != event->xconfigure.width || height != event->xconfigure.height){ width = event->xconfigure.width; -- cgit v1.2.3