[Xfce4-commits] [xfce/xfwm4] 01/03: Compute struts based on reported screen size

noreply at xfce.org noreply at xfce.org
Sat Feb 28 00:00:15 CET 2015


This is an automated email from the git hooks/post-receive script.

olivier pushed a commit to branch master
in repository xfce/xfwm4.

commit 8c4e805ecdb5916140c888b30e8fa773334beb6e
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Fri Feb 27 21:55:42 2015 +0100

    Compute struts based on reported screen size
    
    Even if we know that the screen size is wrong, as most panels (including
    our own)  will base their strut values on these as well.
    
    Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
---
 src/client.c     |    4 ++--
 src/netwm.c      |   20 ++++++++++----------
 src/placement.c  |    8 ++++----
 src/screen.c     |   23 +++++++++++++----------
 src/screen.h     |    6 ++++--
 src/workspaces.c |    8 ++++----
 6 files changed, 37 insertions(+), 32 deletions(-)

diff --git a/src/client.c b/src/client.c
index 0a748f0..7c93414 100644
--- a/src/client.c
+++ b/src/client.c
@@ -3199,9 +3199,9 @@ clientNewMaxSize (Client *c, XWindowChanges *wc, GdkRectangle *rect, tilePositio
 
     full_x = MAX (screen_info->params->xfwm_margins[STRUTS_LEFT], rect->x);
     full_y = MAX (screen_info->params->xfwm_margins[STRUTS_TOP], rect->y);
-    full_w = MIN (screen_info->width - screen_info->params->xfwm_margins[STRUTS_RIGHT],
+    full_w = MIN (screen_info->logical_width - screen_info->params->xfwm_margins[STRUTS_RIGHT],
                   rect->x + rect->width) - full_x;
-    full_h = MIN (screen_info->height - screen_info->params->xfwm_margins[STRUTS_BOTTOM],
+    full_h = MIN (screen_info->logical_height - screen_info->params->xfwm_margins[STRUTS_BOTTOM],
                   rect->y + rect->height) - full_y;
 
     /* Adjust size to the largest size available, not covering struts */
diff --git a/src/netwm.c b/src/netwm.c
index ee3cd4d..81e830a 100644
--- a/src/netwm.c
+++ b/src/netwm.c
@@ -985,29 +985,29 @@ clientValidateNetStrut (Client * c)
     screen_info = c->screen_info;
     valid = TRUE;
 
-    if (c->struts[STRUTS_TOP] > screen_info->height - screen_info->margins[STRUTS_BOTTOM])
+    if (c->struts[STRUTS_TOP] > screen_info->logical_height - screen_info->margins[STRUTS_BOTTOM])
     {
-       c->struts[STRUTS_TOP] = screen_info->height - screen_info->margins[STRUTS_BOTTOM];
+       c->struts[STRUTS_TOP] = screen_info->logical_height - screen_info->margins[STRUTS_BOTTOM];
        g_warning ("Top strut value for application window 0x%lx confined to %d", c->window, c->struts[STRUTS_TOP]);
        valid = FALSE;
     }
 
-    if (c->struts[STRUTS_BOTTOM] > screen_info->height - screen_info->margins[STRUTS_TOP])
+    if (c->struts[STRUTS_BOTTOM] > screen_info->logical_height - screen_info->margins[STRUTS_TOP])
     {
-       c->struts[STRUTS_BOTTOM] = screen_info->height - screen_info->margins[STRUTS_TOP];
+       c->struts[STRUTS_BOTTOM] = screen_info->logical_height - screen_info->margins[STRUTS_TOP];
        g_warning ("Bottom strut value for application window 0x%lx confined to %d", c->window, c->struts[STRUTS_BOTTOM]);
        valid = FALSE;
     }
 
-    if (c->struts[STRUTS_LEFT] > screen_info->width - screen_info->margins[STRUTS_RIGHT])
+    if (c->struts[STRUTS_LEFT] > screen_info->logical_width - screen_info->margins[STRUTS_RIGHT])
     {
-       c->struts[STRUTS_LEFT] = screen_info->height - screen_info->margins[STRUTS_RIGHT];
+       c->struts[STRUTS_LEFT] = screen_info->logical_height - screen_info->margins[STRUTS_RIGHT];
        g_warning ("Left strut value for application window 0x%lx confined to %d", c->window, c->struts[STRUTS_LEFT]);
        valid = FALSE;
     }
-    if (c->struts[STRUTS_RIGHT] > screen_info->width - screen_info->margins[STRUTS_LEFT])
+    if (c->struts[STRUTS_RIGHT] > screen_info->logical_width - screen_info->margins[STRUTS_LEFT])
     {
-       c->struts[STRUTS_RIGHT] = screen_info->height - screen_info->margins[STRUTS_LEFT];
+       c->struts[STRUTS_RIGHT] = screen_info->logical_height - screen_info->margins[STRUTS_LEFT];
        g_warning ("Right strut value for application window 0x%lx confined to %d", c->window, c->struts[STRUTS_RIGHT]);
        valid = FALSE;
     }
@@ -1104,10 +1104,10 @@ clientGetNetStruts (Client * c)
         /* Fill(in values as for partial struts */
         c->struts[STRUTS_TOP_START_X] = c->struts[STRUTS_BOTTOM_START_X] = 0;
         c->struts[STRUTS_TOP_END_X] = c->struts[STRUTS_BOTTOM_END_X] =
-            c->screen_info->width;
+            c->screen_info->logical_width;
         c->struts[STRUTS_LEFT_START_Y] = c->struts[STRUTS_RIGHT_START_Y] = 0;
         c->struts[STRUTS_LEFT_END_Y] = c->struts[STRUTS_RIGHT_END_Y] =
-            c->screen_info->height;
+            c->screen_info->logical_height;
 
         XFree (struts);
     }
diff --git a/src/placement.c b/src/placement.c
index a804c4c..6b87d17 100644
--- a/src/placement.c
+++ b/src/placement.c
@@ -117,8 +117,8 @@ clientMaxSpace (ScreenInfo *screen_info, int *x, int *y, int *w, int *h)
         if (FLAG_TEST (c2->flags, CLIENT_FLAG_HAS_STRUT)
             && FLAG_TEST (c2->xfwm_flags, XFWM_FLAG_VISIBLE))
         {
-            screen_width = c2->screen_info->width;
-            screen_height = c2->screen_info->height;
+            screen_width = c2->screen_info->logical_width;
+            screen_height = c2->screen_info->logical_height;
 
             /* Left */
             if (overlap (*x, *y, *x + *w, *y + *h,
@@ -236,8 +236,8 @@ clientConstrainPos (Client * c, gboolean show_full)
 
     myScreenFindMonitorAtPoint (screen_info, cx, cy, &rect);
 
-    screen_width = screen_info->width;
-    screen_height = screen_info->height;
+    screen_width = screen_info->logical_width;
+    screen_height = screen_info->logical_height;
 
     disp_x = rect.x;
     disp_y = rect.y;
diff --git a/src/screen.c b/src/screen.c
index 08104ac..289915a 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -203,10 +203,9 @@ myScreenInit (DisplayInfo *display_info, GdkScreen *gscr, unsigned long event_ma
     screen_info->screen = gdk_screen_get_number (gscr);
     screen_info->cmap = GDK_COLORMAP_XCOLORMAP(gdk_screen_get_rgb_colormap (gscr));
     screen_info->depth = DefaultDepth (display_info->dpy, screen_info->screen);
-    screen_info->width = WidthOfScreen (screen_info->xscreen);
-    screen_info->height = HeightOfScreen (screen_info->xscreen);
     screen_info->visual = DefaultVisual (display_info->dpy, screen_info->screen);
     screen_info->shape_win = (Window) None;
+    myScreenComputeSize (screen_info);
 
     screen_info->xfwm4_win = GDK_WINDOW_XWINDOW (screen_info->gtk_win->window);
     if (!myScreenSetWMAtom (screen_info, replace_wm))
@@ -627,7 +626,6 @@ myScreenComputeSize (ScreenInfo *screen_info)
 {
     gint num_monitors, i;
     gint width, height;
-    gint screen_width, screen_height;
     GdkRectangle monitor;
     gboolean changed;
 
@@ -651,20 +649,25 @@ myScreenComputeSize (ScreenInfo *screen_info)
         height = MAX (monitor.y + monitor.height, height);
     }
 
+    screen_info->logical_width = gdk_screen_get_width (screen_info->gscr);
+    screen_info->logical_height = gdk_screen_get_height (screen_info->gscr);
+    if ((width != screen_info->logical_width) || (height != screen_info->logical_height))
+    {
+        g_warning ("output size (%dx%d) and logical screen size (%dx%d) do not match",
+                   width, height, screen_info->logical_width, screen_info->logical_height);
+    }
+
     /* Keep the smallest size between what we computed and the
      * reported size for the screen.
      */
-    screen_width = gdk_screen_get_width (screen_info->gscr);
-    screen_height = gdk_screen_get_height (screen_info->gscr);
-
-    if (width == 0 || width > screen_width)
+    if (width == 0 || width > screen_info->logical_width)
     {
-        width = screen_width;
+        width = screen_info->logical_width;
     }
 
-    if (height == 0 || height > screen_height)
+    if (height == 0 || height > screen_info->logical_height)
     {
-        height = screen_height;
+        height = screen_info->logical_height;
     }
 
     changed = ((screen_info->width != width) | (screen_info->height != height));
diff --git a/src/screen.h b/src/screen.h
index 1c4b538..9aeffc4 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -100,8 +100,10 @@ struct _ScreenInfo
     GdkScreen *gscr;
     Screen *xscreen;
     gint depth;
-    gint width;
-    gint height;
+    gint width;  /* Size of all output combined */
+    gint height; /* Size of all output combined */
+    gint logical_width;  /* Xorg reported size */
+    gint logical_height; /* Xorg reported size */
     Visual *visual;
 
     GtkWidget *gtk_win;
diff --git a/src/workspaces.c b/src/workspaces.c
index 3800429..21c84dd 100644
--- a/src/workspaces.c
+++ b/src/workspaces.c
@@ -454,7 +454,7 @@ workspaceSetCount (ScreenInfo * screen_info, guint count)
         workspaceSwitch (screen_info, count - 1, NULL, TRUE, myDisplayGetCurrentTime (display_info));
     }
     setNetWorkarea (display_info, screen_info->xroot, screen_info->workspace_count,
-                    screen_info->width, screen_info->height, screen_info->margins);
+                    screen_info->logical_width, screen_info->logical_height, screen_info->margins);
     /* Recompute the layout based on the (changed) number of desktops */
     getDesktopLayout (display_info, screen_info->xroot, screen_info->workspace_count,
                      &screen_info->desktop_layout);
@@ -575,7 +575,7 @@ workspaceUpdateArea (ScreenInfo *screen_info)
             if(c->struts[STRUTS_BOTTOM])
             {
                 struttmp.x = c->struts[STRUTS_BOTTOM_START_X];
-                struttmp.y = screen_info->height - c->struts[STRUTS_BOTTOM];
+                struttmp.y = screen_info->logical_height - c->struts[STRUTS_BOTTOM];
                 struttmp.width = c->struts[STRUTS_BOTTOM_END_X] - c->struts[STRUTS_BOTTOM_START_X];
                 struttmp.height = c->struts[STRUTS_BOTTOM];
 
@@ -596,7 +596,7 @@ workspaceUpdateArea (ScreenInfo *screen_info)
 
             if(c->struts[STRUTS_RIGHT])
             {
-                struttmp.x = screen_info->width - c->struts[STRUTS_RIGHT];
+                struttmp.x = screen_info->logical_width - c->struts[STRUTS_RIGHT];
                 struttmp.y = c->struts[STRUTS_RIGHT_START_Y];
                 struttmp.width = c->struts[STRUTS_RIGHT];
                 struttmp.height = c->struts[STRUTS_RIGHT_END_Y] - c->struts[STRUTS_RIGHT_START_Y];
@@ -618,7 +618,7 @@ workspaceUpdateArea (ScreenInfo *screen_info)
     {
         TRACE ("Margins have changed, updating net_workarea");
         setNetWorkarea (display_info, screen_info->xroot, screen_info->workspace_count,
-                        screen_info->width, screen_info->height, screen_info->margins);
+                        screen_info->logical_width, screen_info->logical_height, screen_info->margins);
         /* Also prevent windows from being off screen, just like when screen is resized */
         clientScreenResize(screen_info, FALSE);
     }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list