@@ -39,7 +39,6 @@ public class Display.DisplaysOverlay : Gtk.Box {
3939 private int default_y_margin = 0 ;
4040
4141 private unowned Display . MonitorManager monitor_manager;
42- private static GalaDBus gala_dbus = null ;
4342 public int active_displays { get ; set ; default = 0 ; }
4443
4544 private List<DisplayWidget > display_widgets;
@@ -70,6 +69,7 @@ public class Display.DisplaysOverlay : Gtk.Box {
7069 };
7170
7271 private Gtk . GestureDrag drag_gesture;
72+ private MonitorLabel [] monitor_labels = {};
7373
7474 construct {
7575 add_css_class (Granite . STYLE_CLASS_VIEW );
@@ -91,6 +91,9 @@ public class Display.DisplaysOverlay : Gtk.Box {
9191 rescan_displays ();
9292
9393 overlay. get_child_position. connect (get_child_position);
94+
95+ map. connect (show_windows);
96+ unmap. connect (hide_windows);
9497 }
9598
9699 static construct {
@@ -102,20 +105,6 @@ public class Display.DisplaysOverlay : Gtk.Box {
102105 display_provider,
103106 Gtk . STYLE_PROVIDER_PRIORITY_APPLICATION
104107 );
105-
106- GLib . Bus . get_proxy. begin< GalaDBus > (
107- GLib . BusType . SESSION ,
108- " org.pantheon.gala.daemon" ,
109- " /org/pantheon/gala/daemon" ,
110- GLib . DBusProxyFlags . NONE ,
111- null ,
112- (obj, res) = > {
113- try {
114- gala_dbus = GLib . Bus . get_proxy. end (res);
115- } catch (GLib . Error e) {
116- critical (e. message);
117- }
118- });
119108 }
120109
121110 private double prev_dx = 0 ;
@@ -204,39 +193,30 @@ public class Display.DisplaysOverlay : Gtk.Box {
204193 scanning = false ;
205194 }
206195
207- public void show_windows () requires (gala_dbus != null ) {
196+ public void show_windows () {
197+ hide_windows ();
198+
208199 if (monitor_manager. is_mirrored) {
209200 return ;
210201 }
211202
212- MonitorLabelInfo [] label_infos = {};
213-
214203 foreach (unowned var widget in display_widgets) {
215204 if (widget. virtual_monitor. is_active) {
216- label_infos + = MonitorLabelInfo () {
217- monitor = label_infos. length,
218- label = widget. virtual_monitor. get_display_name (),
219- background_color = widget. bg_color,
220- text_color = widget. text_color,
221- x = widget. virtual_monitor. current_x,
222- y = widget. virtual_monitor. current_y
223- };
205+ var monitor_label = new MonitorLabel (
206+ monitor_labels. length, widget. virtual_monitor. get_display_name (),
207+ widget. bg_color, widget. text_color
208+ );
209+ monitor_label. present ();
210+ monitor_labels + = monitor_label;
224211 }
225212 }
226-
227- try {
228- gala_dbus. show_monitor_labels (label_infos);
229- } catch (Error e) {
230- warning (" Couldn't show monitor labels: %s " , e. message);
231- }
232213 }
233214
234- public void hide_windows () requires (gala_dbus != null ) {
235- try {
236- gala_dbus. hide_monitor_labels ();
237- } catch (Error e) {
238- warning (" Couldn't hide monitor labels: %s " , e. message);
215+ public void hide_windows () {
216+ foreach (var monitor_label in monitor_labels) {
217+ monitor_label. destroy ();
239218 }
219+ monitor_labels = {};
240220 }
241221
242222 private void change_active_displays_sensitivity () {
0 commit comments