This commit is contained in:
Benjamin Schaaf
2021-12-24 18:08:37 +11:00
parent a8c5fc2f4d
commit 7c050555e3

View File

@@ -146,14 +146,25 @@ class MainWindow(Handy.ApplicationWindow):
mobile_handle = player_controls.MobileHandle(self.player_manager)
# Toggle drawer when handle is pressed
def toggle_drawer(handle, event):
if event.get_click_count() != (True, 1) or not drawer.get_swipe_to_open() or event.device.get_source() == Gdk.InputSource.TOUCHSCREEN:
mobile_handle_events = Gtk.EventBox()
mobile_handle_events.set_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK)
click_gesture = Gtk.GestureMultiPress.new(mobile_handle_events)
click_gesture.set_propagation_phase(Gtk.PropagationPhase.BUBBLE)
def toggle_drawer(gesture, num, x, y):
if (num != 1 or not drawer.get_swipe_to_open() or
x < 0 or x > mobile_handle_events.get_allocated_width() or
y < 0 or y > mobile_handle_events.get_allocated_height()):
return
drawer.set_reveal_flap(not drawer.get_reveal_flap())
mobile_handle.connect("button-press-event", toggle_drawer)
click_gesture.connect('released', toggle_drawer)
squeezer.add(mobile_handle)
# Need to keep the gesture object alive
mobile_handle_events._gesture = click_gesture
mobile_handle_events.add(mobile_handle)
squeezer.add(mobile_handle_events)
# Only show the handle on desktop
def squeezer_changed(squeezer, _):