From 5e055a374f02127efdb5fdb6a1f6c809d7e17dc7 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 29 May 2023 15:52:32 +0100 Subject: [PATCH] Cleanup: make an enum for the values of CONF_mouse_is_xterm. Again, there's no sensible reason why these should be written at the point of use as bare integers. --- putty.h | 7 +++++++ windows/window.c | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/putty.h b/putty.h index c6295fa1..1df29d8b 100644 --- a/putty.h +++ b/putty.h @@ -487,6 +487,13 @@ enum { RESIZE_TERM, RESIZE_DISABLED, RESIZE_FONT, RESIZE_EITHER }; +enum { + /* Mouse-button assignments */ + MOUSE_COMPROMISE, /* xterm-ish but with paste on RB in case no MB exists */ + MOUSE_XTERM, /* xterm-style: MB pastes, RB extends selection */ + MOUSE_WINDOWS /* Windows-style: RB brings up menu. MB still extends. */ +}; + enum { /* Function key types (CONF_funky_type) */ FUNKY_TILDE, diff --git a/windows/window.c b/windows/window.c index 21170614..69cc3d3d 100644 --- a/windows/window.c +++ b/windows/window.c @@ -2046,10 +2046,10 @@ static Mouse_Button translate_button(WinGuiSeat *wgs, Mouse_Button button) if (button == MBT_LEFT) return MBT_SELECT; if (button == MBT_MIDDLE) - return conf_get_int(wgs->conf, CONF_mouse_is_xterm) == 1 ? + return conf_get_int(wgs->conf, CONF_mouse_is_xterm) == MOUSE_XTERM ? MBT_PASTE : MBT_EXTEND; if (button == MBT_RIGHT) - return conf_get_int(wgs->conf, CONF_mouse_is_xterm) == 1 ? + return conf_get_int(wgs->conf, CONF_mouse_is_xterm) == MOUSE_XTERM ? MBT_EXTEND : MBT_PASTE; return 0; /* shouldn't happen */ } @@ -2603,7 +2603,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, case WM_RBUTTONUP: if (message == WM_RBUTTONDOWN && ((wParam & MK_CONTROL) || - (conf_get_int(wgs->conf, CONF_mouse_is_xterm) == 2))) { + (conf_get_int(wgs->conf, CONF_mouse_is_xterm) == MOUSE_WINDOWS))) { POINT cursorpos; /* Just in case this happened in mid-select */