diff options
author | Olivier Fourdan <fourdan@xfce.org> | 2016-05-27 17:35:42 +0200 |
---|---|---|
committer | Olivier Fourdan <fourdan@xfce.org> | 2016-06-07 08:31:08 +0200 |
commit | eacc942a0698bd6103e43fd711de08773634f9c8 (patch) | |
tree | 5bf75f88118746b70df930b01a3fc389bb8d972b /src | |
parent | a66589442a709507879fa455cac4f346326f4ee0 (diff) | |
download | xfwm4-eacc942a0698bd6103e43fd711de08773634f9c8.tar.gz |
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@xfce.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/placement.c | 63 |
1 files changed, 26 insertions, 37 deletions
diff --git a/src/placement.c b/src/placement.c index 7b0ca22a6..e9a32c72a 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; } |