# HG changeset patch # User David Gow # Date 1351609758 -28800 # Node ID d782da29b2dfe03c13c7287663262bce7d8c66ee # Parent 9a22ac8befa9ed7c4c476f273163c016afb1655d Support WM quirks for KWin diff -r 9a22ac8befa9 -r d782da29b2df src/video/x11/SDL_x11modes.c --- a/src/video/x11/SDL_x11modes.c Sun Oct 28 19:28:44 2012 -0700 +++ b/src/video/x11/SDL_x11modes.c Tue Oct 30 23:09:18 2012 +0800 @@ -149,7 +149,7 @@ #if SDL_VIDEO_DRIVER_X11_XINERAMA static SDL_bool -CheckXinerama(Display * display, int *major, int *minor) +CheckXinerama(Display * display, int *major, int *minor, SDL_bool disable) { int event_base = 0; int error_base = 0; @@ -160,6 +160,12 @@ /* Allow environment override */ env = SDL_GetHint(SDL_HINT_VIDEO_X11_XINERAMA); + if (disable && !env) { +#ifdef X11MODES_DEBUG + printf("Xinerama disabled by default due to window manager issues\n"); +#endif + return SDL_FALSE; + } if (env && !SDL_atoi(env)) { #ifdef X11MODES_DEBUG printf("Xinerama disabled due to hint\n"); @@ -192,7 +198,7 @@ #if SDL_VIDEO_DRIVER_X11_XRANDR static SDL_bool -CheckXRandR(Display * display, int *major, int *minor) +CheckXRandR(Display * display, int *major, int *minor, SDL_bool disable) { const char *env; @@ -201,21 +207,18 @@ /* Allow environment override */ env = SDL_GetHint(SDL_HINT_VIDEO_X11_XRANDR); -#ifdef XRANDR_DISABLED_BY_DEFAULT - if (!env || !SDL_atoi(env)) { + if (disable && !env) { #ifdef X11MODES_DEBUG printf("XRandR disabled by default due to window manager issues\n"); #endif return SDL_FALSE; } -#else if (env && !SDL_atoi(env)) { #ifdef X11MODES_DEBUG printf("XRandR disabled due to hint\n"); #endif return SDL_FALSE; } -#endif /* XRANDR_ENABLED_BY_DEFAULT */ if (!SDL_X11_HAVE_XRANDR) { #ifdef X11MODES_DEBUG @@ -285,7 +288,7 @@ #if SDL_VIDEO_DRIVER_X11_XVIDMODE static SDL_bool -CheckVidMode(Display * display, int *major, int *minor) +CheckVidMode(Display * display, int *major, int *minor, SDL_bool disable) { const char *env; @@ -294,6 +297,13 @@ /* Allow environment override */ env = SDL_GetHint(SDL_HINT_VIDEO_X11_XVIDMODE); + if (disable && !env) + { +#ifdef X11MODES_DEBUG + printf("XVidMode disabled by default due to window manager issues\n"); +#endif + return SDL_FALSE; + } if (env && !SDL_atoi(env)) { #ifdef X11MODES_DEBUG printf("XVidMode disabled due to hint\n"); @@ -376,24 +386,41 @@ #if SDL_VIDEO_DRIVER_X11_XINERAMA int xinerama_major, xinerama_minor; int use_xinerama = 0; + SDL_bool disable_xinerama = SDL_FALSE; XineramaScreenInfo *xinerama = NULL; #endif #if SDL_VIDEO_DRIVER_X11_XRANDR int xrandr_major, xrandr_minor; int use_xrandr = 0; +#ifdef XRANDR_DISABLED_BY_DEFAULT + SDL_bool disable_xrandr = SDL_TRUE; +#else + SDL_bool disable_xrandr = SDL_FALSE; +#endif /* XRANDR_ENABLED_BY_DEFAULT */ XRRScreenResources *res = NULL; #endif #if SDL_VIDEO_DRIVER_X11_XVIDMODE int vm_major, vm_minor; int use_vidmode = 0; + SDL_bool disable_vidmode = SDL_FALSE; #endif + + /* Some window managers have issues with certain setups. */ + if (!strcmp(data->wm_name, "KWin")) + { + disable_xrandr = SDL_FALSE; /* KWin works best with XRandR. */ + disable_vidmode = SDL_TRUE; /* Legacy fullscreen does not work */ + } + + + #if SDL_VIDEO_DRIVER_X11_XINERAMA /* Query Xinerama extention * NOTE: This works with Nvidia Twinview correctly, but you need version 302.17 (released on June 2012) * or newer of the Nvidia binary drivers */ - if (CheckXinerama(data->display, &xinerama_major, &xinerama_minor)) { + if (CheckXinerama(data->display, &xinerama_major, &xinerama_minor, disable_xinerama)) { xinerama = XineramaQueryScreens(data->display, &screencount); if (xinerama) { use_xinerama = xinerama_major * 100 + xinerama_minor; @@ -408,14 +435,14 @@ #if SDL_VIDEO_DRIVER_X11_XRANDR /* require at least XRandR v1.2 */ - if (CheckXRandR(data->display, &xrandr_major, &xrandr_minor) && + if (CheckXRandR(data->display, &xrandr_major, &xrandr_minor, disable_xrandr) && (xrandr_major >= 2 || (xrandr_major == 1 && xrandr_minor >= 2))) { use_xrandr = xrandr_major * 100 + xrandr_minor; } #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ #if SDL_VIDEO_DRIVER_X11_XVIDMODE - if (CheckVidMode(data->display, &vm_major, &vm_minor)) { + if (CheckVidMode(data->display, &vm_major, &vm_minor, disable_vidmode)) { use_vidmode = vm_major * 100 + vm_minor; } #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */ diff -r 9a22ac8befa9 -r d782da29b2df src/video/x11/SDL_x11video.c --- a/src/video/x11/SDL_x11video.c Sun Oct 28 19:28:44 2012 -0700 +++ b/src/video/x11/SDL_x11video.c Tue Oct 30 23:09:18 2012 +0800 @@ -303,9 +303,6 @@ unsigned long items_read, items_left; unsigned char *propdata; Window wm_window = 0; -#ifdef DEBUG_WINDOW_MANAGER - char *wm_name; -#endif /* Set up a handler to gracefully catch errors */ XSync(display, False); @@ -342,10 +339,9 @@ } data->net_wm = SDL_TRUE; + data->wm_name = X11_GetWindowTitle(_this, wm_window); #ifdef DEBUG_WINDOW_MANAGER - wm_name = X11_GetWindowTitle(_this, wm_window); - printf("Window manager: %s\n", wm_name); - SDL_free(wm_name); + printf("Window manager: %s\n", data->wm_name); #endif } @@ -410,6 +406,11 @@ if (data->classname) { SDL_free(data->classname); } + + if (data->wm_name) { + SDL_free(data->wm_name); + } + #ifdef X_HAVE_UTF8_STRING if (data->im) { XCloseIM(data->im); diff -r 9a22ac8befa9 -r d782da29b2df src/video/x11/SDL_x11video.h --- a/src/video/x11/SDL_x11video.h Sun Oct 28 19:28:44 2012 -0700 +++ b/src/video/x11/SDL_x11video.h Tue Oct 30 23:09:18 2012 +0800 @@ -96,6 +96,8 @@ SDL_Scancode key_layout[256]; SDL_bool selection_waiting; + + char *wm_name; } SDL_VideoData; extern SDL_bool X11_UseDirectColorVisuals(void);