mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22:48 -05:00
Move window resize timeouts into the GTK frontend.
In the changes around commit 420fe75552
, I made the terminal
suspend output processing while it waited for a term_size() callback
in response to a resize request. Because on X11 there are unusual
circumstances in which you never receive that callback, I also added a
last-ditch 5-second timeout, so that eventually we'll resume terminal
output processing regardless.
But the timeout lives in terminal.c, in the cross-platform code. This
is pointless on Windows (where resize processing is synchronous, so we
always finish it before the timer code next gets called anyway), but I
decided it was easier to keep the whole mechanism in terminal.c in the
absence of a good reason not to.
Now I've found that reason. We _also_ generate window resizes locally
to the GTK front end, in response to the key combinations that change
the font size, and _those_ still have an asynchrony problem.
So, to begin with, I'm refactoring the request_resize system so that
now there's an explicit callback from the frontend to the terminal to
say 'Your resize request has now been processed, whether or not you've
received a term_size() call'. On Windows, this simplifies matters
greatly because we always know exactly when to call that, and don't
have to keep a 'have we called term_size() already?' flag. On GTK, the
timing complexity previously in terminal.c has moved into window.c.
No functional change (I hope). The payoff will be in the next commit.
This commit is contained in:
@ -1220,12 +1220,6 @@ static void term_timer(void *ctx, unsigned long now)
|
||||
|
||||
if (term->window_update_pending)
|
||||
term_update_callback(term);
|
||||
|
||||
if (term->win_resize_pending == WIN_RESIZE_AWAIT_REPLY &&
|
||||
now == term->win_resize_timeout) {
|
||||
term->win_resize_pending = WIN_RESIZE_NO;
|
||||
queue_toplevel_callback(term_out_cb, term);
|
||||
}
|
||||
}
|
||||
|
||||
static void term_update_callback(void *ctx)
|
||||
@ -1426,8 +1420,6 @@ void term_update(Terminal *term)
|
||||
term->win_resize_pending = WIN_RESIZE_AWAIT_REPLY;
|
||||
win_request_resize(term->win, term->win_resize_pending_w,
|
||||
term->win_resize_pending_h);
|
||||
term->win_resize_timeout = schedule_timer(
|
||||
WIN_RESIZE_TIMEOUT, term_timer, term);
|
||||
}
|
||||
if (term->win_zorder_pending) {
|
||||
win_set_zorder(term->win, term->win_zorder_top);
|
||||
@ -2151,14 +2143,6 @@ void term_size(Terminal *term, int newrows, int newcols, int newsavelines)
|
||||
int sblen;
|
||||
int save_alt_which = term->alt_which;
|
||||
|
||||
/* If we were holding buffered terminal data because we were
|
||||
* waiting for confirmation of a resize, queue a callback to start
|
||||
* processing it again. */
|
||||
if (term->win_resize_pending == WIN_RESIZE_AWAIT_REPLY) {
|
||||
term->win_resize_pending = WIN_RESIZE_NO;
|
||||
queue_toplevel_callback(term_out_cb, term);
|
||||
}
|
||||
|
||||
if (newrows == term->rows && newcols == term->cols &&
|
||||
newsavelines == term->savelines)
|
||||
return; /* nothing to do */
|
||||
@ -2336,6 +2320,13 @@ void term_size(Terminal *term, int newrows, int newcols, int newsavelines)
|
||||
backend_size(term->backend, term->cols, term->rows);
|
||||
}
|
||||
|
||||
void term_resize_request_completed(Terminal *term)
|
||||
{
|
||||
assert(term->win_resize_pending == WIN_RESIZE_AWAIT_REPLY);
|
||||
term->win_resize_pending = WIN_RESIZE_NO;
|
||||
queue_toplevel_callback(term_out_cb, term);
|
||||
}
|
||||
|
||||
/*
|
||||
* Hand a backend to the terminal, so it can be notified of resizes.
|
||||
*/
|
||||
|
@ -427,24 +427,6 @@ struct terminal_tag {
|
||||
WIN_RESIZE_NO, WIN_RESIZE_NEED_SEND, WIN_RESIZE_AWAIT_REPLY
|
||||
} win_resize_pending;
|
||||
int win_resize_pending_w, win_resize_pending_h;
|
||||
|
||||
/*
|
||||
* Not every frontend / TermWin implementation can be relied on
|
||||
* 100% to reply to a resize request in a timely manner. (In X11
|
||||
* it's all asynchronous and goes via the window manager, and if
|
||||
* your window manager is seriously unwell, you'd rather not have
|
||||
* terminal windows start becoming unusable as a knock-on effect,
|
||||
* since those are just the thing you might need to use for
|
||||
* emergency WM maintenance!) So when we enter AWAIT_REPLY status,
|
||||
* we also set a 5-second timer, after which we'll regretfully
|
||||
* conclude that a resize is probably not going to happen after
|
||||
* all.
|
||||
*
|
||||
* However, in non-emergency cases, the plan is that this
|
||||
* shouldn't be needed, for one reason or another.
|
||||
*/
|
||||
long win_resize_timeout;
|
||||
#define WIN_RESIZE_TIMEOUT (TICKSPERSEC*5)
|
||||
};
|
||||
|
||||
static inline bool in_utf(Terminal *term)
|
||||
|
Reference in New Issue
Block a user