From 0fb37cd069d809d7bf647e0e6eceb52238123d31 Mon Sep 17 00:00:00 2001 From: Stan Janssen Date: Wed, 29 Mar 2023 11:21:31 +0200 Subject: [PATCH 1/4] Make the notifications move out of the way when menus are opened --- src/Services/PopoverManager.vala | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index a690cf5a..4d916dcb 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -17,12 +17,19 @@ * Boston, MA 02110-1301 USA. */ +[DBus (name = "org.pantheon.gala")] +public interface WMDBus : GLib.Object { + public abstract void offset_notifications (int32 offset) throws DBusError, Error; +} + public class Wingpanel.Services.PopoverManager : Object { private unowned Wingpanel.PanelWindow? owner; private bool grabbed = false; // whether the wingpanel grabbed focus private bool mousing = false; + private WMDBus? wm = null; + private Gee.HashMap registered_indicators; private Wingpanel.Widgets.IndicatorPopover popover; private Wingpanel.Widgets.IndicatorEntry? _current_indicator = null; @@ -59,10 +66,12 @@ public class Wingpanel.Services.PopoverManager : Object { owner.present (); popover.popup (); popover.show_all (); + offset_notifications (popover); _current_indicator.base_indicator.opened (); } else { update_has_tooltip (((Wingpanel.Widgets.IndicatorEntry)popover.get_relative_to ()).display_widget); popover.popdown (); + offset_notifications (); } } } @@ -72,6 +81,12 @@ public class Wingpanel.Services.PopoverManager : Object { this.owner = owner; + try { + this.wm = Bus.get_proxy_sync (BusType.SESSION, "org.pantheon.gala", "/org/pantheon/gala"); + } catch (Error e) { + warning ("Could not connect to dbus org.pantheon.gala"); + } + popover = new Wingpanel.Widgets.IndicatorPopover (); popover.leave_notify_event.connect ((e) => { @@ -238,4 +253,18 @@ public class Wingpanel.Services.PopoverManager : Object { } }); } + + private void offset_notifications(Wingpanel.Widgets.IndicatorPopover? popover = null) { + int offset = 0; + if (popover != null) { + int minimum_height, natural_height; + popover.get_preferred_height (out minimum_height, out natural_height); + offset = natural_height; + } + try { + wm.offset_notifications (offset); + } catch (Error e) { + warning ("Could not offset notifications: %s", e.message); + } + } } From 70fb61d5a6f515c6f1a617c8e36c30776a57587b Mon Sep 17 00:00:00 2001 From: Stan Janssen Date: Wed, 29 Mar 2023 11:56:58 +0200 Subject: [PATCH 2/4] Clean up the offset_notification method --- src/Services/PopoverManager.vala | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index 4d916dcb..7b64c7f9 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -254,13 +254,12 @@ public class Wingpanel.Services.PopoverManager : Object { }); } - private void offset_notifications(Wingpanel.Widgets.IndicatorPopover? popover = null) { + private void offset_notifications (Wingpanel.Widgets.IndicatorPopover? popover = null) { int offset = 0; if (popover != null) { - int minimum_height, natural_height; - popover.get_preferred_height (out minimum_height, out natural_height); - offset = natural_height; + popover.get_preferred_height (null, out offset); } + try { wm.offset_notifications (offset); } catch (Error e) { From 618ac8f92ef7cefd11d8b8d43c2f11d7933d62fb Mon Sep 17 00:00:00 2001 From: Stan Janssen Date: Wed, 29 Mar 2023 13:08:46 +0200 Subject: [PATCH 3/4] Make offset_notifications asynchronous This avoids a deadlock when selecting the Log Out option. --- src/Services/PopoverManager.vala | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index 7b64c7f9..bda87073 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -19,7 +19,7 @@ [DBus (name = "org.pantheon.gala")] public interface WMDBus : GLib.Object { - public abstract void offset_notifications (int32 offset) throws DBusError, Error; + public abstract async void offset_notifications (int32 offset) throws DBusError, Error; } public class Wingpanel.Services.PopoverManager : Object { @@ -260,10 +260,12 @@ public class Wingpanel.Services.PopoverManager : Object { popover.get_preferred_height (null, out offset); } - try { - wm.offset_notifications (offset); - } catch (Error e) { - warning ("Could not offset notifications: %s", e.message); - } + wm.offset_notifications.begin (offset, (obj, res) => { + try { + wm.offset_notifications.end (res); + } catch (Error e) { + warning ("Could not offset notifications: %s", e.message); + } + }); } } From 6ed1cbcb9b84a63392625c0b2179ed9eb7952cb9 Mon Sep 17 00:00:00 2001 From: Stan Janssen Date: Wed, 29 Mar 2023 13:19:10 +0200 Subject: [PATCH 4/4] Ignore the Panel and Calendar popovers when moving notifications --- src/Services/PopoverManager.vala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index bda87073..f569c460 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -256,7 +256,10 @@ public class Wingpanel.Services.PopoverManager : Object { private void offset_notifications (Wingpanel.Widgets.IndicatorPopover? popover = null) { int offset = 0; - if (popover != null) { + if (popover != null + && current_indicator.base_indicator.code_name != Indicator.APP_LAUNCHER + && current_indicator.base_indicator.code_name != Indicator.DATETIME) { + popover.get_preferred_height (null, out offset); }