]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0564: GTK4: tabline does not respond to mouse clicks v9.2.0564
authorFoxe Chen <chen.foxe@gmail.com>
Fri, 29 May 2026 19:47:24 +0000 (19:47 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 29 May 2026 19:47:24 +0000 (19:47 +0000)
Problem:  GTK4: tabline does not respond to mouse clicks
Solution: Connect on_select_tab() to "switch-page" to fire the tabline
          event, and on_tab_reordered() to "page-reordered" to call
          tabpage_move() with the new index (Foxe Chen).

closes: #20362

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/gui_gtk4.c
src/version.c

index dace72ae4d5422ac67e60f93f46cafb16d5f2e62..b5e134b8a459c40c56ed1a7846d9f49446fc513c 100644 (file)
@@ -278,6 +278,10 @@ static void focus_out_event(GtkEventControllerFocus *controller, gpointer data);
 #ifdef FEAT_DND
 static gboolean drop_cb(GtkDropTarget *target, const GValue *value, double x, double y, gpointer data);
 #endif
+#ifdef FEAT_GUI_TABLINE
+static void on_select_tab(GtkNotebook *notebook, gpointer *page, gint idx, gpointer data);
+static void on_tab_reordered(GtkNotebook *notebook, gpointer *page, gint idx, gpointer data);
+#endif
 static void mainwin_destroy_cb(GObject *object, gpointer data);
 static gboolean delete_event_cb(GtkWindow *window, gpointer data);
 static void mainwin_fullscreened_cb(GObject *obj, GParamSpec *pspec, gpointer user_data);
@@ -488,6 +492,11 @@ gui_mch_init(void)
     gtk_notebook_set_scrollable(GTK_NOTEBOOK(gui.tabline), TRUE);
     gtk_widget_set_visible(gui.tabline, FALSE);
     gtk_box_append(GTK_BOX(vbox), gui.tabline);
+
+    g_signal_connect(G_OBJECT(gui.tabline), "switch-page",
+                    G_CALLBACK(on_select_tab), NULL);
+    g_signal_connect(G_OBJECT(gui.tabline), "page-reordered",
+                    G_CALLBACK(on_tab_reordered), NULL);
 #endif
 
     // The form widget manages absolute positioning of scrollbars.
@@ -2550,6 +2559,39 @@ gui_mch_set_curtab(int nr)
     if (gui.tabline != NULL)
        gtk_notebook_set_current_page(GTK_NOTEBOOK(gui.tabline), nr - 1);
 }
+
+/*
+ * Handle selecting one of the tabs.
+ */
+    static void
+on_select_tab(
+       GtkNotebook     *notebook UNUSED,
+       gpointer        *page UNUSED,
+       gint            idx,
+       gpointer        data UNUSED)
+{
+    if (!ignore_tabline_evt)
+       send_tabline_event(idx + 1);
+}
+
+/*
+ * Handle reordering the tabs (using D&D).
+ */
+    static void
+on_tab_reordered(
+       GtkNotebook     *notebook UNUSED,
+       gpointer        *page UNUSED,
+       gint            idx,
+       gpointer        data UNUSED)
+{
+    if (ignore_tabline_evt)
+       return;
+
+    if ((tabpage_index(curtab) - 1) < idx)
+       tabpage_move(idx + 1);
+    else
+       tabpage_move(idx);
+}
 #endif
 
 /*
index d3977ad1ffb47e346b9f452ac8a809d0fd55f9da..31d5a230597764562e2dc84606ec2b3d7a37e2be 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    564,
 /**/
     563,
 /**/