src/video/x11/SDL_x11window.c
changeset 6500 c532b3fdce27
parent 6488 7b2f712bdf1a
child 6501 2efafb933bd5
     1.1 --- a/src/video/x11/SDL_x11window.c	Fri Sep 28 04:09:06 2012 -0700
     1.2 +++ b/src/video/x11/SDL_x11window.c	Fri Sep 28 10:24:28 2012 -0700
     1.3 @@ -56,14 +56,6 @@
     1.4  {
     1.5      return ev->type == ConfigureNotify && ev->xconfigure.window == *((Window*)win);
     1.6  }
     1.7 -static Bool isFocusIn(Display *dpy, XEvent *ev, XPointer win)
     1.8 -{
     1.9 -    return ev->type == FocusIn && ev->xfocus.window == *((Window*)win);
    1.10 -}
    1.11 -static Bool isFocusOut(Display *dpy, XEvent *ev, XPointer win)
    1.12 -{
    1.13 -    return ev->type == FocusOut && ev->xfocus.window == *((Window*)win);
    1.14 -}
    1.15  
    1.16  static SDL_bool
    1.17  X11_IsWindowLegacyFullscreen(_THIS, SDL_Window * window)
    1.18 @@ -1019,10 +1011,12 @@
    1.19  
    1.20      XSelectInput(display, data->fswindow, StructureNotifyMask);
    1.21      XSetWindowBackground(display, data->fswindow, 0);
    1.22 +    XInstallColormap(display, data->colormap);
    1.23      XClearWindow(display, data->fswindow);
    1.24      XMapRaised(display, data->fswindow);
    1.25  
    1.26      /* Make sure the fswindow is in view by warping mouse to the corner */
    1.27 +    XUngrabPointer(display, CurrentTime);
    1.28      XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
    1.29  
    1.30      /* Wait to be mapped, filter Unmap event out if it arrives. */
    1.31 @@ -1034,7 +1028,6 @@
    1.32          XF86VidModeLockModeSwitch(display, screen, True);
    1.33      }
    1.34  #endif
    1.35 -    XInstallColormap(display, data->colormap);
    1.36  
    1.37      SetWindowBordered(display, displaydata->screen, data->xwindow, SDL_FALSE);
    1.38  
    1.39 @@ -1052,10 +1045,6 @@
    1.40      XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
    1.41      XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);
    1.42  
    1.43 -    /* Set the input focus because we're about to grab input */
    1.44 -    window->flags |= SDL_WINDOW_INPUT_FOCUS;
    1.45 -    SDL_SetKeyboardFocus(data->window);
    1.46 -
    1.47      X11_SetWindowGrab(_this, window);
    1.48  }
    1.49  
    1.50 @@ -1214,9 +1203,9 @@
    1.51      /* ICCCM2.0-compliant window managers can handle fullscreen windows */
    1.52      oldstyle_fullscreen = X11_IsWindowLegacyFullscreen(_this, window);
    1.53  
    1.54 -    if (((window->flags & SDL_WINDOW_INPUT_GRABBED) || oldstyle_fullscreen)
    1.55 -        && (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
    1.56 -        XEvent ev;
    1.57 +    if (oldstyle_fullscreen ||
    1.58 +        ((window->flags & SDL_WINDOW_INPUT_GRABBED) &&
    1.59 +         (window->flags & SDL_WINDOW_INPUT_FOCUS))) {
    1.60  
    1.61          /* Try to grab the mouse */
    1.62          for (;;) {
    1.63 @@ -1235,15 +1224,11 @@
    1.64          /* Now grab the keyboard */
    1.65          XGrabKeyboard(display, data->xwindow, True, GrabModeAsync,
    1.66                        GrabModeAsync, CurrentTime);
    1.67 -
    1.68 -        /* flush these events so they don't confuse normal event handling */
    1.69 -        XSync(display, False);
    1.70 -        XCheckIfEvent(display, &ev, &isFocusIn, (XPointer)&data->xwindow);
    1.71 -        XCheckIfEvent(display, &ev, &isFocusOut, (XPointer)&data->xwindow);
    1.72      } else {
    1.73          XUngrabPointer(display, CurrentTime);
    1.74          XUngrabKeyboard(display, CurrentTime);
    1.75      }
    1.76 +    XSync(display, False);
    1.77  }
    1.78  
    1.79  void