changeset 33994:8e5680eccf54

Move common code to new function wsUpdateXineramaInfo(). Use the new function in wsXInit() and wsFullScreen(). Note: xinerama_x and xinerama_y are output parameters of update_xinerama_info(). It's pointless to set them before calling.
author ib
date Thu, 08 Sep 2011 12:34:28 +0000
parents 57d711d3dcca
children 9c2779f24077
files gui/wm/ws.c
diffstat 1 files changed, 39 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/gui/wm/ws.c	Thu Sep 08 11:11:02 2011 +0000
+++ b/gui/wm/ws.c	Thu Sep 08 12:34:28 2011 +0000
@@ -203,6 +203,42 @@
     return 0;
 }
 
+/**
+ * @brief Update screen width, screen height and screen origin x and y
+ *        from xinerama information.
+ *
+ *        Set wsOrgX, wsOrgY, wsMaxX and wsMaxY as well as
+ *        win->X, win->Y, win->Width and win->Height.
+ *
+ * @param win pointer to a ws window structure or NULL
+ */
+static void wsUpdateXineramaInfo(wsTWindow *win)
+{
+    if (win) {
+        vo_dx      = win->X;
+        vo_dy      = win->Y;
+        vo_dwidth  = win->Width;
+        vo_dheight = win->Height;
+    }
+
+    vo_screenwidth  = wsMaxX;
+    vo_screenheight = wsMaxY;
+
+    update_xinerama_info();
+
+    wsMaxX = vo_screenwidth;
+    wsMaxY = vo_screenheight;
+    wsOrgX = xinerama_x;
+    wsOrgY = xinerama_y;
+
+    if (win) {
+        win->X      = wsOrgX;
+        win->Y      = wsOrgY;
+        win->Width  = wsMaxX;
+        win->Height = wsMaxY;
+    }
+}
+
 void wsXInit(Display *mDisplay)
 {
     int eventbase;
@@ -270,15 +306,8 @@
         if (!wsMaxY)
             wsMaxY = DisplayHeight(wsDisplay, wsScreen);
     }
-    vo_screenwidth  = wsMaxX;
-    vo_screenheight = wsMaxY;
-    xinerama_x      = wsOrgX;
-    xinerama_y      = wsOrgY;
-    update_xinerama_info();
-    wsMaxX = vo_screenwidth;
-    wsMaxY = vo_screenheight;
-    wsOrgX = xinerama_x;
-    wsOrgY = xinerama_y;
+
+    wsUpdateXineramaInfo(NULL);
 
     wsGetDepthOnScreen();
 
@@ -915,23 +944,7 @@
             win->OldHeight = win->Height;
         }
 
-        vo_dx           = win->X;
-        vo_dy           = win->Y;
-        vo_dwidth       = win->Width;
-        vo_dheight      = win->Height;
-        vo_screenwidth  = wsMaxX;
-        vo_screenheight = wsMaxY;
-        xinerama_x      = wsOrgX;
-        xinerama_y      = wsOrgY;
-        update_xinerama_info();
-        wsMaxX      = vo_screenwidth;
-        wsMaxY      = vo_screenheight;
-        wsOrgX      = xinerama_x;
-        wsOrgY      = xinerama_y;
-        win->X      = wsOrgX;
-        win->Y      = wsOrgY;
-        win->Width  = wsMaxX;
-        win->Height = wsMaxY;
+        wsUpdateXineramaInfo(win);
 
         win->isFullScreen = True;