1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 01:18:00 +00:00

windows/window.c: move more variables into WinGuiSeat.

In commit f9e572595b I claimed that I'd removed very nearly all
the global and static variables from windows/window.c. It turns out
that this was wildly overoptimistic - I missed quite a few of them!
I'm not quite sure how I managed that; my best guess is that I used an
underpowered 'nm' command that failed to find some classes of
variable.

Some of the remaining function-scope statics were removed completely
by commit afb3dab1e9 just now. In this commit, I've swept up some
more and turn them into fields of WinGuiSeat, where they should have
been moved last September.

The (hopefully complete this time) list of remaining variables,
generated by running this rune in the Windows build directory:

  nm windows/CMakeFiles/putty.dir/window.c.obj |
     grep -E '^([^ ]+)? *[bBcCdDgGsS] [^\.]'

consists of the following variables which are legitimately global
across the whole process and not related to a particular window:

 - 'hinst' and 'hprev', instance handles for Windows loadable modules

 - 'classname' in the terminal_window_class_a() and
   terminal_window_class_w() functions, which allocate a window class
   reusably

 - some pointers to Windows API functions retrieved via the
   DECL_WINDOWS_FUNCTION / GET_WINDOWS_FUNCTION system, such as
   p_AdjustWindowRectExForDpi and p_FlashWindowEx

 - some pointers to Windows API functions set up by assigning them at
   startup to the right one of the ANSI or Unicode version depending on
   the Windows version, e.g. sw_DefWindowProc and sw_DispatchMessage

 - 'unicode_window', a boolean flag set at the same time as those
   sw_Foo function pointers

 - 'sesslist', storing the last-retrieved version of the saved
   sessions menu

 - 'cursor_visible' in show_mouseptr() and 'forced_visible' in
   update_mouse_pointer(), each of which tracks the cumulative number
   of times that function has shown or hidden the mouse pointer, so as
   to manage its effect on the global state updated by ShowCursor

 - 'trust_icon', loaded from the executable's resources

 - 'wgslisthead', the list of all active WinGuiSeats

 - 'wm_mousewheel', the window-message id we use for mouse wheel
   events

and the following which are nothing to do with our code:

 - '_OptionsStorage' in __local_stdio_printf_options() and
   __local_stdio_scanf_options(), which I'd never noticed before, but
   apparently are internal to a standard library header.
This commit is contained in:
Simon Tatham 2023-05-27 14:59:20 +01:00
parent 322984d635
commit 6aca7f1eef
2 changed files with 305 additions and 272 deletions

View File

@ -59,6 +59,14 @@ struct WinGuiSeat {
HWND term_hwnd;
int extra_width, extra_height;
int font_width, font_height;
bool font_dualwidth, font_varpitch;
int offset_width, offset_height;
bool was_zoomed;
int prev_rows, prev_cols; // FIXME I don't think these are even used
HBITMAP caretbm;
int caret_x, caret_y;
int kbd_codepage;
@ -115,14 +123,29 @@ struct WinGuiSeat {
wchar_t *window_name, *icon_name;
int alt_numberpad_accumulator;
int compose_state;
int compose_char;
WPARAM compose_keycode;
HDC wintw_hdc;
bool resizing;
bool need_backend_resize;
long next_flash;
bool flashing;
long last_beep_time;
bool ignore_clip;
bool fullscr_on_max;
bool processed_resize;
bool in_scrollbar_loop;
UINT last_mousemove;
WPARAM last_wm_mousemove_wParam, last_wm_ncmousemove_wParam;
LPARAM last_wm_mousemove_lParam, last_wm_ncmousemove_lParam;
wchar_t pending_surrogate;
};
extern const LogPolicyVtable win_gui_logpolicy_vt; /* in dialog.c */

File diff suppressed because it is too large Load Diff