Fix multitasking view on x and improve comment

This commit is contained in:
Leonhard Kargl 2024-10-09 23:31:12 +02:00
parent 301bfc4650
commit 17b88e10b3
2 changed files with 19 additions and 9 deletions

View File

@ -132,13 +132,9 @@ public class Gala.Background.BackgroundWindow : Gtk.Window, PantheonWayland.Exte
}
private void make_background_x11 () {
var monitor = (Gdk.X11.Monitor) Gdk.Display.get_default ().get_monitors ().get_item (monitor_index);
var geom = monitor.geometry;
unowned var xdisplay = ((Gdk.X11.Display) display).get_xdisplay ();
unowned var x_window = ((Gdk.X11.Surface) get_surface ()).get_xid ();
unowned var xwindow = ((Gdk.X11.Surface) get_surface ()).get_xid ();
var atom = xdisplay.intern_atom ("_NET_WM_WINDOW_TYPE", false);
var dock_atom = xdisplay.intern_atom ("_NET_WM_WINDOW_TYPE_DESKTOP", false);
@ -146,9 +142,13 @@ public class Gala.Background.BackgroundWindow : Gtk.Window, PantheonWayland.Exte
// (X.Atom) 4 is XA_ATOM
// 32 is format
// 0 means replace
xdisplay.change_property (x_window, atom, (X.Atom) 4, 32, 0, (uchar[]) dock_atom, 1);
xdisplay.change_property (xwindow, atom, (X.Atom) 4, 32, 0, (uchar[]) dock_atom, 1);
xdisplay.move_window (x_window, geom.x, geom.y);
var mutter_prop = xdisplay.intern_atom ("_MUTTER_HINTS", false);
var mutter_prop_value = "monitor-index=%d".printf (monitor_index);
xdisplay.change_property (xwindow, mutter_prop, X.XA_STRING, 8, 0, (uchar[]) mutter_prop_value, mutter_prop_value.length);
}
private static void action_launch (SimpleAction action, Variant? variant) {

View File

@ -229,8 +229,9 @@ public class Gala.ShellClientsManager : Object {
}
/**
* This clone will be valid until Meta.MonitorManager::monitors-changed was emitted.
* After that the clone musn't be used. This will only return null if the monitor_index is out of bounds.
* This clone will be valid until monitor_index goes out of bounds (i.e. enough monitors were disconnected
* so that the number of monitors <= monitor_index). After that the clone musn't be used.
* This will only return null if the monitor_index is out of bounds.
*/
public Clutter.Actor? get_background_clone_for_monitor (int monitor_index) {
if (monitor_index < 0 || monitor_index > background_windows.length) {
@ -307,6 +308,15 @@ public class Gala.ShellClientsManager : Object {
make_centered (window);
break;
case "monitor-index":
int parsed; // Will be used as Pantheon.Desktop.HideMode which is a 5 value enum so check bounds for that
if (int.try_parse (val, out parsed)) {
make_background (window, parsed);
} else {
warning ("Failed to parse %s as monitor index", val);
}
break;
default:
break;
}