[MPlayer-dev-eng] [RFC] keep user window position

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Jun 20 22:08:24 CEST 2006


Hello,
this is a preview-patch. It probably won't work quite right, should be
optional, and only works with -fixed-vo at all.
The idea is to keep the window position if it was explicitly used by the
user (which should include stuff the window manager does).

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libvo/x11_common.c
===================================================================
--- libvo/x11_common.c	(revision 18760)
+++ libvo/x11_common.c	(working copy)
@@ -109,6 +109,9 @@
 static int vo_old_y = 0;
 static int vo_old_width = 0;
 static int vo_old_height = 0;
+static int userpos = 0;
+static int vo_user_x = 0;
+static int vo_user_y = 0;
 
 #ifdef HAVE_XF86VM
 XF86VidModeModeInfo **vidmodes = NULL;
@@ -1007,6 +1010,7 @@
 int vo_x11_check_events(Display * mydisplay)
 {
     int ret = 0;
+    int prevx, prevy;
     XEvent Event;
     char buf[100];
     KeySym keySym;
@@ -1044,6 +1048,8 @@
                     break;
                 vo_dwidth = Event.xconfigure.width;
                 vo_dheight = Event.xconfigure.height;
+                prevx = vo_dx;
+                prevy = vo_dy;
 #if 0
                 /* when resizing, x and y are zero :( */
                 vo_dx = Event.xconfigure.x;
@@ -1061,6 +1067,11 @@
                                           &vo_dx, &vo_dy, &win);
                 }
 #endif
+                if (vo_dx != prevx || vo_dy != prevy) {
+                  userpos = 1;
+                  vo_user_x = vo_dx;
+                  vo_user_y = vo_dy;
+                }
                 ret |= VO_EVENT_RESIZE;
                 break;
             case KeyPress:
@@ -1161,6 +1172,10 @@
  */
 void vo_x11_nofs_sizepos(int x, int y, int width, int height)
 {
+  if (userpos) {
+    x = vo_user_x;
+    y = vo_user_y;
+  }
   if (vo_fs) {
     vo_old_x = x;
     vo_old_y = y;
@@ -1259,6 +1274,7 @@
     if (!f_gc)
         f_gc = XCreateGC(mDisplay, ret_win, 0, 0);
     XSetForeground(mDisplay, f_gc, 0);
+    userpos = 0;
 
     return ret_win;
 }


More information about the MPlayer-dev-eng mailing list