src/video/x11/SDL_x11window.c
changeset 6423 339c0ccf6250
parent 6422 fd0ac1b56115
child 6462 5e09ac1aba80
     1.1 --- a/src/video/x11/SDL_x11window.c	Thu Sep 13 01:43:53 2012 -0400
     1.2 +++ b/src/video/x11/SDL_x11window.c	Thu Sep 13 15:24:04 2012 -0400
     1.3 @@ -734,6 +734,8 @@
     1.4  void
     1.5  X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
     1.6  {
     1.7 +    const SDL_bool focused = ((window->flags & SDL_WINDOW_INPUT_FOCUS) != 0);
     1.8 +    const SDL_bool visible = ((window->flags & SDL_WINDOW_HIDDEN) == 0);
     1.9      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    1.10      SDL_DisplayData *displaydata =
    1.11          (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
    1.12 @@ -741,13 +743,25 @@
    1.13      XEvent event;
    1.14  
    1.15      SetWindowBordered(display, displaydata->screen, data->xwindow, bordered);
    1.16 +    XFlush(display);
    1.17      XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow);
    1.18  
    1.19 +    if (visible) {
    1.20 +        XWindowAttributes attr;
    1.21 +        do {
    1.22 +            XSync(display, False);
    1.23 +            XGetWindowAttributes(display, data->xwindow, &attr);
    1.24 +        } while (attr.map_state != IsViewable);
    1.25 +
    1.26 +        if (focused) {
    1.27 +            XSetInputFocus(display, data->xwindow, RevertToParent, CurrentTime);
    1.28 +        }
    1.29 +    }
    1.30 +
    1.31      /* make sure these don't make it to the real event queue if they fired here. */
    1.32 -    while (XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow)) {}
    1.33 -    while (XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow)) {}
    1.34 -
    1.35 -    XFlush(display);
    1.36 +    XSync(display, False);
    1.37 +    XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
    1.38 +    XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
    1.39  }
    1.40  
    1.41  void