Patch 8.2.4815

9 views
Skip to first unread message

Bram Moolenaar

unread,
Apr 23, 2022, 2:53:09 PM4/23/22
to vim...@googlegroups.com

Patch 8.2.4815 (after 8.2.4776)
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)
Files: src/gui_gtk_x11.c


*** ../vim-8.2.4814/src/gui_gtk_x11.c 2022-04-17 18:27:45.556029572 +0100
--- src/gui_gtk_x11.c 2022-04-23 19:47:12.277864423 +0100
***************
*** 396,401 ****
--- 396,404 ----
# 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,413 ****
* 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
# endif
- #endif

/*
* History item of a resize request.
--- 406,416 ----
* 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
! # endif
# endif

/*
* History item of a resize request.
***************
*** 417,425 ****
int used; // If true, can't match for discard. Only matches once.
int width;
int height;
! #ifdef ENABLE_RESIZE_HISTORY_LOG
int seq; // for ch_log messages
! #endif
struct resize_history *next;
} resize_hist_T;

--- 420,428 ----
int used; // If true, can't match for discard. Only matches once.
int width;
int height;
! # ifdef ENABLE_RESIZE_HISTORY_LOG
int seq; // for ch_log messages
! # endif
struct resize_history *next;
} resize_hist_T;

***************
*** 448,458 ****
prev_hist->next = old_resize_hists;
old_resize_hists = prev_hist;

! #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
}

/*
--- 451,461 ----
prev_hist->next = old_resize_hists;
old_resize_hists = prev_hist;

! # 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
}

/*
***************
*** 462,470 ****
static void
clear_resize_hists()
{
! #ifdef ENABLE_RESIZE_HISTORY_LOG
int i = 0;
! #endif

if (latest_resize_hist)
latest_resize_hist->used = TRUE;
--- 465,473 ----
static void
clear_resize_hists()
{
! # ifdef ENABLE_RESIZE_HISTORY_LOG
int i = 0;
! # endif

if (latest_resize_hist)
latest_resize_hist->used = TRUE;
***************
*** 474,490 ****

vim_free(old_resize_hists);
old_resize_hists = next_hist;
! #ifdef ENABLE_RESIZE_HISTORY_LOG
i++;
! #endif
}
! #ifdef ENABLE_RESIZE_HISTORY_LOG
ch_log(NULL, "gui_gtk: free %d hists", i);
! #endif
}

// true if hist item is unused and matches w,h
! #define MATCH_WIDTH_HEIGHT(hist, w, h) \
(!hist->used && hist->width == w && hist->height == h)

/*
--- 477,493 ----

vim_free(old_resize_hists);
old_resize_hists = next_hist;
! # ifdef ENABLE_RESIZE_HISTORY_LOG
i++;
! # endif
}
! # ifdef ENABLE_RESIZE_HISTORY_LOG
ch_log(NULL, "gui_gtk: free %d hists", i);
! # endif
}

// true if hist item is unused and matches w,h
! # define MATCH_WIDTH_HEIGHT(hist, w, h) \
(!hist->used && hist->width == w && hist->height == h)

/*
***************
*** 501,523 ****
for (hist = old_resize_hists; hist != NULL; hist = hist->next)
if (MATCH_WIDTH_HEIGHT(hist, width, height))
{
! #ifdef ENABLE_RESIZE_HISTORY_LOG
ch_log(NULL, "gui_gtk: discard seq %d, cur seq %d",
hist->seq, latest_resize_hist->seq);
! #endif
hist->used = TRUE;
return TRUE;
}
return FALSE;
}

! #if defined(EXITFREE)
static void
free_all_resize_hist()
{
clear_resize_hists();
vim_free(latest_resize_hist);
}
#endif

/*
--- 504,527 ----
for (hist = old_resize_hists; hist != NULL; hist = hist->next)
if (MATCH_WIDTH_HEIGHT(hist, width, height))
{
! # ifdef ENABLE_RESIZE_HISTORY_LOG
ch_log(NULL, "gui_gtk: discard seq %d, cur seq %d",
hist->seq, latest_resize_hist->seq);
! # endif
hist->used = TRUE;
return TRUE;
}
return FALSE;
}

! # if defined(EXITFREE)
static void
free_all_resize_hist()
{
clear_resize_hists();
vim_free(latest_resize_hist);
}
+ # endif
#endif

/*
***************
*** 717,723 ****
--- 721,729 ----
#if defined(USE_GNOME_SESSION)
vim_free(abs_restart_command);
#endif
+ #ifdef TRACK_RESIZE_HISTORY
free_all_resize_hist();
+ #endif
}
#endif

***************
*** 4131,4156 ****
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
// 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
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.
// 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.
// - "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.
--- 4137,4162 ----
GdkEventConfigure *event,
gpointer data UNUSED)
{
! 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.
! 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 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 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,4166 ****
--- 4167,4173 ----
// 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,4489 ****
--- 4490,4498 ----
* 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,4677 ****
--- 4680,4688 ----
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
*** ../vim-8.2.4814/src/version.c 2022-04-23 14:07:50.934670451 +0100
--- src/version.c 2022-04-23 19:51:25.493549614 +0100
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 4815,
/**/

--
The 50-50-90 rule: Anytime you have a 50-50 chance of getting
something right, there's a 90% probability you'll get it wrong.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Hisashi T Fujinaka

unread,
Apr 23, 2022, 8:52:17 PM4/23/22
to vim...@googlegroups.com
Thanks! That fixed things for me.

--
Hisashi T Fujinaka - ht...@twofifty.com
BSEE + BSChem + BAEnglish + MSCS + $2.50 = coffee
Reply all
Reply to author
Forward
0 new messages