From 7f92770f1f24463650641d5a0e66b32b1402f03b Mon Sep 17 00:00:00 2001 From: Leonhard Date: Sat, 4 Jan 2025 16:10:48 +0100 Subject: [PATCH] Add fullscreen effect and move to old ws on close (#2194) Co-authored-by: Leo --- data/gala.metainfo.xml.in | 2 ++ src/WindowManager.vala | 63 ++++++++------------------------------- 2 files changed, 14 insertions(+), 51 deletions(-) diff --git a/data/gala.metainfo.xml.in b/data/gala.metainfo.xml.in index 065164995..4af463b64 100644 --- a/data/gala.metainfo.xml.in +++ b/data/gala.metainfo.xml.in @@ -39,8 +39,10 @@ Prevent PIP overlapping wingpanel? + Return to original workspace if a fullscreen window is closed and there is no more windows open Toggling the active window's maximization state during multitasking view messes up the window preview size Some apps ignore HiDPI mode + Does not return to the first virtual desktop after exiting fullscreen mode. Invisible window clones gnome-session-x11-services-ready.target isn't started on Wayland session Unthemed cursor style and glitchy menus on some applications diff --git a/src/WindowManager.vala b/src/WindowManager.vala index 6d26f39c2..563a9879e 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -1168,50 +1168,6 @@ namespace Gala { * effects */ - private void handle_fullscreen_window (Meta.Window window, Meta.SizeChange which_change) { - // Only handle windows which are located on the primary monitor - if (!window.is_on_primary_monitor () || !behavior_settings.get_boolean ("move-fullscreened-workspace")) - return; - - // Due to how this is implemented, by relying on the functionality - // offered by the dynamic workspace handler, let's just bail out - // if that's not available. - if (!Meta.Prefs.get_dynamic_workspaces ()) - return; - - unowned Meta.Display display = get_display (); - var time = display.get_current_time (); - unowned Meta.Workspace win_ws = window.get_workspace (); - unowned Meta.WorkspaceManager manager = display.get_workspace_manager (); - - if (which_change == Meta.SizeChange.FULLSCREEN) { - // Do nothing if the current workspace would be empty - if (Utils.get_n_windows (win_ws) <= 1) - return; - - var old_ws_index = win_ws.index (); - var new_ws_index = old_ws_index + 1; - InternalUtils.insert_workspace_with_window (new_ws_index, window); - - unowned var new_ws = manager.get_workspace_by_index (new_ws_index); - window.change_workspace (new_ws); - new_ws.activate_with_focus (window, time); - - ws_assoc.insert (window, old_ws_index); - } else if (ws_assoc.contains (window)) { - var old_ws_index = ws_assoc.get (window); - var new_ws_index = win_ws.index (); - - if (new_ws_index != old_ws_index && old_ws_index < manager.get_n_workspaces ()) { - unowned var old_ws = manager.get_workspace_by_index (old_ws_index); - window.change_workspace (old_ws); - old_ws.activate_with_focus (window, time); - } - - ws_assoc.remove (window); - } - } - // must wait for size_changed to get updated frame_rect // as which_change is not passed to size_changed, save it as instance variable #if HAS_MUTTER45 @@ -1257,8 +1213,10 @@ namespace Gala { unmaximize (actor, new_rect.x, new_rect.y, new_rect.width, new_rect.height); break; case Meta.SizeChange.FULLSCREEN: + maximize (actor, new_rect.x, new_rect.y, new_rect.width, new_rect.height); + break; case Meta.SizeChange.UNFULLSCREEN: - handle_fullscreen_window (window, which_change_local); + unmaximize (actor, new_rect.x, new_rect.y, new_rect.width, new_rect.height); break; default: break; @@ -1347,7 +1305,8 @@ namespace Gala { kill_window_effects (actor); unowned var window = actor.get_meta_window (); - if (window.maximized_horizontally && behavior_settings.get_boolean ("move-maximized-workspace")) { + if (window.maximized_horizontally && behavior_settings.get_boolean ("move-maximized-workspace") + || window.fullscreen && behavior_settings.get_boolean ("move-fullscreened-workspace")) { move_window_to_next_ws (window); } @@ -1605,8 +1564,6 @@ namespace Gala { public override void destroy (Meta.WindowActor actor) { unowned var window = actor.get_meta_window (); - ws_assoc.remove (window); - actor.remove_all_transitions (); if (NotificationStack.is_notification (window)) { @@ -1728,9 +1685,7 @@ namespace Gala { kill_window_effects (actor); unowned var window = actor.get_meta_window (); - if (behavior_settings.get_boolean ("move-maximized-workspace")) { - move_window_to_old_ws (window); - } + move_window_to_old_ws (window); if (window.window_type == Meta.WindowType.NORMAL) { float offset_x, offset_y; @@ -1820,6 +1775,10 @@ namespace Gala { window.change_workspace (new_ws); new_ws.activate_with_focus (window, time); + if (!(window in ws_assoc)) { + window.unmanaged.connect (move_window_to_old_ws); + } + ws_assoc[window] = old_ws_index; } @@ -1848,6 +1807,8 @@ namespace Gala { } ws_assoc.remove (window); + + window.unmanaged.disconnect (move_window_to_old_ws); } // Cancel attached animation of an actor and reset it