Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/PanelWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
26 changes: 0 additions & 26 deletions src/Services/BackgroundManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
69 changes: 29 additions & 40 deletions src/Services/PopoverManager.vala
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
/*
* Copyright (c) 2011-2015 Ikey Doherty <ikey@solus-project.com>
*
* 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 <ikey@solus-project.com>
* SPDX-License-Identifier: GPL-2.0-or-later
*/

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;
Expand All @@ -29,37 +14,42 @@ 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;
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) {
}

_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);

// Make sure display_widget is parented beforehand
_current_indicator.base_indicator.opened ();
popover.popup ();
}
}

Expand All @@ -72,7 +62,6 @@ public class Wingpanel.Services.PopoverManager : Object {

popover.closed.connect (() => {
current_indicator = null;
popover.unparent ();
});
}
}
Loading