[MPlayer-cvslog] r27919 - in trunk/libvo: gl_common.c vo_x11.c vo_xv.c x11_common.c x11_common.h

reimar subversion at mplayerhq.hu
Sat Nov 15 18:45:56 CET 2008


Author: reimar
Date: Sat Nov 15 18:45:55 2008
New Revision: 27919

Log:
Change some of the different inconsistent XGetGeometry uses by a
vo_x11_update_geometry function.


Modified:
   trunk/libvo/gl_common.c
   trunk/libvo/vo_x11.c
   trunk/libvo/vo_xv.c
   trunk/libvo/x11_common.c
   trunk/libvo/x11_common.h

Modified: trunk/libvo/gl_common.c
==============================================================================
--- trunk/libvo/gl_common.c	(original)
+++ trunk/libvo/gl_common.c	Sat Nov 15 18:45:55 2008
@@ -1607,13 +1607,7 @@ int setGlWindow(XVisualInfo **vinfo, GLX
 
   // set new values
   vo_window = win;
-  {
-    Window root;
-    int tmp;
-    unsigned utmp;
-    XGetGeometry(mDisplay, vo_window, &root, &tmp, &tmp,
-        (unsigned *)&vo_dwidth, (unsigned *)&vo_dheight, &utmp, &utmp);
-  }
+  vo_x11_update_geometry();
   if (!keep_context) {
     void *(*getProcAddress)(const GLubyte *);
     const char *(*glXExtStr)(Display *, int);

Modified: trunk/libvo/vo_x11.c
==============================================================================
--- trunk/libvo/vo_x11.c	(original)
+++ trunk/libvo/vo_x11.c	Sat Nov 15 18:45:55 2008
@@ -430,9 +430,7 @@ static int config(uint32_t width, uint32
                                            ButtonReleaseMask |
                                            ExposureMask);
                 XMapWindow(mDisplay, vo_window);
-                XGetGeometry(mDisplay, vo_window, &mRootWin,
-                             &vo_dx, &vo_dy, &vo_dwidth, &vo_dheight,
-                             &border, &depth);
+                depth = vo_x11_update_geometry();
             } else
                 XSelectInput(mDisplay, vo_window, ExposureMask);
         } else

Modified: trunk/libvo/vo_xv.c
==============================================================================
--- trunk/libvo/vo_xv.c	(original)
+++ trunk/libvo/vo_xv.c	Sat Nov 15 18:45:55 2008
@@ -290,11 +290,7 @@ static int config(uint32_t width, uint32
                                            ButtonReleaseMask |
                                            ExposureMask);
                 XMapWindow(mDisplay, vo_window);
-                XGetGeometry(mDisplay, vo_window, &mRoot,
-                             &drwX, &drwY, &vo_dwidth, &vo_dheight,
-                             &drwBorderWidth, &drwDepth);
-                if (vo_dwidth <= 0) vo_dwidth = d_width;
-                if (vo_dheight <= 0) vo_dheight = d_height;
+                vo_x11_update_geometry();
                 aspect_save_prescale(vo_dwidth, vo_dheight);
             }
         } else

Modified: trunk/libvo/x11_common.c
==============================================================================
--- trunk/libvo/x11_common.c	(original)
+++ trunk/libvo/x11_common.c	Sat Nov 15 18:45:55 2008
@@ -1040,25 +1040,7 @@ int vo_x11_check_events(Display * mydisp
 //         if (vo_fs && Event.xconfigure.width != vo_screenwidth && Event.xconfigure.height != vo_screenheight) break;
                 if (vo_window == None)
                     break;
-                vo_dwidth = Event.xconfigure.width;
-                vo_dheight = Event.xconfigure.height;
-#if 0
-                /* when resizing, x and y are zero :( */
-                vo_dx = Event.xconfigure.x;
-                vo_dy = Event.xconfigure.y;
-#else
-                {
-                    Window root;
-                    int foo;
-                    Window win;
-
-                    XGetGeometry(mydisplay, vo_window, &root, &foo, &foo,
-                                 &foo /*width */ , &foo /*height */ , &foo,
-                                 &foo);
-                    XTranslateCoordinates(mydisplay, vo_window, root, 0, 0,
-                                          &vo_dx, &vo_dy, &win);
-                }
-#endif
+                vo_x11_update_geometry();
                 ret |= VO_EVENT_RESIZE;
                 break;
             case KeyPress:
@@ -1496,6 +1478,22 @@ static int vo_x11_get_fs_type(int suppor
     return type;
 }
 
+/**
+ * \brief update vo_dx, vo_dy, vo_dwidth and vo_dheight with current values of vo_window
+ * \return returns current color depth of vo_window
+ */
+int vo_x11_update_geometry(void) {
+    unsigned depth, w, h;
+    int dummy_int;
+    Window dummy_win;
+    XGetGeometry(mDisplay, vo_window, &dummy_win, &dummy_int, &dummy_int,
+                 &w, &h, &dummy_int, &depth);
+    if (w <= INT_MAX && h <= INT_MAX) { vo_dwidth = w; vo_dheight = h; }
+    XTranslateCoordinates(mDisplay, vo_window, mRootWin, 0, 0, &vo_dx, &vo_dy,
+                          &dummy_win);
+    return depth <= INT_MAX ? depth : 0;
+}
+
 void vo_x11_fullscreen(void)
 {
     int x, y, w, h;

Modified: trunk/libvo/x11_common.h
==============================================================================
--- trunk/libvo/x11_common.h	(original)
+++ trunk/libvo/x11_common.h	Sat Nov 15 18:45:55 2008
@@ -50,6 +50,7 @@ extern void vo_x11_nofs_sizepos(int x, i
 extern void vo_x11_sizehint( int x, int y, int width, int height, int max );
 extern int vo_x11_check_events(Display *mydisplay);
 extern void vo_x11_selectinput_witherr(Display *display, Window w, long event_mask);
+int vo_x11_update_geometry(void);
 extern void vo_x11_fullscreen( void );
 extern void vo_x11_setlayer( Display * mDisplay,Window vo_window,int layer );
 extern void vo_x11_uninit(void);



More information about the MPlayer-cvslog mailing list