diff --git a/src/Services/PopoverManager.vala b/src/Services/PopoverManager.vala index a690cf5a..895241ae 100644 --- a/src/Services/PopoverManager.vala +++ b/src/Services/PopoverManager.vala @@ -21,7 +21,6 @@ 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 Gee.HashMap registered_indicators; private Wingpanel.Widgets.IndicatorPopover popover; @@ -95,10 +94,6 @@ public class Wingpanel.Services.PopoverManager : Object { }); owner.focus_out_event.connect ((e) => { - if (mousing) { - return Gdk.EVENT_PROPAGATE; - } - if (current_indicator != null && e.window == null) { current_indicator = null; } @@ -175,7 +170,7 @@ public class Wingpanel.Services.PopoverManager : Object { } private void make_modal (Gtk.Popover? pop, bool modal = true) { - if (pop == null || pop.get_window () == null || mousing) { + if (pop == null || pop.get_window () == null) { return; } @@ -210,26 +205,8 @@ public class Wingpanel.Services.PopoverManager : Object { registered_indicators.set (widg.base_indicator.code_name, widg); - widg.enter_notify_event.connect ((w, e) => { - if (mousing) { - return Gdk.EVENT_PROPAGATE; - } - - if (grabbed) { - if (!get_visible (widg) && e.mode != Gdk.CrossingMode.TOUCH_BEGIN) { - mousing = true; - current_indicator = widg; - mousing = false; - } - - return Gdk.EVENT_STOP; - } - - return Gdk.EVENT_PROPAGATE; - }); - widg.notify["visible"].connect (() => { - if (mousing || grabbed) { + if (grabbed) { return; } diff --git a/src/Widgets/IndicatorEntry.vala b/src/Widgets/IndicatorEntry.vala index c79691e4..e8855dd6 100644 --- a/src/Widgets/IndicatorEntry.vala +++ b/src/Widgets/IndicatorEntry.vala @@ -37,6 +37,9 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.EventBox { private Gtk.Revealer revealer; + private Gtk.GestureMultiPress gesture_controller; + private Gtk.EventControllerMotion motion_controller; + public IndicatorEntry (Indicator base_indicator, Services.PopoverManager popover_manager) { Object ( base_indicator: base_indicator, @@ -54,9 +57,10 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.EventBox { return; } - revealer = new Gtk.Revealer (); + revealer = new Gtk.Revealer () { + child = display_widget + }; revealer.get_style_context ().add_class ("composited-indicator"); - revealer.add (display_widget); add (revealer); @@ -97,26 +101,20 @@ public class Wingpanel.Widgets.IndicatorEntry : Gtk.EventBox { return Gdk.EVENT_PROPAGATE; }); - touch_event.connect ((e) => { - if (e.type == Gdk.EventType.TOUCH_BEGIN) { - popover_manager.current_indicator = this; - return Gdk.EVENT_STOP; - } + button_press_event.connect ((e) => display_widget.button_press_event (e)); - return Gdk.EVENT_PROPAGATE; - }); + gesture_controller = new Gtk.GestureMultiPress (this); + gesture_controller.pressed.connect (() => popover_manager.current_indicator = this); + + motion_controller = new Gtk.EventControllerMotion (this) { + propagation_phase = CAPTURE + }; - button_press_event.connect ((e) => { - if ((e.button == Gdk.BUTTON_PRIMARY || e.button == Gdk.BUTTON_SECONDARY) - && e.type == Gdk.EventType.BUTTON_PRESS) { + motion_controller.enter.connect (() => { + // If something is open and it's not us, open us. This implements the scrubbing behavior + if (popover_manager.current_indicator != null && !popover_manager.get_visible (this)) { popover_manager.current_indicator = this; - return Gdk.EVENT_STOP; } - - /* Call button press on the indicator display widget */ - display_widget.button_press_event (e); - - return Gdk.EVENT_STOP; }); set_reveal (base_indicator.visible);