Skip to content
This repository has been archived by the owner. It is now read-only.
Browse files

Make the X11 SetBordered event tapdancing more robust, restore focus,…

… etc.
  • Loading branch information
icculus committed Sep 13, 2012
1 parent dc38242 commit 756088cf435a5f6683b8052cb10219256a78b1ae
Showing with 19 additions and 4 deletions.
  1. +1 −0 src/video/x11/SDL_x11sym.h
  2. +18 −4 src/video/x11/SDL_x11window.c
@@ -89,6 +89,7 @@ SDL_X11_SYM(int,XSelectInput,(Display* a,Window b,long c),(a,b,c),return)
SDL_X11_SYM(Status,XSendEvent,(Display* a,Window b,Bool c,long d,XEvent* e),(a,b,c,d,e),return)
SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return)
SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return)
SDL_X11_SYM(int,XSetInputFocus,(Display *a,Window b,int c,Time d),(a,b,c,d),return)
SDL_X11_SYM(int,XSetSelectionOwner,(Display* a,Atom b,Window c,Time d),(a,b,c,d),return)
SDL_X11_SYM(int,XSetTransientForHint,(Display* a,Window b,Window c),(a,b,c),return)
SDL_X11_SYM(void,XSetTextProperty,(Display* a,Window b,XTextProperty* c,Atom d),(a,b,c,d),)
@@ -734,20 +734,34 @@ static Bool isConfigureNotify(Display *dpy, XEvent *ev, XPointer win)
X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
const SDL_bool focused = ((window->flags & SDL_WINDOW_INPUT_FOCUS) != 0);
const SDL_bool visible = ((window->flags & SDL_WINDOW_HIDDEN) == 0);
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
SDL_DisplayData *displaydata =
(SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
Display *display = data->videodata->display;
XEvent event;

SetWindowBordered(display, displaydata->screen, data->xwindow, bordered);
XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow);

/* make sure these don't make it to the real event queue if they fired here. */
while (XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow)) {}
while (XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow)) {}
if (visible) {
XWindowAttributes attr;
do {
XSync(display, False);
XGetWindowAttributes(display, data->xwindow, &attr);
} while (attr.map_state != IsViewable);

if (focused) {
XSetInputFocus(display, data->xwindow, RevertToParent, CurrentTime);

/* make sure these don't make it to the real event queue if they fired here. */
XSync(display, False);
XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);


0 comments on commit 756088c

Please sign in to comment.