@@ -862,33 +862,6 @@ long gtk_show (long widget) {
862862 return 0 ;
863863}
864864
865- @ Override
866- long notifyProc (long object , long arg0 , long user_data ) {
867- switch ((int )user_data ) {
868- case NOTIFY_VISIBLE :
869- // GTK4: When a BAR or POP_UP menu becomes visible,
870- // fire SWT.Show on all CASCADE sub-menus to enable lazy population
871- if (GTK .GTK4 && (style & SWT .DROP_DOWN ) == 0 ) {
872- // Check if the menu is becoming visible
873- boolean visible = GTK .gtk_widget_get_visible (handle );
874- if (visible ) {
875- MenuItem [] items = getItems ();
876- for (int i = 0 ; i < items .length ; i ++) {
877- MenuItem item = items [i ];
878- if ((item .style & SWT .CASCADE ) != 0 ) {
879- Menu subMenu = item .getMenu ();
880- if (subMenu != null && !subMenu .isDisposed ()) {
881- subMenu .sendEvent (SWT .Show );
882- }
883- }
884- }
885- }
886- }
887- return 0 ;
888- }
889- return super .notifyProc (object , arg0 , user_data );
890- }
891-
892865
893866@ Override
894867long gtk3_show_help (long widget , long helpType ) {
@@ -938,9 +911,6 @@ void hookEvents() {
938911 if ((style & SWT .DROP_DOWN ) == 0 ) {
939912 OS .g_signal_connect_closure_by_id (handle , display .signalIds [SHOW ], 0 , display .getClosure (SHOW ), false );
940913 OS .g_signal_connect_closure_by_id (handle , display .signalIds [HIDE ], 0 , display .getClosure (HIDE ), false );
941-
942- // Hook notify::visible to fire SWT.Show on CASCADE sub-menus when parent becomes visible
943- OS .g_signal_connect (handle , OS .notify_visible , display .notifyProc , NOTIFY_VISIBLE );
944914 }
945915
946916 } else {
@@ -1303,6 +1273,25 @@ void setOrientation (boolean create) {
13031273 }
13041274}
13051275
1276+ @ Override
1277+ void sendEvent (int eventType ) {
1278+ super .sendEvent (eventType );
1279+ // GTK4: When sending SWT.Show to a menu, recursively send it to CASCADE sub-menus
1280+ // This is needed because DROP_DOWN menus don't have widget handles and can't receive signals
1281+ if (GTK .GTK4 && eventType == SWT .Show ) {
1282+ MenuItem [] items = getItems ();
1283+ for (int i = 0 ; i < items .length ; i ++) {
1284+ MenuItem item = items [i ];
1285+ if ((item .style & SWT .CASCADE ) != 0 ) {
1286+ Menu subMenu = item .getMenu ();
1287+ if (subMenu != null && !subMenu .isDisposed ()) {
1288+ subMenu .sendEvent (SWT .Show );
1289+ }
1290+ }
1291+ }
1292+ }
1293+ }
1294+
13061295/**
13071296 * Lack of absolute coordinates make Wayland event windows inaccurate.
13081297 * Currently the best approach is to the use the GdkWindow of the mouse
0 commit comments