From 875fa132190c970ece1da4cce2b76f85619da4a9 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 27 May 2016 17:35:42 +0200 Subject: [PATCH] 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 --- src/placement.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/placement.c b/src/placement.c index 7b0ca22..c4dea34 100644 --- a/src/placement.c +++ b/src/placement.c @@ -484,27 +484,31 @@ 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))) + /* We only center dialogs */ + if (c->type & (WINDOW_TYPE_DIALOG)) { - /* Dialogs that place temselves in (0,0) will be centered */ - centered = TRUE; - } - else if (n_monitors > 1) - { - /* 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)); + if ((c->size->x == 0) && (c->size->y == 0)) + { + /* Dialogs that place temselves in (0,0) will be centered */ + centered = TRUE; + } + else if (n_monitors > 1) + { + /* First, check if the window is centered on the whole screen */ + diff_x = c->size->x - ((c->screen_info->width - c->size->width) / 2); + diff_y = c->size->y - ((c->screen_info->height - c->size->height) / 2); - monitor_nbr = 0; - centered = ((diff_x < 25) && (diff_y < 25)); + monitor_nbr = 0; + centered = ((diff_x > 0) && (diff_y > 0) && (diff_x < 25) && (diff_y < 25)); - while ((!centered) && (monitor_nbr < n_monitors)) - { - 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)); - centered = ((diff_x < 25) && (diff_y < 25)); - monitor_nbr++; + while ((!centered) && (monitor_nbr < n_monitors)) + { + gdk_screen_get_monitor_geometry (screen_info->gscr, monitor_nbr, &rect); + diff_x = c->size->x - ((rect.width - c->size->width) / 2); + diff_y = c->size->y - ((rect.height - c->size->height) / 2); + centered = ((diff_x > 0) && (diff_y > 0) && (diff_x < 25) && (diff_y < 25)); + monitor_nbr++; + } } } if (centered) -- 2.7.4