diff --git a/src/DBus.vala b/src/DBus.vala index e474c1dc0..51eb6d24f 100644 --- a/src/DBus.vala +++ b/src/DBus.vala @@ -19,10 +19,10 @@ namespace Gala { [DBus (name="org.pantheon.gala")] public class DBus { private static DBus? instance; - private static WindowManager wm; + private static WindowManagerGala wm; [DBus (visible = false)] - public static void init (WindowManager _wm) { + public static void init (WindowManagerGala _wm) { wm = _wm; Bus.own_name (BusType.SESSION, "org.pantheon.gala", BusNameOwnerFlags.NONE, @@ -65,19 +65,14 @@ namespace Gala { () => {}, () => critical ("Could not acquire name") ); - unowned WindowManagerGala? gala_wm = wm as WindowManagerGala; - if (gala_wm != null) { - var screensaver_manager = gala_wm.screensaver; - - Bus.own_name (BusType.SESSION, "org.gnome.ScreenSaver", BusNameOwnerFlags.REPLACE, - (connection) => { - try { - connection.register_object ("/org/gnome/ScreenSaver", screensaver_manager); - } catch (Error e) { warning (e.message); } - }, - () => {}, - () => critical ("Could not acquire ScreenSaver bus") ); - } + Bus.own_name (BusType.SESSION, "org.gnome.ScreenSaver", BusNameOwnerFlags.REPLACE, + (connection) => { + try { + connection.register_object ("/org/gnome/ScreenSaver", wm.screensaver); + } catch (Error e) { warning (e.message); } + }, + () => {}, + () => critical ("Could not acquire ScreenSaver bus") ); } private DBus () { diff --git a/src/DesktopIntegration.vala b/src/DesktopIntegration.vala index 2b701b902..6cadb6177 100644 --- a/src/DesktopIntegration.vala +++ b/src/DesktopIntegration.vala @@ -16,17 +16,14 @@ public class Gala.DesktopIntegration : GLib.Object { GLib.HashTable properties; } - private unowned WindowManager wm; + private unowned WindowManagerGala wm; public uint version { get; default = 1; } public signal void running_applications_changed (); public signal void windows_changed (); - public DesktopIntegration (WindowManager wm) { + public DesktopIntegration (WindowManagerGala wm) { this.wm = wm; - unowned WindowManagerGala? gala_wm = wm as WindowManagerGala; - if (gala_wm != null) { - gala_wm.window_tracker.windows_changed.connect (() => windows_changed ()); - } + wm.window_tracker.windows_changed.connect (() => windows_changed ()); } public RunningApplication[] get_running_applications () throws GLib.DBusError, GLib.IOError { @@ -102,4 +99,21 @@ public class Gala.DesktopIntegration : GLib.Object { return (owned) returned_windows; } + + public void show_windows_for (string app_id) throws IOError, DBusError { + App app; + if ((app = AppSystem.get_default ().lookup_app (app_id)) == null) { + throw new IOError.NOT_FOUND ("App not found"); + } + + uint64[] window_ids = {}; + foreach (var window in app.get_windows ()) { + window_ids += window.get_id (); + } + + var hash_table = new HashTable (str_hash, str_equal); + hash_table["windows"] = window_ids; + + wm.show_window_spread (hash_table); + } } diff --git a/src/Widgets/WindowOverview.vala b/src/Widgets/WindowOverview.vala index 627b14544..8099c714e 100644 --- a/src/Widgets/WindowOverview.vala +++ b/src/Widgets/WindowOverview.vala @@ -16,6 +16,7 @@ public class Gala.WindowOverview : Clutter.Actor, ActivatableComponent { // the workspaces which we expose right now private List workspaces; + private List minimized_windows; public WindowOverview (WindowManager wm) { Object (wm : wm); @@ -75,6 +76,12 @@ public class Gala.WindowOverview : Clutter.Actor, ActivatableComponent { workspaces.append (workspace); } + uint64[]? window_ids = null; + if (hints != null && "windows" in hints) { + window_ids = (uint64[]) hints["windows"]; + } + + minimized_windows = new List (); var windows = new List (); foreach (var workspace in workspaces) { foreach (unowned var window in workspace.list_windows ()) { @@ -85,13 +92,22 @@ public class Gala.WindowOverview : Clutter.Actor, ActivatableComponent { if (window.window_type != Meta.WindowType.NORMAL && window.window_type != Meta.WindowType.DIALOG || - window.is_attached_dialog ()) { + window.is_attached_dialog () + ) { unowned var actor = (Meta.WindowActor) window.get_compositor_private (); actor.hide (); continue; } + if (window_ids != null && !(window.get_id () in window_ids)) { + if (!window.minimized) { + window.minimize (); + minimized_windows.append (window); + } + continue; + } + // skip windows that are on all workspace except we're currently // processing the workspace it actually belongs to if (window.on_all_workspaces && window.get_workspace () != workspace) { @@ -272,6 +288,10 @@ public class Gala.WindowOverview : Clutter.Actor, ActivatableComponent { ((WindowCloneContainer) child).close (); } + foreach (var window in minimized_windows) { + window.unminimize (); + } + Clutter.Threads.Timeout.add (MultitaskingView.ANIMATION_DURATION, () => { cleanup (); diff --git a/src/WindowManager.vala b/src/WindowManager.vala index b44536497..82832acb2 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -72,7 +72,7 @@ namespace Gala { private Meta.PluginInfo info; private WindowSwitcher? window_switcher = null; - private ActivatableComponent? window_overview = null; + public ActivatableComponent? window_overview = null; public ScreenSaverManager? screensaver { get; private set; } @@ -2427,6 +2427,14 @@ namespace Gala { new_parent.add_child (actor); actor.unref (); } + + public void show_window_spread (HashTable? hints = null) { + if (window_overview.is_opened ()) { + window_overview.close (); + } + + window_overview.open (hints); + } } [CCode (cname="clutter_x11_get_stage_window")]