Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
A few more tweaks for the legacy fullscreen support
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Sep 28, 2012
1 parent 3b5c59e commit db98e26
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions src/video/x11/SDL_x11window.c
Expand Up @@ -56,14 +56,6 @@ static Bool isConfigureNotify(Display *dpy, XEvent *ev, XPointer win)
{
return ev->type == ConfigureNotify && ev->xconfigure.window == *((Window*)win);
}
static Bool isFocusIn(Display *dpy, XEvent *ev, XPointer win)
{
return ev->type == FocusIn && ev->xfocus.window == *((Window*)win);
}
static Bool isFocusOut(Display *dpy, XEvent *ev, XPointer win)
{
return ev->type == FocusOut && ev->xfocus.window == *((Window*)win);
}

static SDL_bool
X11_IsWindowLegacyFullscreen(_THIS, SDL_Window * window)
Expand Down Expand Up @@ -1019,10 +1011,12 @@ X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _

XSelectInput(display, data->fswindow, StructureNotifyMask);
XSetWindowBackground(display, data->fswindow, 0);
XInstallColormap(display, data->colormap);
XClearWindow(display, data->fswindow);
XMapRaised(display, data->fswindow);

/* Make sure the fswindow is in view by warping mouse to the corner */
XUngrabPointer(display, CurrentTime);
XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);

/* Wait to be mapped, filter Unmap event out if it arrives. */
Expand All @@ -1034,7 +1028,6 @@ X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _
XF86VidModeLockModeSwitch(display, screen, True);
}
#endif
XInstallColormap(display, data->colormap);

SetWindowBordered(display, displaydata->screen, data->xwindow, SDL_FALSE);

Expand All @@ -1052,10 +1045,6 @@ X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _
XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);

/* Set the input focus because we're about to grab input */
window->flags |= SDL_WINDOW_INPUT_FOCUS;
SDL_SetKeyboardFocus(data->window);

X11_SetWindowGrab(_this, window);
}

Expand Down Expand Up @@ -1214,9 +1203,9 @@ X11_SetWindowGrab(_THIS, SDL_Window * window)
/* ICCCM2.0-compliant window managers can handle fullscreen windows */
oldstyle_fullscreen = X11_IsWindowLegacyFullscreen(_this, window);

if (((window->flags & SDL_WINDOW_INPUT_GRABBED) || oldstyle_fullscreen)
&& (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
XEvent ev;
if (oldstyle_fullscreen ||
((window->flags & SDL_WINDOW_INPUT_GRABBED) &&
(window->flags & SDL_WINDOW_INPUT_FOCUS))) {

/* Try to grab the mouse */
for (;;) {
Expand All @@ -1235,15 +1224,11 @@ X11_SetWindowGrab(_THIS, SDL_Window * window)
/* Now grab the keyboard */
XGrabKeyboard(display, data->xwindow, True, GrabModeAsync,
GrabModeAsync, CurrentTime);

/* flush these events so they don't confuse normal event handling */
XSync(display, False);
XCheckIfEvent(display, &ev, &isFocusIn, (XPointer)&data->xwindow);
XCheckIfEvent(display, &ev, &isFocusOut, (XPointer)&data->xwindow);
} else {
XUngrabPointer(display, CurrentTime);
XUngrabKeyboard(display, CurrentTime);
}
XSync(display, False);
}

void
Expand Down

0 comments on commit db98e26

Please sign in to comment.