mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12: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:
@ -189,6 +189,24 @@ struct GtkFrontend {
|
||||
#endif
|
||||
int trust_sigil_w, trust_sigil_h;
|
||||
|
||||
/*
|
||||
* Not every GDK backend 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 ask GTK to resize our terminal window, we also set a
|
||||
* 5-second timer, after which we'll regretfully conclude that a
|
||||
* resize (or ConfigureNotify telling us no resize took place) is
|
||||
* probably not going to happen after all.
|
||||
*/
|
||||
bool win_resize_pending, term_resize_notification_required;
|
||||
long win_resize_timeout;
|
||||
#define WIN_RESIZE_TIMEOUT (TICKSPERSEC*5)
|
||||
|
||||
Seat seat;
|
||||
TermWin termwin;
|
||||
LogPolicy logpolicy;
|
||||
@ -759,6 +777,10 @@ static void drawing_area_setup(GtkFrontend *inst, int width, int height)
|
||||
inst->drawing_area_setup_called = true;
|
||||
if (inst->term)
|
||||
term_size(inst->term, h, w, conf_get_int(inst->conf, CONF_savelines));
|
||||
if (inst->term_resize_notification_required)
|
||||
term_resize_request_completed(inst->term);
|
||||
if (inst->win_resize_pending)
|
||||
inst->win_resize_pending = false;
|
||||
|
||||
if (!inst->drawing_area_setup_needed)
|
||||
return;
|
||||
@ -2480,6 +2502,17 @@ static void gtkwin_deny_term_resize(void *vctx)
|
||||
drawing_area_setup_simple(inst);
|
||||
}
|
||||
|
||||
static void gtkwin_timer(void *vctx, unsigned long now)
|
||||
{
|
||||
GtkFrontend *inst = (GtkFrontend *)vctx;
|
||||
|
||||
if (inst->win_resize_pending && now == inst->win_resize_timeout) {
|
||||
if (inst->term_resize_notification_required)
|
||||
term_resize_request_completed(inst->term);
|
||||
inst->win_resize_pending = false;
|
||||
}
|
||||
}
|
||||
|
||||
static void gtkwin_request_resize(TermWin *tw, int w, int h)
|
||||
{
|
||||
GtkFrontend *inst = container_of(tw, GtkFrontend, termwin);
|
||||
@ -2525,6 +2558,7 @@ static void gtkwin_request_resize(TermWin *tw, int w, int h)
|
||||
#endif
|
||||
0)) {
|
||||
queue_toplevel_callback(gtkwin_deny_term_resize, inst);
|
||||
term_resize_request_completed(inst->term);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2613,6 +2647,10 @@ static void gtkwin_request_resize(TermWin *tw, int w, int h)
|
||||
|
||||
#endif
|
||||
|
||||
inst->win_resize_pending = true;
|
||||
inst->term_resize_notification_required = true;
|
||||
inst->win_resize_timeout = schedule_timer(
|
||||
WIN_RESIZE_TIMEOUT, gtkwin_timer, inst);
|
||||
}
|
||||
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
|
Reference in New Issue
Block a user