[Xfce4-commits] [xfce/xfwm4] 03/03: Set maximum valid struts values

noreply at xfce.org noreply at xfce.org
Sat Feb 28 00:00:17 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 58f9f51d1f438dcaa208937314c9d61bb33d1574
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Fri Feb 27 23:56:46 2015 +0100

    Set maximum valid struts values
    
    Some app set some insane value for struts or partial
    struts, set a maximum to be 25% of output size, and
    ignore the strut otherwise.
    
    Not ideal, but better that nothing.
    
    Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
---
 src/placement.c |   28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/placement.c b/src/placement.c
index 6b87d17..cae55ac 100644
--- a/src/placement.c
+++ b/src/placement.c
@@ -38,6 +38,7 @@
 #include "frame.h"
 #include "netwm.h"
 
+#define MAX_VALID_STRUT(n) (n / 4) /* 25% of available space */
 
 /* Compute rectangle overlap area */
 
@@ -102,12 +103,15 @@ clientMaxSpace (ScreenInfo *screen_info, int *x, int *y, int *w, int *h)
     Client *c2;
     guint i;
     gint delta, screen_width, screen_height;
+    gint original_w, original_h;
 
     g_return_if_fail (x != NULL);
     g_return_if_fail (y != NULL);
     g_return_if_fail (w != NULL);
     g_return_if_fail (h != NULL);
 
+    original_w = *w;
+    original_h = *h;
     screen_width = 0;
     screen_height = 0;
     delta = 0;
@@ -125,8 +129,11 @@ clientMaxSpace (ScreenInfo *screen_info, int *x, int *y, int *w, int *h)
                          0, c2->struts[STRUTS_LEFT_START_Y], c2->struts[STRUTS_LEFT], c2->struts[STRUTS_LEFT_END_Y]))
             {
                 delta = c2->struts[STRUTS_LEFT] - *x;
-                *x = *x + delta;
-                *w = *w - delta;
+                if (delta < MAX_VALID_STRUT(original_w))
+                {
+                    *x = *x + delta;
+                    *w = *w - delta;
+                }
             }
 
             /* Right */
@@ -135,7 +142,10 @@ clientMaxSpace (ScreenInfo *screen_info, int *x, int *y, int *w, int *h)
                          screen_width, c2->struts[STRUTS_RIGHT_END_Y]))
             {
                 delta = (*x + *w) - screen_width + c2->struts[STRUTS_RIGHT];
-                *w = *w - delta;
+                if (delta < MAX_VALID_STRUT(original_w))
+                {
+                    *w = *w - delta;
+                }
             }
 
             /* Top */
@@ -143,8 +153,11 @@ clientMaxSpace (ScreenInfo *screen_info, int *x, int *y, int *w, int *h)
                          c2->struts[STRUTS_TOP_START_X], 0, c2->struts[STRUTS_TOP_END_X], c2->struts[STRUTS_TOP]))
             {
                 delta = c2->struts[STRUTS_TOP] - *y;
-                *y = *y + delta;
-                *h = *h - delta;
+                if (delta < MAX_VALID_STRUT(original_h))
+                {
+                    *y = *y + delta;
+                    *h = *h - delta;
+                }
             }
 
             /* Bottom */
@@ -153,7 +166,10 @@ clientMaxSpace (ScreenInfo *screen_info, int *x, int *y, int *w, int *h)
                          c2->struts[STRUTS_BOTTOM_END_X], screen_height))
             {
                 delta = (*y + *h) - screen_height + c2->struts[STRUTS_BOTTOM];
-                *h = *h - delta;
+                if (delta < MAX_VALID_STRUT(original_h))
+                {
+                    *h = *h - delta;
+                }
             }
         }
     }

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


More information about the Xfce4-commits mailing list