[MPlayer-dev-eng] [PATCH] Warp cursor to 0,0 on fullscreen

Wander Winkelhorst wander at f1racing.net
Thu Jul 25 23:24:09 CEST 2002


Hi,

> > old_width=vo_dwidth;   vo_old_height=vo_dheight; }.
> >  .
> > + XWarpPointer( mDisplay, None, DefaultRootWindow(mDisplay), 0, 0, 0, 0, 0
> > , 0 );.
> >   vo_x11_decoration( mDisplay,vo_window,(vo_fs) ? 0 : 1 );.
> >   vo_x11_sizehint( x,y,w,h,0 );.
>
> it seems it ALWAYS wraps the cursors, not only at fullscreen...
> please implement tehnegative of this wrapping, for the vase when vo_fs==0
>

The included patch queries the current cursor position on going fullscreen,
and warps the cursor back to that position when leaving fullscreen.
Is this satisfactionary?

And Rich, what do you think?

And does someone know a way to get rid of these junk variables I'm currently
using? I don't like it this way.

Regards,

Wander
-------------- next part --------------
diff -Naur /tmp/MPlayer-20020725/libvo/x11_common.c ./libvo/x11_common.c
--- /tmp/MPlayer-20020725/libvo/x11_common.c	Thu Jun 13 00:57:58 2002
+++ ./libvo/x11_common.c	Thu Jul 25 23:13:10 2002
@@ -76,6 +76,9 @@
 int vo_mouse_autohide = 0;
 int vo_wm_type = -1;
 
+/* To return cursor on original position after fullscreen */
+int prev_cursor_X, prev_cursor_Y = 0;
+
 #ifdef HAVE_XINERAMA
 int xinerama_screen = 0;
 int xinerama_x = 0;
@@ -754,11 +757,28 @@
 {
  int x=0,y=0,w=vo_screenwidth,h=vo_screenheight;
 
+ /* Junk variables, to keep XQueryPointer happy */
+ int junk;
+ Window window_junk;
+
  if ( WinID >= 0 ) return;
 
  if ( vo_fs )
-  { vo_fs=VO_FALSE; x=vo_old_x; y=vo_old_y; w=vo_old_width; h=vo_old_height; }
-   else { vo_fs=VO_TRUE; vo_old_x=vo_dx; vo_old_y=vo_dy; vo_old_width=vo_dwidth;   vo_old_height=vo_dheight; }
+ { 
+  vo_fs=VO_FALSE; x=vo_old_x; y=vo_old_y; w=vo_old_width; h=vo_old_height;
+  if (prev_cursor_X >= 0) 
+    XWarpPointer(mDisplay, None, DefaultRootWindow(mDisplay), 0, 0, 0, 0, prev_cursor_X, prev_cursor_Y);
+ } else { 
+  if (!XQueryPointer(mDisplay, DefaultRootWindow(mDisplay), &window_junk, &window_junk, &prev_cursor_X, &prev_cursor_Y, &junk, &junk, &junk))
+  {
+   /* cursor is on an other screen */
+   prev_cursor_X = -1;
+   prev_cursor_Y = -1;
+  } 
+  else XWarpPointer(mDisplay, None, DefaultRootWindow(mDisplay), 0, 0, 0, 0, 0, 0);
+
+  vo_fs=VO_TRUE; vo_old_x=vo_dx; vo_old_y=vo_dy; vo_old_width=vo_dwidth;   vo_old_height=vo_dheight; 
+ }
 
  vo_x11_decoration( mDisplay,vo_window,(vo_fs) ? 0 : 1 );
  vo_x11_sizehint( x,y,w,h,0 );


More information about the MPlayer-dev-eng mailing list