[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Patches to fix fullscreen games viewport issues with recent Xorg versions



Hi,

With recent Xorg versions XF86VidModeSetViewPort() does not seem to
do anything. So fullscreen games which place an undecorated window
at 0,0 and then do XF86VidModeSetViewPort(.., 0, 0) no may end up with
the viewport wrong (showing part of the game and part of the
desktop).

This can be workedaround by doing a XWarpPointer() call to 0, 0
before XF86VidModeSwitchToMode().

SDL is already doing this, attached are patches for:
allegro
ClanLib-0.8 / 1.0 (0.6 and 2.x are not affected)
xgalaxy

Implementing this workaround.

Regards,

Hans
--- allegro-4.2.2/src/x/xwin.c	2009-09-10 22:29:53.000000000 +0200
+++ allegro-4.2.2.new/src/x/xwin.c	2009-09-10 21:48:21.000000000 +0200
@@ -2853,6 +2853,13 @@
       }
    }
       
+   /* Warp the pointer to the upper left corner (where our fs_window is),
+      this is necessary as the: XF86VidModeSetViewPort() call below does
+      not seem to do anything on newer Xorg servers, instead the viewport
+      seems to always be centered at the last mouse cursor position. */
+   XWarpPointer(_xwin.display, None, XDefaultRootWindow(_xwin.display),
+                0, 0, 0, 0, 0, 0);
+
    /* Switch video mode.  */
    if ((_xwin.modesinfo[i] == _xwin.orig_modeinfo) ||
        !XF86VidModeSwitchToMode(_xwin.display, _xwin.screen,
diff -up ClanLib-1.0.0/Sources/GL/GLX/display_window_opengl.cpp~ ClanLib-1.0.0/Sources/GL/GLX/display_window_opengl.cpp
--- ClanLib-1.0.0/Sources/GL/GLX/display_window_opengl.cpp~	2008-11-13 17:09:02.000000000 +0100
+++ ClanLib-1.0.0/Sources/GL/GLX/display_window_opengl.cpp	2009-09-10 22:58:10.000000000 +0200
@@ -612,6 +612,13 @@ void CL_DisplayWindow_OpenGL::set_resolu
 				XF86VidModeGetViewPort(disp, vi->screen,
 					&old_x, &old_y);
 			}
+			/* Warp the pointer to the upper left corner, this is
+			   necessary as the: XF86VidModeSetViewPort() call
+			   below does not seem to do anything on newer Xorg
+			   servers, instead the viewport appears to be always
+			   centered at the last mouse position */
+			XWarpPointer(disp, None, XDefaultRootWindow(disp),
+				     0, 0, 0, 0, 0, 0);
 			XF86VidModeSwitchToMode(disp, vi->screen,
 				modes[i]);
 		}
diff -up xgalaga-2.0.34/libsprite/makewindow.c~ xgalaga-2.0.34/libsprite/makewindow.c
--- xgalaga-2.0.34/libsprite/makewindow.c~	2009-09-11 08:48:44.000000000 +0200
+++ xgalaga-2.0.34/libsprite/makewindow.c	2009-09-11 08:50:50.000000000 +0200
@@ -642,6 +642,13 @@ void W_ToggleFullscreen(_win)
       }
     }
         
+    /* Warp the pointer to the upper left corner (where our fs_window is),
+       this is necessary as the: XF86VidModeSetViewPort() call below does
+       not seem to do anything on newer Xorg servers, instead the viewport
+       seems to always be centered at the last mouse cursor position. */
+    XWarpPointer(W_Display, None, XDefaultRootWindow(W_Display),
+                 0, 0, 0, 0, 0, 0);
+
     /* Switch video mode.  */
     if ((i >= 0) &&
         ((modes[i]->hdisplay != mode.hdisplay) ||

Reply to: