]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0900: FocusGained still triggered when closing dialog v9.2.0900
authorChristoffer Aasted <dezzadk@gmail.com>
Sun, 2 Aug 2026 19:00:41 +0000 (19:00 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 2 Aug 2026 19:00:41 +0000 (19:00 +0000)
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 <dezzadk@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/gui.h
src/gui_gtk.c
src/gui_gtk_x11.c
src/version.c

index e2232982e958d60c8483513b5f03526281bee136..653937cfe6e32da4460ea29431ce1ddd00cce568 100644 (file)
--- 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
index eef771e84011e44e486321a4f6f274de80382ce1..89159d237fc499a62740c14765215ba56924e4f7 100644 (file)
@@ -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;
 }
 
index f2db6d1da8460196f78477fb198ce1dac47d9024..6b56a1ee5cd1cd16eddd977b296f6bff7f8a1c3e 100644 (file)
@@ -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)
index 41209b1257b035623c14ff7764b4734e0e048b15..ac814a01ee20ed64976f62b3bb2a06029e2331b4 100644 (file)
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    900,
 /**/
     899,
 /**/