Skip to content

Commit 9fee616

Browse files
leolost2605lenemter
authored andcommitted
WindowManager: Explicitly override window group of shell windows
1 parent a089a76 commit 9fee616

2 files changed

Lines changed: 61 additions & 29 deletions

File tree

src/ShellClients/ShellClientsManager.vala

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public class Gala.ShellClientsManager : Object, GestureTarget {
99
private static ShellClientsManager instance;
1010

11-
public static void init (WindowManager wm) {
11+
public static void init (WindowManagerGala wm) {
1212
if (instance != null) {
1313
return;
1414
}
@@ -20,7 +20,7 @@ public class Gala.ShellClientsManager : Object, GestureTarget {
2020
return instance;
2121
}
2222

23-
public WindowManager wm { get; construct; }
23+
public WindowManagerGala wm { get; construct; }
2424

2525
private NotificationsClient notifications_client;
2626
private ManagedClient[] protocol_clients = {};
@@ -31,7 +31,7 @@ public class Gala.ShellClientsManager : Object, GestureTarget {
3131
private GLib.HashTable<Meta.Window, ExtendedBehaviorWindow> positioned_windows = new GLib.HashTable<Meta.Window, ExtendedBehaviorWindow> (null, null);
3232
private GLib.HashTable<Meta.Window, MonitorLabelWindow> monitor_label_windows = new GLib.HashTable<Meta.Window, MonitorLabelWindow> (null, null);
3333

34-
private ShellClientsManager (WindowManager wm) {
34+
private ShellClientsManager (WindowManagerGala wm) {
3535
Object (wm: wm);
3636
}
3737

@@ -178,6 +178,8 @@ public class Gala.ShellClientsManager : Object, GestureTarget {
178178

179179
panel_windows[window] = new PanelWindow (wm, window, anchor);
180180

181+
wm.override_window_group (window, DESKTOP_SHELL);
182+
181183
InternalUtils.wait_for_window_actor_visible (window, on_panel_ready);
182184

183185
// connect_after so we make sure the PanelWindow can destroy its barriers and struts
@@ -243,6 +245,8 @@ public class Gala.ShellClientsManager : Object, GestureTarget {
243245

244246
public void make_modal (Meta.Window window, bool dim) requires (window in positioned_windows) {
245247
positioned_windows[window].make_modal (dim);
248+
249+
wm.override_window_group (window, MODAL);
246250
}
247251

248252
public void make_monitor_label (Meta.Window window, int monitor_index) requires (!is_itself_shell_window (window)) {
@@ -253,6 +257,8 @@ public class Gala.ShellClientsManager : Object, GestureTarget {
253257

254258
monitor_label_windows[window] = new MonitorLabelWindow (window, monitor_index);
255259

260+
wm.override_window_group (window, DESKTOP_SHELL);
261+
256262
// connect_after so we make sure that any queued move is unqueued
257263
window.unmanaging.connect_after ((_window) => monitor_label_windows.remove (_window));
258264
}
@@ -297,25 +303,10 @@ public class Gala.ShellClientsManager : Object, GestureTarget {
297303
return positioned;
298304
}
299305

300-
private bool is_itself_system_modal (Meta.Window window) {
301-
return (window in positioned_windows) && positioned_windows[window].modal;
302-
}
303-
304-
public bool is_system_modal_window (Meta.Window window) {
305-
var modal = is_itself_system_modal (window);
306-
window.foreach_ancestor ((ancestor) => {
307-
if (is_itself_system_modal (ancestor)) {
308-
modal = true;
309-
}
310-
311-
return !modal;
312-
});
313-
314-
return modal;
315-
}
316-
317-
public bool is_system_modal_dimmed (Meta.Window window) {
318-
return is_itself_system_modal (window) && positioned_windows[window].dim;
306+
public bool is_system_modal_dimmed (Meta.Window window) requires (
307+
window in positioned_windows && positioned_windows[window].modal
308+
) {
309+
return positioned_windows[window].dim;
319310
}
320311

321312
//X11 only

src/WindowManager.vala

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
namespace Gala {
2020
public class WindowManagerGala : Meta.Plugin, WindowManager {
21+
public enum WindowGroup {
22+
DESKTOP_SHELL,
23+
MODAL,
24+
}
25+
2126
private const string OPEN_MULTITASKING_VIEW = "dbus-send --session --dest=org.pantheon.gala --print-reply /org/pantheon/gala org.pantheon.gala.PerformAction int32:1";
2227
private const string OPEN_APPLICATIONS_MENU = "io.elementary.wingpanel --toggle-indicator=app-launcher";
2328

@@ -120,6 +125,8 @@ namespace Gala {
120125

121126
private GLib.Settings behavior_settings;
122127

128+
private Gee.Map<Meta.Window, WindowGroup> overridden_window_group = new Gee.HashMap<Meta.Window, WindowGroup> ();
129+
123130
construct {
124131
#if !HAS_MUTTER48
125132
info = Meta.PluginInfo () {name = "Gala", version = Config.VERSION, author = "Gala Developers",
@@ -1040,23 +1047,57 @@ namespace Gala {
10401047
show_window_menu (window, menu, rect.x, rect.y);
10411048
}
10421049

1050+
/**
1051+
* Tells the wm to place the {@link window} in the given {@link new_group} instead of the default
1052+
* window group as determined by the wm.
1053+
* The wm will also automatically place transient windows of {@link window} in the same group.
1054+
*/
1055+
public void override_window_group (Meta.Window window, WindowGroup new_group) {
1056+
overridden_window_group[window] = new_group;
1057+
window.unmanaged.connect ((_window) => overridden_window_group.unset (_window));
1058+
1059+
InternalUtils.wait_for_window_actor_visible (window, (actor) => {
1060+
InternalUtils.clutter_actor_reparent (actor, get_window_group_actor (new_group));
1061+
1062+
// FIXME: workaround for https://github.com/elementary/dock/issues/537
1063+
actor.set_scale (1.0, 1.0);
1064+
actor.opacity = 255;
1065+
});
1066+
}
1067+
1068+
private Clutter.Actor get_window_group_actor (WindowGroup group) {
1069+
switch (group) {
1070+
case DESKTOP_SHELL: return shell_group;
1071+
case MODAL: return modal_group.window_group;
1072+
default: assert_not_reached ();
1073+
}
1074+
}
1075+
10431076
private void check_shell_window (Meta.WindowActor actor) {
10441077
unowned var window = actor.get_meta_window ();
10451078

1046-
if (ShellClientsManager.get_instance ().is_system_modal_window (window)) {
1047-
InternalUtils.clutter_actor_reparent (actor, modal_group.window_group);
1079+
if (overridden_window_group.has_key (window)) {
1080+
/* We are already overridden so make sure to ignore it */
10481081
return;
10491082
}
10501083

1051-
if (ShellClientsManager.get_instance ().is_shell_window (window)) {
1052-
InternalUtils.clutter_actor_reparent (actor, shell_group);
1084+
/* Check if we're a transient of a window with an overridden group and if so place there */
1085+
window.foreach_ancestor ((ancestor) => {
1086+
if (overridden_window_group.has_key (ancestor)) {
1087+
override_window_group (window, overridden_window_group[ancestor]);
1088+
return false;
1089+
}
1090+
1091+
return true;
1092+
});
10531093

1054-
// FIXME: workaround for https://github.com/elementary/dock/issues/537
1055-
actor.set_scale (1.0, 1.0);
1056-
actor.opacity = 255;
1094+
if (overridden_window_group.has_key (window)) {
1095+
/* We found an ancestor with an overridden group so we are now being placed in the same group */
1096+
return;
10571097
}
10581098

10591099
if (NotificationStack.is_notification (window)) {
1100+
override_window_group (window, DESKTOP_SHELL);
10601101
notification_stack.show_notification (actor);
10611102
}
10621103

0 commit comments

Comments
 (0)