Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add window spread for an app #1833

Merged
merged 5 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions src/DBus.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 () {
Expand Down
26 changes: 20 additions & 6 deletions src/DesktopIntegration.vala
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@ public class Gala.DesktopIntegration : GLib.Object {
GLib.HashTable<unowned string, Variant> 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 {
Expand Down Expand Up @@ -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<string, Variant> (str_hash, str_equal);
hash_table["windows"] = window_ids;

wm.show_window_spread (hash_table);
}
}
9 changes: 8 additions & 1 deletion src/Widgets/WindowOverview.vala
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ 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"];
}

var windows = new List<Meta.Window> ();
foreach (var workspace in workspaces) {
foreach (unowned var window in workspace.list_windows ()) {
Expand All @@ -85,7 +90,9 @@ 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 () ||
(window_ids != null && !(window.get_id () in window_ids))
lenemter marked this conversation as resolved.
Show resolved Hide resolved
) {
unowned var actor = (Meta.WindowActor) window.get_compositor_private ();
actor.hide ();

Expand Down
8 changes: 8 additions & 0 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2427,6 +2427,14 @@ namespace Gala {
new_parent.add_child (actor);
actor.unref ();
}

public void show_window_spread (HashTable<string,Variant>? hints = null) {
if (window_overview.is_opened ()) {
window_overview.close ();
}

window_overview.open (hints);
}
leolost2605 marked this conversation as resolved.
Show resolved Hide resolved
}

[CCode (cname="clutter_x11_get_stage_window")]
Expand Down