Skip to content

Commit 17b88e1

Browse files
committed
Fix multitasking view on x and improve comment
1 parent 301bfc4 commit 17b88e1

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

background/BackgroundWindow.vala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,23 @@ public class Gala.Background.BackgroundWindow : Gtk.Window, PantheonWayland.Exte
132132
}
133133

134134
private void make_background_x11 () {
135-
var monitor = (Gdk.X11.Monitor) Gdk.Display.get_default ().get_monitors ().get_item (monitor_index);
136-
137-
var geom = monitor.geometry;
138-
139135
unowned var xdisplay = ((Gdk.X11.Display) display).get_xdisplay ();
140136

141-
unowned var x_window = ((Gdk.X11.Surface) get_surface ()).get_xid ();
137+
unowned var xwindow = ((Gdk.X11.Surface) get_surface ()).get_xid ();
142138

143139
var atom = xdisplay.intern_atom ("_NET_WM_WINDOW_TYPE", false);
144140
var dock_atom = xdisplay.intern_atom ("_NET_WM_WINDOW_TYPE_DESKTOP", false);
145141

146142
// (X.Atom) 4 is XA_ATOM
147143
// 32 is format
148144
// 0 means replace
149-
xdisplay.change_property (x_window, atom, (X.Atom) 4, 32, 0, (uchar[]) dock_atom, 1);
145+
xdisplay.change_property (xwindow, atom, (X.Atom) 4, 32, 0, (uchar[]) dock_atom, 1);
146+
147+
var mutter_prop = xdisplay.intern_atom ("_MUTTER_HINTS", false);
148+
149+
var mutter_prop_value = "monitor-index=%d".printf (monitor_index);
150150

151-
xdisplay.move_window (x_window, geom.x, geom.y);
151+
xdisplay.change_property (xwindow, mutter_prop, X.XA_STRING, 8, 0, (uchar[]) mutter_prop_value, mutter_prop_value.length);
152152
}
153153

154154
private static void action_launch (SimpleAction action, Variant? variant) {

src/ShellClients/ShellClientsManager.vala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,9 @@ public class Gala.ShellClientsManager : Object {
229229
}
230230

231231
/**
232-
* This clone will be valid until Meta.MonitorManager::monitors-changed was emitted.
233-
* After that the clone musn't be used. This will only return null if the monitor_index is out of bounds.
232+
* This clone will be valid until monitor_index goes out of bounds (i.e. enough monitors were disconnected
233+
* so that the number of monitors <= monitor_index). After that the clone musn't be used.
234+
* This will only return null if the monitor_index is out of bounds.
234235
*/
235236
public Clutter.Actor? get_background_clone_for_monitor (int monitor_index) {
236237
if (monitor_index < 0 || monitor_index > background_windows.length) {
@@ -307,6 +308,15 @@ public class Gala.ShellClientsManager : Object {
307308
make_centered (window);
308309
break;
309310

311+
case "monitor-index":
312+
int parsed; // Will be used as Pantheon.Desktop.HideMode which is a 5 value enum so check bounds for that
313+
if (int.try_parse (val, out parsed)) {
314+
make_background (window, parsed);
315+
} else {
316+
warning ("Failed to parse %s as monitor index", val);
317+
}
318+
break;
319+
310320
default:
311321
break;
312322
}

0 commit comments

Comments
 (0)