Skip to content

Commit 5b42ae5

Browse files
committed
[GTK] Support popup menu on Gtk 4
Gtk 3 "popup-menu" signal no longer exists on Gtk 4 thus popup menu has to be handled by the generic "gesture-press". Renamed the Gtk 3 handler to acknowledge the fact it doesn't belong to Gtk 4 port and removed wrong effort to port the popup-menu handler to Gtk 4.
1 parent 5f77aac commit 5b42ae5

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3421,22 +3421,22 @@ int gtk_gesture_press_event (long gesture, int n_press, double x, double y, long
34213421
if (!cancelled) {
34223422
result = GTK4.GTK_EVENT_SEQUENCE_CLAIMED;
34233423
}
3424-
if ((state & MENU) != 0) {
3425-
if (eventButton == 3) {
3424+
if (eventButton == 3) {
3425+
if ((state & MENU) != 0 || menu != null) {
34263426
if (showMenu ((int)x, (int)y)) {
34273427
result = GTK4.GTK_EVENT_SEQUENCE_CLAIMED;
34283428
}
34293429
}
34303430
}
34313431
} else if (n_press >= 2) {
34323432
boolean cancelled = sendMouseEvent(SWT.MouseDoubleClick, eventButton, n_press, 0, false, eventTime, x, y, false, eventState);
3433-
3434-
//Issue 344, DoubleClick event currently unsupported below sendMouseEvent(). Until DoubleClickSupport is
3433+
3434+
//Issue 344, DoubleClick event currently unsupported below sendMouseEvent(). Until DoubleClickSupport is
34353435
//added this will catch failed events and try MouseDown instead.
34363436
if (cancelled) {
34373437
cancelled = sendMouseEvent(SWT.MouseDown, eventButton, n_press, 0, false, eventTime, x, y, false, eventState);
34383438
}
3439-
3439+
34403440
if (!cancelled) {
34413441
result = GTK4.GTK_EVENT_SEQUENCE_CLAIMED;
34423442
}
@@ -4240,18 +4240,10 @@ long gtk_motion_notify_event (long widget, long event) {
42404240
}
42414241

42424242
@Override
4243-
long gtk_popup_menu (long widget) {
4243+
long gtk3_popup_menu (long widget) {
42444244
if (!hasFocus()) return 0;
42454245
int [] x = new int [1], y = new int [1];
4246-
if (GTK.GTK4) {
4247-
/*
4248-
* TODO: calling gdk_window_get_device_position() with a 0
4249-
* for the GdkWindow uses gdk_get_default_root_window(),
4250-
* which doesn't exist on GTK4.
4251-
*/
4252-
} else {
4253-
display.getWindowPointerPosition (0, x, y, null);
4254-
}
4246+
display.getWindowPointerPosition (0, x, y, null);
42554247
return showMenu (x [0], y [0], SWT.MENU_KEYBOARD) ? 1 : 0;
42564248
}
42574249

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ long gtk_populate_popup (long widget, long menu) {
10611061
return 0;
10621062
}
10631063

1064-
long gtk_popup_menu (long widget) {
1064+
long gtk3_popup_menu (long widget) {
10651065
return 0;
10661066
}
10671067

@@ -2592,7 +2592,7 @@ long windowProc (long handle, long user_data) {
25922592
case MAP: return gtk_map (handle);
25932593
case MONTH_CHANGED: return gtk_month_changed (handle);
25942594
case OUTPUT: return gtk_output (handle);
2595-
case POPUP_MENU: return gtk_popup_menu (handle);
2595+
case POPUP_MENU: return gtk3_popup_menu (handle);
25962596
case PREEDIT_CHANGED: return gtk_preedit_changed (handle);
25972597
case REALIZE: return gtk_realize (handle);
25982598
case START_INTERACTIVE_SEARCH: return gtk_start_interactive_search (handle);

0 commit comments

Comments
 (0)