comparison src/video/x11/SDL_x11window.c @ 2931:e705adf6f3dc

Date: Mon, 29 Dec 2008 23:29:52 +0100 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.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 30 Dec 2008 17:09:42 +0000
parents 3fcb0d447bcd
children b93965a16fe0
comparison
equal deleted inserted replaced
2930:8acbb14124c5 2931:e705adf6f3dc
25 #include "../SDL_sysvideo.h" 25 #include "../SDL_sysvideo.h"
26 #include "../../events/SDL_keyboard_c.h" 26 #include "../../events/SDL_keyboard_c.h"
27 27
28 #include "SDL_x11video.h" 28 #include "SDL_x11video.h"
29 #include "../Xext/extensions/StdCmap.h" 29 #include "../Xext/extensions/StdCmap.h"
30
31 static void
32 X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h)
33 {
34 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
35 SDL_DisplayData *displaydata =
36 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
37 XWindowAttributes attr;
38
39 XGetWindowAttributes(data->display, RootWindow(data->display,
40 displaydata->screen),
41 &attr);
42 if (w) {
43 *w = attr.width;
44 }
45 if (h) {
46 *h = attr.height;
47 }
48 }
30 49
31 static int 50 static int
32 SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) 51 SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
33 { 52 {
34 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; 53 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
287 visual, AllocNone); 306 visual, AllocNone);
288 } 307 }
289 308
290 if ((window->flags & SDL_WINDOW_FULLSCREEN) 309 if ((window->flags & SDL_WINDOW_FULLSCREEN)
291 || window->x == SDL_WINDOWPOS_CENTERED) { 310 || window->x == SDL_WINDOWPOS_CENTERED) {
292 x = (DisplayWidth(data->display, displaydata->screen) - 311 X11_GetDisplaySize(_this, window, &x, NULL);
293 window->w) / 2; 312 x = (x - window->w) / 2;
294 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { 313 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
295 x = 0; 314 x = 0;
296 } else { 315 } else {
297 x = window->x; 316 x = window->x;
298 } 317 }
299 if ((window->flags & SDL_WINDOW_FULLSCREEN) 318 if ((window->flags & SDL_WINDOW_FULLSCREEN)
300 || window->y == SDL_WINDOWPOS_CENTERED) { 319 || window->y == SDL_WINDOWPOS_CENTERED) {
301 y = (DisplayHeight(data->display, displaydata->screen) - 320 X11_GetDisplaySize(_this, window, NULL, &y);
302 window->h) / 2; 321 y = (y - window->h) / 2;
303 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) { 322 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
304 y = 0; 323 y = 0;
305 } else { 324 } else {
306 y = window->y; 325 y = window->y;
307 } 326 }
606 Display *display = data->videodata->display; 625 Display *display = data->videodata->display;
607 int x, y; 626 int x, y;
608 627
609 if ((window->flags & SDL_WINDOW_FULLSCREEN) 628 if ((window->flags & SDL_WINDOW_FULLSCREEN)
610 || window->x == SDL_WINDOWPOS_CENTERED) { 629 || window->x == SDL_WINDOWPOS_CENTERED) {
611 x = (DisplayWidth(display, displaydata->screen) - window->w) / 2; 630 X11_GetDisplaySize(_this, window, &x, NULL);
631 x = (x - window->w) / 2;
612 } else { 632 } else {
613 x = window->x; 633 x = window->x;
614 } 634 }
615 if ((window->flags & SDL_WINDOW_FULLSCREEN) 635 if ((window->flags & SDL_WINDOW_FULLSCREEN)
616 || window->y == SDL_WINDOWPOS_CENTERED) { 636 || window->y == SDL_WINDOWPOS_CENTERED) {
617 y = (DisplayHeight(display, displaydata->screen) - window->h) / 2; 637 X11_GetDisplaySize(_this, window, NULL, &y);
638 y = (y - window->h) / 2;
618 } else { 639 } else {
619 y = window->y; 640 y = window->y;
620 } 641 }
621 XMoveWindow(display, data->window, x, y); 642 XMoveWindow(display, data->window, x, y);
622 } 643 }
625 X11_SetWindowSize(_THIS, SDL_Window * window) 646 X11_SetWindowSize(_THIS, SDL_Window * window)
626 { 647 {
627 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; 648 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
628 Display *display = data->videodata->display; 649 Display *display = data->videodata->display;
629 650
630 XMoveWindow(display, data->window, window->w, window->h); 651 XResizeWindow(display, data->window, window->w, window->h);
631 } 652 }
632 653
633 void 654 void
634 X11_ShowWindow(_THIS, SDL_Window * window) 655 X11_ShowWindow(_THIS, SDL_Window * window)
635 { 656 {