forked from aniani/vim
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)
This commit is contained in:
committed by
Bram Moolenaar
parent
4a392d2440
commit
d42b83942e
@@ -396,6 +396,9 @@ static int using_gnome = 0;
|
|||||||
# define using_gnome 0
|
# define using_gnome 0
|
||||||
#endif
|
#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
|
* Keep a short term resize history so that stale gtk responses can be
|
||||||
* discarded.
|
* discarded.
|
||||||
@@ -403,11 +406,11 @@ static int using_gnome = 0;
|
|||||||
* the request is saved. Recent stale requests are kept around in a list.
|
* the request is saved. Recent stale requests are kept around in a list.
|
||||||
* See https://github.com/vim/vim/issues/10123
|
* See https://github.com/vim/vim/issues/10123
|
||||||
*/
|
*/
|
||||||
#if 0 // Change to 1 to enable ch_log() calls for debugging.
|
# if 0 // Change to 1 to enable ch_log() calls for debugging.
|
||||||
# ifdef FEAT_JOB_CHANNEL
|
# ifdef FEAT_JOB_CHANNEL
|
||||||
# define ENABLE_RESIZE_HISTORY_LOG
|
# define ENABLE_RESIZE_HISTORY_LOG
|
||||||
# endif
|
# endif
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* History item of a resize request.
|
* 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 used; // If true, can't match for discard. Only matches once.
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
#ifdef ENABLE_RESIZE_HISTORY_LOG
|
# ifdef ENABLE_RESIZE_HISTORY_LOG
|
||||||
int seq; // for ch_log messages
|
int seq; // for ch_log messages
|
||||||
#endif
|
# endif
|
||||||
struct resize_history *next;
|
struct resize_history *next;
|
||||||
} resize_hist_T;
|
} resize_hist_T;
|
||||||
|
|
||||||
@@ -448,11 +451,11 @@ alloc_resize_hist(int width, int height)
|
|||||||
prev_hist->next = old_resize_hists;
|
prev_hist->next = old_resize_hists;
|
||||||
old_resize_hists = prev_hist;
|
old_resize_hists = prev_hist;
|
||||||
|
|
||||||
#ifdef ENABLE_RESIZE_HISTORY_LOG
|
# ifdef ENABLE_RESIZE_HISTORY_LOG
|
||||||
new_hist->seq = prev_hist->seq + 1;
|
new_hist->seq = prev_hist->seq + 1;
|
||||||
ch_log(NULL, "gui_gtk: New resize seq %d (%d, %d) [%d, %d]",
|
ch_log(NULL, "gui_gtk: New resize seq %d (%d, %d) [%d, %d]",
|
||||||
new_hist->seq, width, height, (int)Columns, (int)Rows);
|
new_hist->seq, width, height, (int)Columns, (int)Rows);
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -462,9 +465,9 @@ alloc_resize_hist(int width, int height)
|
|||||||
static void
|
static void
|
||||||
clear_resize_hists()
|
clear_resize_hists()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_RESIZE_HISTORY_LOG
|
# ifdef ENABLE_RESIZE_HISTORY_LOG
|
||||||
int i = 0;
|
int i = 0;
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
if (latest_resize_hist)
|
if (latest_resize_hist)
|
||||||
latest_resize_hist->used = TRUE;
|
latest_resize_hist->used = TRUE;
|
||||||
@@ -474,17 +477,17 @@ clear_resize_hists()
|
|||||||
|
|
||||||
vim_free(old_resize_hists);
|
vim_free(old_resize_hists);
|
||||||
old_resize_hists = next_hist;
|
old_resize_hists = next_hist;
|
||||||
#ifdef ENABLE_RESIZE_HISTORY_LOG
|
# ifdef ENABLE_RESIZE_HISTORY_LOG
|
||||||
i++;
|
i++;
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_RESIZE_HISTORY_LOG
|
# ifdef ENABLE_RESIZE_HISTORY_LOG
|
||||||
ch_log(NULL, "gui_gtk: free %d hists", i);
|
ch_log(NULL, "gui_gtk: free %d hists", i);
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// true if hist item is unused and matches w,h
|
// 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)
|
(!hist->used && hist->width == w && hist->height == h)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -501,23 +504,24 @@ match_stale_width_height(int width, int height)
|
|||||||
for (hist = old_resize_hists; hist != NULL; hist = hist->next)
|
for (hist = old_resize_hists; hist != NULL; hist = hist->next)
|
||||||
if (MATCH_WIDTH_HEIGHT(hist, width, height))
|
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",
|
ch_log(NULL, "gui_gtk: discard seq %d, cur seq %d",
|
||||||
hist->seq, latest_resize_hist->seq);
|
hist->seq, latest_resize_hist->seq);
|
||||||
#endif
|
# endif
|
||||||
hist->used = TRUE;
|
hist->used = TRUE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(EXITFREE)
|
# if defined(EXITFREE)
|
||||||
static void
|
static void
|
||||||
free_all_resize_hist()
|
free_all_resize_hist()
|
||||||
{
|
{
|
||||||
clear_resize_hists();
|
clear_resize_hists();
|
||||||
vim_free(latest_resize_hist);
|
vim_free(latest_resize_hist);
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -717,7 +721,9 @@ gui_mch_free_all(void)
|
|||||||
#if defined(USE_GNOME_SESSION)
|
#if defined(USE_GNOME_SESSION)
|
||||||
vim_free(abs_restart_command);
|
vim_free(abs_restart_command);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef TRACK_RESIZE_HISTORY
|
||||||
free_all_resize_hist();
|
free_all_resize_hist();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -4132,25 +4138,25 @@ form_configure_event(GtkWidget *widget UNUSED,
|
|||||||
gpointer data UNUSED)
|
gpointer data UNUSED)
|
||||||
{
|
{
|
||||||
int usable_height = event->height;
|
int usable_height = event->height;
|
||||||
// Resize requests are made for gui.mainwin,
|
#ifdef TRACK_RESIZE_HISTORY
|
||||||
// get it's dimensions for searching if this event
|
// Resize requests are made for gui.mainwin;
|
||||||
|
// get its dimensions for searching if this event
|
||||||
// is a response to a vim request.
|
// is a response to a vim request.
|
||||||
GdkWindow *win = gtk_widget_get_window(gui.mainwin);
|
int w, h;
|
||||||
int w = gdk_window_get_width(win);
|
gtk_window_get_size(GTK_WINDOW(gui.mainwin), &w, &h);
|
||||||
int h = gdk_window_get_height(win);
|
|
||||||
|
|
||||||
#ifdef ENABLE_RESIZE_HISTORY_LOG
|
# ifdef ENABLE_RESIZE_HISTORY_LOG
|
||||||
ch_log(NULL, "gui_gtk: form_configure_event: (%d, %d) [%d, %d]",
|
ch_log(NULL, "gui_gtk: form_configure_event: (%d, %d) [%d, %d]",
|
||||||
w, h, (int)Columns, (int)Rows);
|
w, h, (int)Columns, (int)Rows);
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
// Look through history of recent vim resize reqeusts.
|
// Look through history of recent vim resize requests.
|
||||||
// If this event matches:
|
// If this event matches:
|
||||||
// - "latest resize hist" We're caught up;
|
// - "latest resize hist" We're caught up;
|
||||||
// clear the history and process this event.
|
// clear the history and process this event.
|
||||||
// If history is, old to new, 100, 99, 100, 99. If this event is
|
// 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
|
// 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,
|
// - "older/stale hist" If match an unused event in history,
|
||||||
// then discard this event, and mark the matching event as used.
|
// then discard this event, and mark the matching event as used.
|
||||||
// - "no match" Figure it's a user resize event, clear history.
|
// - "no match" Figure it's a user resize event, clear history.
|
||||||
@@ -4161,6 +4167,7 @@ form_configure_event(GtkWidget *widget UNUSED,
|
|||||||
// discard stale event
|
// discard stale event
|
||||||
return TRUE;
|
return TRUE;
|
||||||
clear_resize_hists();
|
clear_resize_hists();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if GTK_CHECK_VERSION(3,22,2) && !GTK_CHECK_VERSION(3,22,4)
|
#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
|
// 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
|
* manager upon us and should not interfere with what VIM is requesting
|
||||||
* upon startup.
|
* upon startup.
|
||||||
*/
|
*/
|
||||||
|
#ifdef TRACK_RESIZE_HISTORY
|
||||||
latest_resize_hist = ALLOC_CLEAR_ONE(resize_hist_T);
|
latest_resize_hist = ALLOC_CLEAR_ONE(resize_hist_T);
|
||||||
|
#endif
|
||||||
g_signal_connect(G_OBJECT(gui.formwin), "configure-event",
|
g_signal_connect(G_OBJECT(gui.formwin), "configure-event",
|
||||||
G_CALLBACK(form_configure_event), NULL);
|
G_CALLBACK(form_configure_event), NULL);
|
||||||
|
|
||||||
@@ -4671,7 +4680,9 @@ gui_mch_set_shellsize(int width, int height,
|
|||||||
width += get_menu_tool_width();
|
width += get_menu_tool_width();
|
||||||
height += get_menu_tool_height();
|
height += get_menu_tool_height();
|
||||||
|
|
||||||
|
#ifdef TRACK_RESIZE_HISTORY
|
||||||
alloc_resize_hist(width, height); // track the resize request
|
alloc_resize_hist(width, height); // track the resize request
|
||||||
|
#endif
|
||||||
if (gtk_socket_id == 0)
|
if (gtk_socket_id == 0)
|
||||||
gtk_window_resize(GTK_WINDOW(gui.mainwin), width, height);
|
gtk_window_resize(GTK_WINDOW(gui.mainwin), width, height);
|
||||||
else
|
else
|
||||||
|
@@ -746,6 +746,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4815,
|
||||||
/**/
|
/**/
|
||||||
4814,
|
4814,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user