From 967b6c33df5716255f4dc1105de9dbb7a1aad1b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 20 Jun 2014 18:06:40 +0200 Subject: [PATCH] window: Add user_op parameter to update_monitor() When workspaces-only-on-primary is set and a window is moved back to the primary, we also move it to the active workspace to avoid the confusion of a visible window suddenly disappearing when crossing the monitor border. However when the window is not actually moved by the user, preserving the workspace makes more sense - we already do this in some cases (e.g. when moving between primary monitors), but miss others (unplugging the previous monitor); just add an explicit user_op parameter as used elsewhere to cover all exceptions. https://bugzilla.gnome.org/show_bug.cgi?id=731760 --- src/core/window-private.h | 3 ++- src/core/window.c | 25 +++++++++++-------------- src/x11/window-x11.c | 2 +- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/core/window-private.h b/src/core/window-private.h index cfc000ab8..3cd326332 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -690,7 +690,8 @@ void meta_window_activate_full (MetaWindow *window, gboolean meta_window_is_client_decorated (MetaWindow *window); -void meta_window_update_monitor (MetaWindow *window); +void meta_window_update_monitor (MetaWindow *window, + gboolean user_op); void meta_window_set_urgent (MetaWindow *window, gboolean urgent); diff --git a/src/core/window.c b/src/core/window.c index 9bb7d32b0..e98b287ad 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -3579,7 +3579,7 @@ meta_window_update_for_monitors_changed (MetaWindow *window) if (window->override_redirect) { - meta_window_update_monitor (window); + meta_window_update_monitor (window, FALSE); return; } @@ -3612,7 +3612,8 @@ meta_window_update_for_monitors_changed (MetaWindow *window) } void -meta_window_update_monitor (MetaWindow *window) +meta_window_update_monitor (MetaWindow *window, + gboolean user_op) { const MetaMonitorInfo *old; @@ -3622,22 +3623,17 @@ meta_window_update_monitor (MetaWindow *window) { meta_window_update_on_all_workspaces (window); - /* If workspaces only on primary and we moved back to primary, ensure that the - * window is now in that workspace. We do this because while the window is on a - * non-primary monitor it is always visible, so it would be very jarring if it - * disappeared when it crossed the monitor border. + /* If workspaces only on primary and we moved back to primary due to a user action, + * ensure that the window is now in that workspace. We do this because while + * the window is on a non-primary monitor it is always visible, so it would be + * very jarring if it disappeared when it crossed the monitor border. * The one time we want it to both change to the primary monitor and a non-active * workspace is when dropping the window on some other workspace thumbnail directly. * That should be handled by explicitly moving the window before changing the - * workspace - * Don't do this if old == NULL, because thats what happens when starting up, and - * we don't want to move all windows around from a previous WM instance. Nor do - * we want it when moving from one primary monitor to another (can happen during - * screen reconfiguration. + * workspace. */ - if (meta_prefs_get_workspaces_only_on_primary () && + if (meta_prefs_get_workspaces_only_on_primary () && user_op && meta_window_is_on_primary_monitor (window) && - old != NULL && !old->is_primary && window->screen->active_workspace != window->workspace) meta_window_change_workspace (window, window->screen->active_workspace); @@ -3648,6 +3644,7 @@ meta_window_update_monitor (MetaWindow *window) /* If we're changing monitors, we need to update the has_maximize_func flag, * as the working area has changed. */ meta_window_recalc_features (window); + meta_window_queue (window, META_QUEUE_CALC_SHOWING); } } @@ -3764,7 +3761,7 @@ meta_window_move_resize_internal (MetaWindow *window, old_output_id = window->monitor->output_id; - meta_window_update_monitor (window); + meta_window_update_monitor (window, flags & META_IS_USER_ACTION); if (old_output_id != window->monitor->output_id && flags & META_IS_MOVE_ACTION && flags & META_IS_USER_ACTION) diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 2def97a65..e8c279f6d 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -3271,7 +3271,7 @@ meta_window_x11_configure_notify (MetaWindow *window, priv->client_rect = window->rect; window->buffer_rect = window->rect; - meta_window_update_monitor (window); + meta_window_update_monitor (window, FALSE); /* Whether an override-redirect window is considered fullscreen depends * on its geometry.