1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-18 11:31:00 -05:00

Windows: move GUI timer handling into a utils module.

Previously, the timing.c subsystem worked in Windows PuTTY by means of
scheduling WM_TIMER messages to be sent to the terminal window. Now it
uses a separate hidden window instead, and all the machinery for
handling that window lives on its own in windows/utils/gui-timing.c.

Most immediately, this removes a use of wgs.term_hwnd that will become
awkward when I move that structure in a following commit. But also, it
will make it easier to add the same timing subsystem to unrelated GUI
programs, such as Windows Pageant: if we ever decide to implement
automatic deletion or re-encryption of unused keys after a timeout,
this will help make that easier.
This commit is contained in:
Simon Tatham
2022-09-12 11:57:15 +01:00
parent 307e909b51
commit c674b2da4f
4 changed files with 61 additions and 27 deletions

View File

@ -142,9 +142,6 @@ static const SessionSpecial *specials = NULL;
static HMENU specials_menu = NULL;
static int n_specials = 0;
#define TIMING_TIMER_ID 1234
static long timing_next_time;
static struct {
HMENU menu;
} popup_menus[2];
@ -564,6 +561,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
init_winfuncs();
setup_gui_timing();
conf = conf_new();
/*
@ -2106,19 +2105,6 @@ static void win_seat_notify_remote_exit(Seat *seat)
queue_toplevel_callback(exit_callback, NULL);
}
void timer_change_notify(unsigned long next)
{
unsigned long now = GETTICKCOUNT();
long ticks;
if (now - next < INT_MAX)
ticks = 0;
else
ticks = next - now;
KillTimer(wgs.term_hwnd, TIMING_TIMER_ID);
SetTimer(wgs.term_hwnd, TIMING_TIMER_ID, ticks, NULL);
timing_next_time = next;
}
static void conf_cache_data(void)
{
/* Cache some items from conf to speed lookups in very hot code */
@ -2195,17 +2181,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
int resize_action;
switch (message) {
case WM_TIMER:
if ((UINT_PTR)wParam == TIMING_TIMER_ID) {
unsigned long next;
KillTimer(hwnd, TIMING_TIMER_ID);
if (run_timers(timing_next_time, &next)) {
timer_change_notify(next);
} else {
}
}
return 0;
case WM_CREATE:
break;
case WM_CLOSE: {