@@ -868,6 +868,42 @@ long gtk_mnemonic_activate (long widget, long arg1) {
868868 return parent .gtk_mnemonic_activate (widget , arg1 );
869869}
870870
871+ @ Override
872+ int gtk_gesture_press_event (long gesture , int n_press , double x , double y , long event ) {
873+ /*
874+ * GTK4: For DROP_DOWN items, the arrow portion is a GtkMenuButton
875+ * (arrowHandle) that is separate from the main button. Attach a gesture
876+ * controller to arrowHandle and detect it here in order to send the
877+ * SWT.ARROW selection detail to the listener (e.g. to open a drop-down menu).
878+ */
879+ if ((style & SWT .DROP_DOWN ) != 0 && arrowHandle != 0
880+ && GTK .gtk_event_controller_get_widget (gesture ) == arrowHandle
881+ && n_press == 1
882+ && GTK .gtk_gesture_single_get_current_button (gesture ) == 1 ) {
883+ Event e = new Event ();
884+ e .detail = SWT .ARROW ;
885+ GtkAllocation allocation = new GtkAllocation ();
886+ GTK .gtk_widget_get_allocation (arrowHandle , allocation );
887+ /*
888+ * On GTK4 gtk_widget_get_allocation returns parent-widget-relative
889+ * coordinates, but the SWT event x/y must be in ToolBar-relative
890+ * coordinates so that callers can use toolBar.toDisplay(event.x, event.y).
891+ * Translate the arrow button's origin into the ToolBar's coordinate space.
892+ * If translation fails, fall back to the parent-relative allocation.
893+ */
894+ double [] destX = new double [1 ];
895+ double [] destY = new double [1 ];
896+ boolean translated = GTK4 .gtk_widget_translate_coordinates (arrowHandle , parent .handle , 0 , 0 , destX , destY );
897+ e .x = translated ? (int ) destX [0 ] : allocation .x ;
898+ if ((parent .style & SWT .MIRRORED ) != 0 ) e .x = parent .getClientWidth () - allocation .width - e .x ;
899+ System .out .println (e .x );
900+ e .y = translated ? (int ) destY [0 ] + allocation .height : allocation .y + allocation .height ;
901+ sendSelectionEvent (SWT .Selection , e , false );
902+ return GTK4 .GTK_EVENT_SEQUENCE_CLAIMED ;
903+ }
904+ return GTK4 .GTK_EVENT_SEQUENCE_NONE ;
905+ }
906+
871907@ Override
872908void hookEvents () {
873909 super .hookEvents ();
@@ -1664,4 +1700,4 @@ private void recreateMenuProxy() {
16641700 }
16651701 }
16661702}
1667- }
1703+ }
0 commit comments