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

Commit

Permalink
Fixed fullscreen origin for multi-head displays
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Sep 27, 2012
1 parent 3598a87 commit a7243d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
16 changes: 6 additions & 10 deletions src/video/x11/SDL_x11modes.c
Expand Up @@ -151,9 +151,8 @@ X11_InitModes(_THIS)
*/
if (CheckXinerama(data->display, &xinerama_major, &xinerama_minor)) {
xinerama = XineramaQueryScreens(data->display, &screencount);
if (!xinerama) screencount = ScreenCount(data->display);
}
else {
if (!xinerama) {
screencount = ScreenCount(data->display);
}
#else
Expand Down Expand Up @@ -807,14 +806,11 @@ X11_GetDisplayBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect)
return 0;
}
#endif
if (_this->windows) {
rect->x = 0;
rect->y = 0;
rect->w = _this->windows->w;
rect->h = _this->windows->h;
return 0;
}
return -1;
rect->x = 0;
rect->y = 0;
rect->w = sdl_display->current_mode.w;
rect->h = sdl_display->current_mode.h;
return 0;
}

#endif /* SDL_VIDEO_DRIVER_X11 */
Expand Down
20 changes: 11 additions & 9 deletions src/video/x11/SDL_x11window.c
Expand Up @@ -996,13 +996,14 @@ X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _
unsigned long xattrmask = 0;
XSetWindowAttributes xattr;
XEvent ev;
int x = 0;
int y = 0;
SDL_Rect rect;

if ( data->fswindow ) {
return; /* already fullscreen, I hope. */
}

X11_GetDisplayBounds(_this, _display, &rect);

/* Ungrab the input so that we can move the mouse around */
XUngrabPointer(display, CurrentTime);

Expand All @@ -1020,7 +1021,8 @@ X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _
xattr.colormap = data->colormap;
xattrmask |= CWColormap;

data->fswindow = XCreateWindow(display, root, x, y, w, h, 0,
data->fswindow = XCreateWindow(display, root,
rect.x, rect.y, rect.w, rect.h, 0,
displaydata->depth, InputOutput,
visual, xattrmask, &xattr);

Expand Down Expand Up @@ -1048,19 +1050,19 @@ X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _
//XIfEvent(display, &ev, &isConfigureNotify, (XPointer)&data->xwindow);

/* Center actual window within our cover-the-screen window. */
x += (w - window->w) / 2;
y += (h - window->h) / 2;
XReparentWindow(display, data->xwindow, data->fswindow, x, y);
rect.x += (rect.w - window->w) / 2;
rect.y += (rect.h - window->h) / 2;
XReparentWindow(display, data->xwindow, data->fswindow, rect.x, rect.y);
XRaiseWindow(display, data->xwindow);

/* Make sure the fswindow is in view by warping mouse to the corner */
XWarpPointer(display, None, root, 0, 0, 0, 0, 0, 0);
XFlush(display);

/* Center mouse in the window. */
x += (window->w / 2);
y += (window->h / 2);
XWarpPointer(display, None, root, 0, 0, 0, 0, x, y);
rect.x += (window->w / 2);
rect.y += (window->h / 2);
XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);

/* Wait to be mapped, filter Unmap event out if it arrives. */
XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
Expand Down

0 comments on commit a7243d9

Please sign in to comment.