Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PopoverManager: Remove a lot of (hopefully) unnecessary stuff #574

Merged
merged 3 commits into from
Sep 11, 2024
Merged
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
62 changes: 8 additions & 54 deletions src/Services/PopoverManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
public class Wingpanel.Services.PopoverManager : Object {
private unowned Wingpanel.PanelWindow? owner;

private bool grabbed = false; // whether the wingpanel grabbed focus

private Gtk.GestureMultiPress owner_gesture_controller;

private Gee.HashMap<string, Wingpanel.Widgets.IndicatorEntry> registered_indicators;
Expand Down Expand Up @@ -56,7 +54,6 @@ public class Wingpanel.Services.PopoverManager : Object {
popover.relative_to = _current_indicator;
update_has_tooltip (_current_indicator.display_widget, false);
owner.set_expanded (true);
make_modal (popover, true);
owner.present ();
popover.popup ();
popover.show_all ();
Expand All @@ -75,33 +72,17 @@ public class Wingpanel.Services.PopoverManager : Object {

popover = new Wingpanel.Widgets.IndicatorPopover ();

popover.leave_notify_event.connect ((e) => {
Gtk.Allocation allocation;
popover.get_allocation (out allocation);

if (e.mode != Gdk.CrossingMode.NORMAL && e.subwindow == null) {
current_indicator = null;
}

return Gdk.EVENT_PROPAGATE;
});

popover.closed.connect (() => {
current_indicator = null;
make_modal (popover, false);
});
popover.unmap.connect (() => {
if (!grabbed) {
owner.set_expanded (false);
}
});

owner.focus_out_event.connect ((e) => {
if (current_indicator != null && e.window == null) {
current_indicator = null;
}

return Gdk.EVENT_PROPAGATE;
// We have to wait for unmap otherwise the popover is confined to the panel space
// on X. But we also can't just connect to it because unmap gets emitted when repositioning
// for some reason.
ulong handler_id = 0;
handler_id = popover.unmap.connect (() => {
owner.set_expanded (false);
popover.disconnect (handler_id);
});
});

owner_gesture_controller = new Gtk.GestureMultiPress (owner) {
Expand Down Expand Up @@ -141,23 +122,6 @@ public class Wingpanel.Services.PopoverManager : Object {
}
}

private void make_modal (Gtk.Popover? pop, bool modal = true) {
if (pop == null || pop.get_window () == null) {
return;
}

if (modal && !grabbed) {
grabbed = true;
Gtk.grab_add (owner);
owner.set_focus (null);
pop.grab_focus ();
} else if (!modal && grabbed) {
grabbed = false;
Gtk.grab_remove (owner);
owner.grab_focus ();
}
}

public void close () {
if (current_indicator != null) {
current_indicator = null;
Expand All @@ -176,15 +140,5 @@ public class Wingpanel.Services.PopoverManager : Object {
}

registered_indicators.set (widg.base_indicator.code_name, widg);

widg.notify["visible"].connect (() => {
if (grabbed) {
return;
}

if (get_visible (widg)) {
current_indicator = null;
}
});
}
}
Loading