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

Commit

Permalink
Date: Mon, 29 Dec 2008 23:29:52 +0100
Browse files Browse the repository at this point in the history
From: Couriersud
Subject: SDL1.3: Some X11 diffs

The attached diff fixes the following issues in the X11 backend:

a) When calling resize, actually a move was performed. This has been
corrected.

b) DisplayHeight and DisplayWidth do not return up-to-date information
after a modeswitch using the xrandr code, which I enabled in
x11_modes.c
Height and width are now queried from the root window and all
occurrences of DisplayHeight and DisplayWidth changed.
  • Loading branch information
slouken committed Dec 30, 2008
1 parent 7c8ad93 commit ecc2fac
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions src/video/x11/SDL_x11window.c
Expand Up @@ -28,6 +28,25 @@
#include "SDL_x11video.h"
#include "../Xext/extensions/StdCmap.h"

static void
X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_DisplayData *displaydata =
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
XWindowAttributes attr;

XGetWindowAttributes(data->display, RootWindow(data->display,
displaydata->screen),
&attr);
if (w) {
*w = attr.width;
}
if (h) {
*h = attr.height;
}
}

static int
SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
{
Expand Down Expand Up @@ -289,17 +308,17 @@ X11_CreateWindow(_THIS, SDL_Window * window)

if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->x == SDL_WINDOWPOS_CENTERED) {
x = (DisplayWidth(data->display, displaydata->screen) -
window->w) / 2;
X11_GetDisplaySize(_this, window, &x, NULL);
x = (x - window->w) / 2;
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
x = 0;
} else {
x = window->x;
}
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->y == SDL_WINDOWPOS_CENTERED) {
y = (DisplayHeight(data->display, displaydata->screen) -
window->h) / 2;
X11_GetDisplaySize(_this, window, NULL, &y);
y = (y - window->h) / 2;
} else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
y = 0;
} else {
Expand Down Expand Up @@ -608,13 +627,15 @@ X11_SetWindowPosition(_THIS, SDL_Window * window)

if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->x == SDL_WINDOWPOS_CENTERED) {
x = (DisplayWidth(display, displaydata->screen) - window->w) / 2;
X11_GetDisplaySize(_this, window, &x, NULL);
x = (x - window->w) / 2;
} else {
x = window->x;
}
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->y == SDL_WINDOWPOS_CENTERED) {
y = (DisplayHeight(display, displaydata->screen) - window->h) / 2;
X11_GetDisplaySize(_this, window, NULL, &y);
y = (y - window->h) / 2;
} else {
y = window->y;
}
Expand All @@ -627,7 +648,7 @@ X11_SetWindowSize(_THIS, SDL_Window * window)
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
Display *display = data->videodata->display;

XMoveWindow(display, data->window, window->w, window->h);
XResizeWindow(display, data->window, window->w, window->h);
}

void
Expand Down

0 comments on commit ecc2fac

Please sign in to comment.