# HG changeset patch # User Bram Moolenaar # Date 1650740403 -7200 # Node ID 278a14b00896e69f2a49541669ff492373c3a3e7 # Parent 668a94bb0e5e6af201cde0f713c3e5eb237bf3ab patch 8.2.4815: cannot build with older GTK version Commit: https://github.com/vim/vim/commit/d42b83942e6741de2bb630ee17a2e9fcc03d6b43 Author: Ernie Rael Date: Sat Apr 23 19:52:23 2022 +0100 patch 8.2.4815: cannot build with older GTK version Problem: Cannot build with older GTK version. Solution: Use gtk_window_get_size() instead of gdk_window_get_width() and gdk_window_get_height(). (Ernie Rael, closes #10257) diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -396,6 +396,9 @@ static int using_gnome = 0; # define using_gnome 0 #endif +// Comment out the following line to ignore code for resize history tracking. +#define TRACK_RESIZE_HISTORY +#ifdef TRACK_RESIZE_HISTORY /* * Keep a short term resize history so that stale gtk responses can be * discarded. @@ -403,11 +406,11 @@ static int using_gnome = 0; * the request is saved. Recent stale requests are kept around in a list. * See https://github.com/vim/vim/issues/10123 */ -#if 0 // Change to 1 to enable ch_log() calls for debugging. -# ifdef FEAT_JOB_CHANNEL -# define ENABLE_RESIZE_HISTORY_LOG +# if 0 // Change to 1 to enable ch_log() calls for debugging. +# ifdef FEAT_JOB_CHANNEL +# define ENABLE_RESIZE_HISTORY_LOG +# endif # endif -#endif /* * History item of a resize request. @@ -417,9 +420,9 @@ typedef struct resize_history { int used; // If true, can't match for discard. Only matches once. int width; int height; -#ifdef ENABLE_RESIZE_HISTORY_LOG +# ifdef ENABLE_RESIZE_HISTORY_LOG int seq; // for ch_log messages -#endif +# endif struct resize_history *next; } resize_hist_T; @@ -448,11 +451,11 @@ alloc_resize_hist(int width, int height) prev_hist->next = old_resize_hists; old_resize_hists = prev_hist; -#ifdef ENABLE_RESIZE_HISTORY_LOG +# ifdef ENABLE_RESIZE_HISTORY_LOG new_hist->seq = prev_hist->seq + 1; ch_log(NULL, "gui_gtk: New resize seq %d (%d, %d) [%d, %d]", new_hist->seq, width, height, (int)Columns, (int)Rows); -#endif +# endif } /* @@ -462,9 +465,9 @@ alloc_resize_hist(int width, int height) static void clear_resize_hists() { -#ifdef ENABLE_RESIZE_HISTORY_LOG +# ifdef ENABLE_RESIZE_HISTORY_LOG int i = 0; -#endif +# endif if (latest_resize_hist) latest_resize_hist->used = TRUE; @@ -474,17 +477,17 @@ clear_resize_hists() vim_free(old_resize_hists); old_resize_hists = next_hist; -#ifdef ENABLE_RESIZE_HISTORY_LOG +# ifdef ENABLE_RESIZE_HISTORY_LOG i++; -#endif - } -#ifdef ENABLE_RESIZE_HISTORY_LOG +# endif + } +# ifdef ENABLE_RESIZE_HISTORY_LOG ch_log(NULL, "gui_gtk: free %d hists", i); -#endif +# endif } // true if hist item is unused and matches w,h -#define MATCH_WIDTH_HEIGHT(hist, w, h) \ +# define MATCH_WIDTH_HEIGHT(hist, w, h) \ (!hist->used && hist->width == w && hist->height == h) /* @@ -501,23 +504,24 @@ match_stale_width_height(int width, int for (hist = old_resize_hists; hist != NULL; hist = hist->next) if (MATCH_WIDTH_HEIGHT(hist, width, height)) { -#ifdef ENABLE_RESIZE_HISTORY_LOG +# ifdef ENABLE_RESIZE_HISTORY_LOG ch_log(NULL, "gui_gtk: discard seq %d, cur seq %d", hist->seq, latest_resize_hist->seq); -#endif +# endif hist->used = TRUE; return TRUE; } return FALSE; } -#if defined(EXITFREE) +# if defined(EXITFREE) static void free_all_resize_hist() { clear_resize_hists(); vim_free(latest_resize_hist); } +# endif #endif /* @@ -717,7 +721,9 @@ gui_mch_free_all(void) #if defined(USE_GNOME_SESSION) vim_free(abs_restart_command); #endif +#ifdef TRACK_RESIZE_HISTORY free_all_resize_hist(); +#endif } #endif @@ -4131,26 +4137,26 @@ form_configure_event(GtkWidget *widget U GdkEventConfigure *event, gpointer data UNUSED) { - int usable_height = event->height; - // Resize requests are made for gui.mainwin, - // get it's dimensions for searching if this event + int usable_height = event->height; +#ifdef TRACK_RESIZE_HISTORY + // Resize requests are made for gui.mainwin; + // get its dimensions for searching if this event // is a response to a vim request. - GdkWindow *win = gtk_widget_get_window(gui.mainwin); - int w = gdk_window_get_width(win); - int h = gdk_window_get_height(win); - -#ifdef ENABLE_RESIZE_HISTORY_LOG + int w, h; + gtk_window_get_size(GTK_WINDOW(gui.mainwin), &w, &h); + +# ifdef ENABLE_RESIZE_HISTORY_LOG ch_log(NULL, "gui_gtk: form_configure_event: (%d, %d) [%d, %d]", w, h, (int)Columns, (int)Rows); -#endif - - // Look through history of recent vim resize reqeusts. +# endif + + // Look through history of recent vim resize requests. // If this event matches: // - "latest resize hist" We're caught up; // clear the history and process this event. // If history is, old to new, 100, 99, 100, 99. If this event is // 99 for the stale, it is matched against the current. History - // is cleared, we my bounce, but no worse than before. + // is cleared, we may bounce, but no worse than before. // - "older/stale hist" If match an unused event in history, // then discard this event, and mark the matching event as used. // - "no match" Figure it's a user resize event, clear history. @@ -4161,6 +4167,7 @@ form_configure_event(GtkWidget *widget U // discard stale event return TRUE; clear_resize_hists(); +#endif #if GTK_CHECK_VERSION(3,22,2) && !GTK_CHECK_VERSION(3,22,4) // As of 3.22.2, GdkWindows have started distributing configure events to @@ -4483,7 +4490,9 @@ gui_mch_open(void) * manager upon us and should not interfere with what VIM is requesting * upon startup. */ +#ifdef TRACK_RESIZE_HISTORY latest_resize_hist = ALLOC_CLEAR_ONE(resize_hist_T); +#endif g_signal_connect(G_OBJECT(gui.formwin), "configure-event", G_CALLBACK(form_configure_event), NULL); @@ -4671,7 +4680,9 @@ gui_mch_set_shellsize(int width, int hei width += get_menu_tool_width(); height += get_menu_tool_height(); +#ifdef TRACK_RESIZE_HISTORY alloc_resize_hist(width, height); // track the resize request +#endif if (gtk_socket_id == 0) gtk_window_resize(GTK_WINDOW(gui.mainwin), width, height); else diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4815, +/**/ 4814, /**/ 4813,