From: Christoffer Aasted Date: Sun, 2 Aug 2026 19:00:41 +0000 (+0000) Subject: patch 9.2.0900: FocusGained still triggered when closing dialog X-Git-Tag: v9.2.0900^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d474289d0f12505b16b59a61ad161c57c3e596cb;p=thirdparty%2Fvim.git patch 9.2.0900: FocusGained still triggered when closing dialog Problem: FocusGained still triggered when closing dialog (after v9.2.0851) Solution: Track that dialog is active and suppress the FocusGained autocommand (Christoffer Aasted) related: #20780 closes: #20894 Signed-off-by: Christoffer Aasted Signed-off-by: Christian Brabandt --- diff --git a/src/gui.h b/src/gui.h index e2232982e9..653937cfe6 100644 --- a/src/gui.h +++ b/src/gui.h @@ -422,8 +422,7 @@ typedef struct Gui # ifdef FEAT_GUI_DIALOG // Multiple dialogs not allowed, just tracked for future use. int dialogs_active; // number of active GUI dialogs - - // X11 focus_in_event() by dialogs, ignored to match wayland. + // Suppress focus-in event when focus returns. int dialog_focus_pending; # endif bool is_x11; // active gdk backend in gtk is x11 diff --git a/src/gui_gtk.c b/src/gui_gtk.c index eef771e840..89159d237f 100644 --- a/src/gui_gtk.c +++ b/src/gui_gtk.c @@ -1710,8 +1710,6 @@ gui_mch_dialog(int type, // type of dialog DialogInfo dialoginfo; ++gui.dialogs_active; - if (gui.is_x11) - ++gui.dialog_focus_pending; dialog = create_message_dialog(type, title, message); dialoginfo.dialog = GTK_DIALOG(dialog); @@ -1798,7 +1796,8 @@ gui_mch_dialog(int type, // type of dialog gtk_widget_destroy(dialog); } - --gui.dialogs_active; + if (gui.dialogs_active > 0) + --gui.dialogs_active; return response > 0 ? response : 0; } diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index f2db6d1da8..6b56a1ee5c 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -1071,8 +1071,13 @@ focus_in_event(GtkWidget *widget, gpointer data UNUSED) { #ifdef FEAT_GUI_DIALOG - if (gui.is_x11 && gui.dialog_focus_pending > 0) + if (gui.dialog_focus_pending > 0) + { --gui.dialog_focus_pending; + ++hold_gui_events; + gui_focus_change(TRUE); + --hold_gui_events; + } else #endif gui_focus_change(TRUE); @@ -1093,6 +1098,11 @@ focus_out_event(GtkWidget *widget UNUSED, GdkEventFocus *event UNUSED, gpointer data UNUSED) { +#ifdef FEAT_GUI_DIALOG + if (gui.dialogs_active > 0) + ++gui.dialog_focus_pending; +#endif + gui_focus_change(FALSE); if (blink_state != BLINK_NONE) diff --git a/src/version.c b/src/version.c index 41209b1257..ac814a01ee 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 900, /**/ 899, /**/