Skip to content

Commit 735aa20

Browse files
committed
Try the same fix as Gtk3
1 parent 3875e3d commit 735aa20

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

daemon/DBus.vala

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public class Gala.Daemon.DBus : GLib.Object {
6767
private WMDBus? wm_proxy = null;
6868

6969
private Window window;
70-
private WindowMenu? window_menu;
70+
private WindowMenu window_menu;
71+
private Gtk.GestureClick window_menu_click_controller;
7172
private Gtk.PopoverMenu background_menu;
7273

7374
private List<MonitorLabel> monitor_labels = new List<MonitorLabel> ();
@@ -123,6 +124,11 @@ public class Gala.Daemon.DBus : GLib.Object {
123124
return Source.REMOVE;
124125
});
125126
});
127+
128+
window_menu_click_controller = new Gtk.GestureClick () {
129+
propagation_phase = Gtk.PropagationPhase.BUBBLE
130+
};
131+
((Gtk.Widget) window_menu).add_controller (window_menu_click_controller);
126132
}
127133

128134
private void on_gala_get (GLib.Object? obj, GLib.AsyncResult? res) {
@@ -156,14 +162,14 @@ public class Gala.Daemon.DBus : GLib.Object {
156162
public void show_window_menu (Gala.WindowFlags flags, int monitor, int monitor_width, int monitor_height, int x, int y) throws DBusError, IOError {
157163
window_menu.update (flags);
158164

159-
show_menu (window_menu, monitor, monitor_width, monitor_height, x, y);
165+
show_menu (window_menu, monitor, monitor_width, monitor_height, x, y, true);
160166
}
161167

162168
public void show_desktop_menu (int monitor, int monitor_width, int monitor_height, int x, int y) throws DBusError, IOError {
163-
show_menu (background_menu, monitor, monitor_width, monitor_height, x, y);
169+
show_menu (background_menu, monitor, monitor_width, monitor_height, x, y, false);
164170
}
165171

166-
private void show_menu (Gtk.Popover menu, int monitor, int monitor_width, int monitor_height, int x, int y) {
172+
private void show_menu (Gtk.Popover menu, int monitor, int monitor_width, int monitor_height, int x, int y, bool ignore_first_release) {
167173
if (!DisplayConfig.is_logical_layout ()) {
168174
var scale_factor = window.scale_factor;
169175

@@ -190,6 +196,18 @@ public class Gala.Daemon.DBus : GLib.Object {
190196
menu.popup ();
191197
return Source.REMOVE;
192198
});
199+
200+
if (ignore_first_release) {
201+
var first = true;
202+
window_menu_click_controller.released.connect (() => {
203+
if (first) {
204+
first = false;
205+
window_menu_click_controller.set_state (Gtk.EventSequenceState.CLAIMED);
206+
}
207+
208+
window_menu_click_controller.set_state (Gtk.EventSequenceState.NONE);
209+
});
210+
}
193211
}
194212

195213
public void show_monitor_labels (MonitorLabelInfo[] label_infos) throws GLib.DBusError, GLib.IOError {

0 commit comments

Comments
 (0)