[Xfce4-commits] [xfce/xfwm4] 01/01: placement: Relocate dialogs only

noreply at xfce.org noreply at xfce.org
Tue Jun 7 08:31:40 CEST 2016


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

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

commit 6b94d5a212772d4015769a4e4ad83f62478b0bc3
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Fri May 27 17:35:42 2016 +0200

    placement: Relocate dialogs only
    
    Bug: 12587
    
    Relocating any window on the current monitor in multi-monitor setup
    when centered can cause issues with Citrix.
    
    Relocate only dialogs, and when not the exact same size as the screen.
    
    Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
---
 src/placement.c | 63 ++++++++++++++++++++++++---------------------------------
 1 file changed, 26 insertions(+), 37 deletions(-)

diff --git a/src/placement.c b/src/placement.c
index 7b0ca22..e9a32c7 100644
--- a/src/placement.c
+++ b/src/placement.c
@@ -472,10 +472,8 @@ static void
 clientKeepVisible (Client * c, gint n_monitors, GdkRectangle *monitor_rect)
 {
     ScreenInfo *screen_info;
-    GdkRectangle rect;
     gboolean centered;
     int diff_x, diff_y;
-    int monitor_nbr;
 
     g_return_if_fail (c != NULL);
     TRACE ("entering clientKeepVisible");
@@ -484,27 +482,20 @@ clientKeepVisible (Client * c, gint n_monitors, GdkRectangle *monitor_rect)
     screen_info = c->screen_info;
 
     centered = FALSE;
-    if ((c->size->x == 0) && (c->size->y == 0) && (c->type & (WINDOW_TYPE_DIALOG)))
-    {
-        /* Dialogs that place temselves in (0,0) will be centered */
-        centered = TRUE;
-    }
-    else if (n_monitors > 1)
+    /* We only center dialogs */
+    if (c->type & (WINDOW_TYPE_DIALOG))
     {
-        /* First, check if the window is centered on the whole screen */
-        diff_x = abs (c->size->x - ((c->screen_info->width - c->size->width) / 2));
-        diff_y = abs (c->size->y - ((c->screen_info->height - c->size->height) / 2));
-
-        monitor_nbr = 0;
-        centered = ((diff_x < 25) && (diff_y < 25));
-
-        while ((!centered) && (monitor_nbr < n_monitors))
+        if ((c->size->x == 0) && (c->size->y == 0))
         {
-            gdk_screen_get_monitor_geometry (screen_info->gscr, monitor_nbr, &rect);
-            diff_x = abs (c->size->x - ((rect.width - c->size->width) / 2));
-            diff_y = abs (c->size->y - ((rect.height - c->size->height) / 2));
+            /* Dialogs that place temselves in (0,0) will be centered */
+            centered = TRUE;
+        }
+        else if ((n_monitors > 1) && (c->size->x > 0) && (c->size->y > 0))
+        {
+            /* Check if the window is centered on the whole screen */
+            diff_x = ABS(c->size->x - ((c->screen_info->width - c->size->width) / 2));
+            diff_y = ABS(c->size->y - ((c->screen_info->height - c->size->height) / 2));
             centered = ((diff_x < 25) && (diff_y < 25));
-            monitor_nbr++;
         }
     }
     if (centered)
@@ -769,6 +760,7 @@ clientInitPosition (Client * c)
     gint n_monitors;
     gboolean place;
     gboolean position;
+    gboolean is_transient;
 
     g_return_if_fail (c != NULL);
     TRACE ("entering clientInitPosition");
@@ -779,30 +771,25 @@ clientInitPosition (Client * c)
     position = (c->size->flags & (PPosition | USPosition));
 
     n_monitors = myScreenGetNumMonitors (c->screen_info);
-    if ((n_monitors > 1) || (screen_info->params->placement_mode == PLACE_MOUSE))
-    {
-        getMouseXY (screen_info, screen_info->xroot, &msx, &msy);
-        myScreenFindMonitorAtPoint (screen_info, msx, msy, &rect);
-    }
-    else
-    {
-        gdk_screen_get_monitor_geometry (screen_info->gscr, 0, &rect);
-    }
-    if (position || (c->type & (WINDOW_TYPE_DONT_PLACE | WINDOW_TYPE_DIALOG)) || clientIsTransient (c))
+    gdk_screen_get_monitor_geometry (screen_info->gscr, 0, &rect);
+    is_transient = clientIsTransient (c);
+
+    if (position || is_transient || (c->type & (WINDOW_TYPE_DONT_PLACE | WINDOW_TYPE_DIALOG)))
     {
-        if (!position && clientIsTransient (c) && (c2 = clientGetTransient (c)))
+        if (!position && is_transient && (c2 = clientGetTransient (c)))
         {
             /* Center transient relative to their parent window */
             c->x = c2->x + (c2->width - c->width) / 2;
             c->y = c2->y + (c2->height - c->height) / 2;
+        }
 
-            if (n_monitors > 1)
-            {
-                msx = frameExtentX (c) + (frameExtentWidth (c) / 2);
-                msy = frameExtentY (c) + (frameExtentHeight (c) / 2);
-                myScreenFindMonitorAtPoint (screen_info, msx, msy, &rect);
-            }
+        if (n_monitors > 1)
+        {
+            msx = frameExtentX (c) + (frameExtentWidth (c) / 2);
+            msy = frameExtentY (c) + (frameExtentHeight (c) / 2);
+            myScreenFindMonitorAtPoint (screen_info, msx, msy, &rect);
         }
+
         if (CONSTRAINED_WINDOW (c))
         {
             clientKeepVisible (c, n_monitors, &rect);
@@ -811,6 +798,8 @@ clientInitPosition (Client * c)
     }
     else
     {
+        getMouseXY (screen_info, screen_info->xroot, &msx, &msy);
+        myScreenFindMonitorAtPoint (screen_info, msx, msy, &rect);
         place = TRUE;
     }
 

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


More information about the Xfce4-commits mailing list