Mercurial > vim
changeset 28582:278a14b00896 v8.2.4815
patch 8.2.4815: cannot build with older GTK version
Commit: https://github.com/vim/vim/commit/d42b83942e6741de2bb630ee17a2e9fcc03d6b43
Author: Ernie Rael <errael@raelity.com>
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 23 Apr 2022 21:00:03 +0200 |
parents | 668a94bb0e5e |
children | 6ebad1100b5f |
files | src/gui_gtk_x11.c src/version.c |
diffstat | 2 files changed, 44 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- 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