src/video/x11/SDL_x11window.c
changeset 6423 339c0ccf6250
parent 6422 fd0ac1b56115
child 6462 5e09ac1aba80
equal deleted inserted replaced
6422:fd0ac1b56115 6423:339c0ccf6250
   732 }
   732 }
   733 
   733 
   734 void
   734 void
   735 X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
   735 X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
   736 {
   736 {
       
   737     const SDL_bool focused = ((window->flags & SDL_WINDOW_INPUT_FOCUS) != 0);
       
   738     const SDL_bool visible = ((window->flags & SDL_WINDOW_HIDDEN) == 0);
   737     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   739     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   738     SDL_DisplayData *displaydata =
   740     SDL_DisplayData *displaydata =
   739         (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
   741         (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
   740     Display *display = data->videodata->display;
   742     Display *display = data->videodata->display;
   741     XEvent event;
   743     XEvent event;
   742 
   744 
   743     SetWindowBordered(display, displaydata->screen, data->xwindow, bordered);
   745     SetWindowBordered(display, displaydata->screen, data->xwindow, bordered);
       
   746     XFlush(display);
   744     XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow);
   747     XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow);
   745 
   748 
       
   749     if (visible) {
       
   750         XWindowAttributes attr;
       
   751         do {
       
   752             XSync(display, False);
       
   753             XGetWindowAttributes(display, data->xwindow, &attr);
       
   754         } while (attr.map_state != IsViewable);
       
   755 
       
   756         if (focused) {
       
   757             XSetInputFocus(display, data->xwindow, RevertToParent, CurrentTime);
       
   758         }
       
   759     }
       
   760 
   746     /* make sure these don't make it to the real event queue if they fired here. */
   761     /* make sure these don't make it to the real event queue if they fired here. */
   747     while (XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow)) {}
   762     XSync(display, False);
   748     while (XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow)) {}
   763     XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
   749 
   764     XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
   750     XFlush(display);
       
   751 }
   765 }
   752 
   766 
   753 void
   767 void
   754 X11_ShowWindow(_THIS, SDL_Window * window)
   768 X11_ShowWindow(_THIS, SDL_Window * window)
   755 {
   769 {