Commit: patch 9.2.0900: FocusGained still triggered when closing dialog

1 view
Skip to first unread message

Christian Brabandt

unread,
3:15 PM (5 hours ago) 3:15 PM
to vim...@googlegroups.com
patch 9.2.0900: FocusGained still triggered when closing dialog

Commit: https://github.com/vim/vim/commit/d474289d0f12505b16b59a61ad161c57c3e596cb
Author: Christoffer Aasted <dez...@gmail.com>
Date: Sun Aug 2 19:00:41 2026 +0000

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 <dez...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/gui.h b/src/gui.h
index e2232982e..653937cfe 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 eef771e84..89159d237 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 f2db6d1da..6b56a1ee5 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 41209b125..ac814a01e 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,
/**/
Reply all
Reply to author
Forward
0 new messages