Skip to content

Commit 301bfc4

Browse files
committed
Support X11
1 parent 3f33900 commit 301bfc4

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

background/BackgroundWindow.vala

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,17 @@ public class Gala.Background.BackgroundWindow : Gtk.Window, PantheonWayland.Exte
6363

6464
child.realize.connect (() => {
6565
connect_to_shell ();
66-
get_surface ().notify["scale"].connect (setup_size);
66+
get_surface ().notify["scale"].connect (update_size);
6767
});
6868

6969
map.connect (() => {
70-
make_background (monitor_index);
71-
setup_size ();
70+
if (get_surface () is Gdk.Wayland.Surface) {
71+
make_background (monitor_index);
72+
} else {
73+
make_background_x11 ();
74+
}
75+
76+
update_size ();
7277
});
7378

7479
var gesture = new Gtk.GestureClick () {
@@ -90,7 +95,7 @@ public class Gala.Background.BackgroundWindow : Gtk.Window, PantheonWayland.Exte
9095
present ();
9196
}
9297

93-
private void setup_size () {
98+
private void update_size () {
9499
var monitor = Gdk.Display.get_default ().get_monitor_at_surface (get_surface ());
95100
var geom = monitor.get_geometry ();
96101

@@ -126,6 +131,26 @@ public class Gala.Background.BackgroundWindow : Gtk.Window, PantheonWayland.Exte
126131
animation.play ();
127132
}
128133

134+
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+
139+
unowned var xdisplay = ((Gdk.X11.Display) display).get_xdisplay ();
140+
141+
unowned var x_window = ((Gdk.X11.Surface) get_surface ()).get_xid ();
142+
143+
var atom = xdisplay.intern_atom ("_NET_WM_WINDOW_TYPE", false);
144+
var dock_atom = xdisplay.intern_atom ("_NET_WM_WINDOW_TYPE_DESKTOP", false);
145+
146+
// (X.Atom) 4 is XA_ATOM
147+
// 32 is format
148+
// 0 means replace
149+
xdisplay.change_property (x_window, atom, (X.Atom) 4, 32, 0, (uchar[]) dock_atom, 1);
150+
151+
xdisplay.move_window (x_window, geom.x, geom.y);
152+
}
153+
129154
private static void action_launch (SimpleAction action, Variant? variant) {
130155
try {
131156
AppInfo.launch_default_for_uri (variant.get_string (), null);

background/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ executable(
1010
'io.elementary.desktop.background',
1111
background_sources,
1212
gala_resources,
13-
dependencies: [config_dep, granite_dep, gtk4_dep, dependency('pantheon-wayland-1'), m_dep, dependency('libadwaita-1'), dependency('gnome-desktop-4'), dependency('gnome-bg-4')],
13+
dependencies: [config_dep, granite_dep, gtk4_dep, dependency('pantheon-wayland-1'), m_dep, dependency('libadwaita-1'), dependency('gnome-desktop-4'), dependency('gnome-bg-4'), dependency ('gtk4-wayland'), dependency('gtk4-x11')],
1414
include_directories: config_inc_dir,
1515
install: true,
1616
)

0 commit comments

Comments
 (0)