33 * SPDX-FileCopyrightText: 2022-2025 elementary, Inc. (https://elementary.io)
44 */
55
6- public class Dock.MainWindow : Granite . BlurSurface , Gtk .ApplicationWindow {
6+ public class Dock.MainWindow : Gtk .ApplicationWindow {
77 private class Container : Gtk .Box {
88 class construct {
99 set_css_name ("dock ");
@@ -25,6 +25,7 @@ public class Dock.MainWindow : Granite.BlurSurface, Gtk.ApplicationWindow {
2525
2626 private Pantheon . Desktop . Shell ? desktop_shell;
2727 private Pantheon . Desktop . Panel ? panel;
28+ private PantheonBlur . Blur ? blur;
2829
2930 private Gtk . Box main_box;
3031 private int full_height = 0 ;
@@ -69,7 +70,7 @@ public class Dock.MainWindow : Granite.BlurSurface, Gtk.ApplicationWindow {
6970 if (panel != null ) {
7071 panel. set_hide_mode (settings. get_enum (" autohide-mode" ));
7172 } else {
72- update_real_x11_hints ();
73+ update_x11_hints ();
7374 }
7475 });
7576
@@ -90,25 +91,18 @@ public class Dock.MainWindow : Granite.BlurSurface, Gtk.ApplicationWindow {
9091 }
9192 }
9293
94+ private static Wl . RegistryListener registry_listener;
9395 private void init_panel () {
94- if (is_wayland ()) {
95- init_wayland (registry_handle_global);
96- } else {
97- update_real_x11_hints ();
98- }
99-
10096 get_surface (). layout. connect_after (() = > {
10197 var new_full_height = main_box. get_height ();
102-
10398 if (new_full_height != full_height) {
10499 full_height = new_full_height;
105100
106101 if (panel != null ) {
107102 panel. set_size (- 1 , full_height);
108103 } else {
109- update_real_x11_hints ();
104+ update_x11_hints ();
110105 }
111-
112106 }
113107
114108 unowned var item_manager = ItemManager . get_default ();
@@ -119,27 +113,39 @@ public class Dock.MainWindow : Granite.BlurSurface, Gtk.ApplicationWindow {
119113 visible_width = new_visible_width;
120114 visible_height = new_visible_height;
121115
122- if (is_wayland () ) {
123- request_blur_wayland (
116+ if (blur != null ) {
117+ blur . set_region (
124118 0 ,
125119 TOP_PADDING ,
126120 visible_width,
127121 visible_height,
128122 BORDER_RADIUS
129123 );
130124 } else {
131- update_real_x11_hints ();
125+ update_x11_hints ();
132126 }
133127 }
134128 });
135- }
136129
137- public void registry_handle_global (Wl .Registry wl_registry , uint32 name , string @interface , uint32 version ) {
138- panel_registry_handle_global (wl_registry, name, @interface, version);
139- blur_registry_handle_global (wl_registry, name, @interface, version);
130+ registry_listener. global = registry_handle_global;
131+ unowned var display = Gdk . Display . get_default ();
132+ if (display is Gdk . Wayland . Display ) {
133+ unowned var wl_display = ((Gdk . Wayland . Display ) display). get_wl_display ();
134+ var wl_registry = wl_display. get_registry ();
135+ wl_registry. add_listener (
136+ registry_listener,
137+ this
138+ );
139+
140+ if (wl_display. roundtrip () < 0 ) {
141+ return ;
142+ }
143+ } else {
144+ update_x11_hints ();
145+ }
140146 }
141147
142- public void panel_registry_handle_global (Wl .Registry wl_registry , uint32 name , string @interface , uint32 version ) {
148+ public void registry_handle_global (Wl .Registry wl_registry , uint32 name , string @interface , uint32 version ) {
143149 if (@interface == " io_elementary_pantheon_shell_v1" ) {
144150 desktop_shell = wl_registry. bind< Pantheon . Desktop . Shell > (name, ref Pantheon . Desktop . Shell . iface, uint32 . min (version, 1 ));
145151 unowned var surface = get_surface ();
@@ -149,24 +155,36 @@ public class Dock.MainWindow : Granite.BlurSurface, Gtk.ApplicationWindow {
149155 panel. set_anchor (BOTTOM );
150156 panel. set_hide_mode (settings. get_enum (" autohide-mode" ));
151157 }
158+ } else if (@interface == " io_elementary_pantheon_blur_manager_v1" ) {
159+ var blur_manager = wl_registry. bind< PantheonBlur . BlurManager > (name, ref PantheonBlur . BlurManager . iface, uint32 . min (version, 1 ));
160+ unowned var surface = get_surface ();
161+ if (surface is Gdk . Wayland . Surface ) {
162+ unowned var wl_surface = ((Gdk . Wayland . Surface ) surface). get_wl_surface ();
163+ blur = blur_manager. get_blur (wl_surface);
164+ }
152165 }
153166 }
154167
155- private void update_real_x11_hints () {
156- update_x11_hints (get_x11_panel_hints () + get_real_x11_blur_hints ());
157- }
168+ private void update_x11_hints () {
169+ var display = Gdk . Display . get_default ();
170+ if (display is Gdk . X11. Display ) {
171+ unowned var xdisplay = ((Gdk . X11. Display ) display). get_xdisplay ();
158172
159- private string get_x11_panel_hints () {
160- return " anchor=8:hide-mode= %d :size=-1, %d : " . printf (settings . get_enum ( " autohide-mode " ), full_height);
161- }
173+ var window = (( Gdk . X11 . Surface ) get_surface ()) . get_xid ();
174+
175+ var prop = xdisplay . intern_atom ( " _MUTTER_HINTS " , false );
162176
163- private string get_real_x11_blur_hints () {
164- return get_x11_blur_hints (
165- 0 ,
166- TOP_PADDING ,
167- visible_width,
168- visible_height,
169- BORDER_RADIUS
170- );
177+ var value = " anchor=8:hide-mode=%d :size=-1,%d :blur=%d ,%d ,%d ,%d ,%d " . printf (
178+ settings. get_enum (" autohide-mode" ),
179+ full_height,
180+ 0 ,
181+ TOP_PADDING ,
182+ visible_width,
183+ visible_height,
184+ BORDER_RADIUS
185+ );
186+
187+ xdisplay. change_property (window, prop, X . XA_STRING , 8 , 0 , (uchar[]) value , value . length);
188+ }
171189 }
172190}
0 commit comments