From a58ead2055c4e1f491cde0200d12c8b6acb2c4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 19 Sep 2026 10:47:50 -0700 Subject: [PATCH 1/6] PopoverManager: DRY and organize current_indicator setter --- src/Services/PopoverManager.vala | 49 ++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index ea74b347..bf85aee8 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -29,37 +29,43 @@ public class Wingpanel.Services.PopoverManager : Object { } set { + // Double close. Shouldn't happen? if (value == null && _current_indicator == null) { return; } - if (_current_indicator == null && value != null) { // First open - _current_indicator = value; - indicator_open = true; - } else if (value == null && _current_indicator != null) { // Close requested - _current_indicator.set_state_flags (NORMAL, true); - _current_indicator.display_widget.has_tooltip = true; - _current_indicator.base_indicator.closed (); - _current_indicator = null; - popover.popdown (); - indicator_open = false; - } else { // Switch + // Switch or Close + if (_current_indicator != null) { _current_indicator.set_state_flags (NORMAL, true); _current_indicator.display_widget.has_tooltip = true; _current_indicator.base_indicator.closed (); - _current_indicator = value; - popover.unparent (); - } - if (_current_indicator != null) { - popover.child = _current_indicator.indicator_widget; - popover.set_parent (_current_indicator); - popover.popup (); + // Close + if (value == null) { + popover.popdown (); + popover.unparent (); + _current_indicator = null; + indicator_open = false; + return; + } else { + popover.unparent (); + } + } - _current_indicator.set_state_flags (CHECKED, true); - _current_indicator.display_widget.has_tooltip = false; - _current_indicator.base_indicator.opened (); + // First open + if (_current_indicator == null) { + indicator_open = true; } + + _current_indicator = value; + _current_indicator.set_state_flags (CHECKED, true); + _current_indicator.display_widget.has_tooltip = false; + + popover.child = _current_indicator.indicator_widget; + popover.set_parent (_current_indicator); + popover.popup (); + + _current_indicator.base_indicator.opened (); } } @@ -72,7 +78,6 @@ public class Wingpanel.Services.PopoverManager : Object { popover.closed.connect (() => { current_indicator = null; - popover.unparent (); }); } } From 0ccbafbc25ad25af0614fc3e6b768ea8efd7749e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 19 Sep 2026 10:50:42 -0700 Subject: [PATCH 2/6] comment --- src/Services/PopoverManager.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index bf85aee8..16c125fa 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -63,9 +63,10 @@ public class Wingpanel.Services.PopoverManager : Object { popover.child = _current_indicator.indicator_widget; popover.set_parent (_current_indicator); - popover.popup (); + // Make sure we're parented beforehand _current_indicator.base_indicator.opened (); + popover.popup (); } } From cea641af63b88346740789c10b3755116a1ea2f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 19 Sep 2026 10:51:04 -0700 Subject: [PATCH 3/6] better comment --- src/Services/PopoverManager.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index 16c125fa..76b338f6 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -64,7 +64,7 @@ public class Wingpanel.Services.PopoverManager : Object { popover.child = _current_indicator.indicator_widget; popover.set_parent (_current_indicator); - // Make sure we're parented beforehand + // Make sure display_widget is parented beforehand _current_indicator.base_indicator.opened (); popover.popup (); } From 4e9fa7ff4a53226c52c178e9f2d13f54846b2a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 19 Sep 2026 10:54:25 -0700 Subject: [PATCH 4/6] Bump license header --- src/Services/PopoverManager.vala | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index 76b338f6..5c7daacf 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -1,20 +1,7 @@ /* - * Copyright (c) 2011-2015 Ikey Doherty - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. + * Copyright 2026 elementary, Inc. (https://elementary.io) + * 2011-2015 Ikey Doherty + * SPDX-License-Identifier: GPL-2.0-or-later */ public class Wingpanel.Services.PopoverManager : Object { From c4ee156b72ddeca73d0a102e45b5d8e5f431f811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 19 Sep 2026 10:57:43 -0700 Subject: [PATCH 5/6] PopoverManager: remember and restore window internally --- src/PanelWindow.vala | 9 --------- src/Services/PopoverManager.vala | 6 ++---- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/PanelWindow.vala b/src/PanelWindow.vala index 88c23192..030b6682 100644 --- a/src/PanelWindow.vala +++ b/src/PanelWindow.vala @@ -50,15 +50,6 @@ public class Wingpanel.PanelWindow : Gtk.Window { decorated = false; resizable = false; - popover_manager.notify["indicator-open"].connect (() => { - if (!popover_manager.indicator_open) { - Services.BackgroundManager.get_default ().restore_window (); - return; - } else { - Services.BackgroundManager.get_default ().remember_window (); - } - }); - Services.BackgroundManager.get_default ().background_state_changed.connect (update_background); } diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index 5c7daacf..d2d6f43a 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -5,8 +5,6 @@ */ public class Wingpanel.Services.PopoverManager : Object { - public bool indicator_open { get; private set; default = false; } - private Gtk.Popover popover; private Wingpanel.Widgets.IndicatorEntry? _current_indicator = null; @@ -32,7 +30,7 @@ public class Wingpanel.Services.PopoverManager : Object { popover.popdown (); popover.unparent (); _current_indicator = null; - indicator_open = false; + Services.BackgroundManager.get_default ().restore_window (); return; } else { popover.unparent (); @@ -41,7 +39,7 @@ public class Wingpanel.Services.PopoverManager : Object { // First open if (_current_indicator == null) { - indicator_open = true; + Services.BackgroundManager.get_default ().remember_window (); } _current_indicator = value; From 36b346040b991accff2261d0f6947829bacb2cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sat, 19 Sep 2026 11:05:54 -0700 Subject: [PATCH 6/6] Alternatively, don't do this? --- src/Services/BackgroundManager.vala | 26 -------------------------- src/Services/PopoverManager.vala | 2 -- 2 files changed, 28 deletions(-) diff --git a/src/Services/BackgroundManager.vala b/src/Services/BackgroundManager.vala index 11d4b01e..680b6c1a 100644 --- a/src/Services/BackgroundManager.vala +++ b/src/Services/BackgroundManager.vala @@ -31,8 +31,6 @@ namespace Wingpanel.Services { public signal void state_changed (BackgroundState state, uint animation_duration); public abstract void initialize (int panel_height) throws GLib.Error; - public abstract void remember_focused_window () throws GLib.Error; - public abstract void restore_focused_window () throws GLib.Error; public abstract bool begin_grab_focused_window (int x, int y) throws GLib.Error; } @@ -77,30 +75,6 @@ namespace Wingpanel.Services { use_transparency = panel_settings.get_boolean ("use-transparency"); } - public void remember_window () { - if (!bus_available) { - return; - } - - try { - bus.remember_focused_window (); - } catch (Error e) { - warning ("Remembering focused window failed: %s", e.message); - } - } - - public void restore_window () { - if (!bus_available) { - return; - } - - try { - bus.restore_focused_window (); - } catch (Error e) { - warning ("Restoring last focused window failed: %s", e.message); - } - } - public bool begin_grab_focused_window (int x, int y) { try { return bus.begin_grab_focused_window (x, y); diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index d2d6f43a..f3374aef 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -30,7 +30,6 @@ public class Wingpanel.Services.PopoverManager : Object { popover.popdown (); popover.unparent (); _current_indicator = null; - Services.BackgroundManager.get_default ().restore_window (); return; } else { popover.unparent (); @@ -39,7 +38,6 @@ public class Wingpanel.Services.PopoverManager : Object { // First open if (_current_indicator == null) { - Services.BackgroundManager.get_default ().remember_window (); } _current_indicator = value;