From 99dfc66457d19f0769a0b5cfe9dd7f924e22ee71 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 7 Feb 2021 19:59:21 +0000 Subject: [PATCH] Decouple frontend's raw mouse mode from pointer shape. This paves the way for a followup commit that will make them happen at slightly different times. --- putty.h | 8 ++++++++ terminal.c | 2 ++ unix/gtkwin.c | 13 +++++++++---- windows/window.c | 14 ++++++++++---- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/putty.h b/putty.h index 54a072e4..1200b4da 100644 --- a/putty.h +++ b/putty.h @@ -1246,7 +1246,13 @@ struct TermWinVtable { void (*set_cursor_pos)(TermWin *, int x, int y); + /* set_raw_mouse_mode instructs the front end to start sending mouse events + * in raw mode suitable for translating into mouse-tracking terminal data + * (e.g. include scroll-wheel events and don't bother to identify double- + * and triple-clicks). set_raw_mouse_mode_pointer instructs the front end + * to change the mouse pointer shape to *indicate* raw mouse mode. */ void (*set_raw_mouse_mode)(TermWin *, bool enable); + void (*set_raw_mouse_mode_pointer)(TermWin *, bool enable); void (*set_scrollbar)(TermWin *, int total, int start, int page); @@ -1304,6 +1310,8 @@ static inline void win_set_cursor_pos(TermWin *win, int x, int y) { win->vt->set_cursor_pos(win, x, y); } static inline void win_set_raw_mouse_mode(TermWin *win, bool enable) { win->vt->set_raw_mouse_mode(win, enable); } +static inline void win_set_raw_mouse_mode_pointer(TermWin *win, bool enable) +{ win->vt->set_raw_mouse_mode_pointer(win, enable); } static inline void win_set_scrollbar(TermWin *win, int t, int s, int p) { win->vt->set_scrollbar(win, t, s, p); } static inline void win_bell(TermWin *win, int mode) diff --git a/terminal.c b/terminal.c index 9fc2ea53..0b9411b5 100644 --- a/terminal.c +++ b/terminal.c @@ -1357,6 +1357,7 @@ static void power_on(Terminal *term, bool clear) term->xterm_extended_mouse = false; term->urxvt_extended_mouse = false; win_set_raw_mouse_mode(term->win, false); + win_set_raw_mouse_mode_pointer(term->win, false); term->bracketed_paste = false; term->srm_echo = false; { @@ -2829,6 +2830,7 @@ static void term_update_raw_mouse_mode(Terminal *term) { bool want_raw = (term->xterm_mouse != 0 && !term->xterm_mouse_forbidden); win_set_raw_mouse_mode(term->win, want_raw); + win_set_raw_mouse_mode_pointer(term->win, want_raw); } /* diff --git a/unix/gtkwin.c b/unix/gtkwin.c index 8178aba2..b9c5ad0e 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -179,6 +179,7 @@ struct GtkFrontend { int system_mod_mask; #endif bool send_raw_mouse; + bool pointer_indicates_raw_mouse; unifont_drawctx uctx; #if GTK_CHECK_VERSION(2,0,0) GdkPixbuf *trust_sigil_pb; @@ -647,7 +648,7 @@ static void update_mouseptr(GtkFrontend *inst) if (!inst->mouseptr_visible) { gdk_window_set_cursor(gtk_widget_get_window(inst->area), inst->blankcursor); - } else if (inst->send_raw_mouse) { + } else if (inst->pointer_indicates_raw_mouse) { gdk_window_set_cursor(gtk_widget_get_window(inst->area), inst->rawcursor); } else { @@ -2397,13 +2398,16 @@ static void gtk_seat_set_busy_status(Seat *seat, BusyStatus status) update_mouseptr(inst); } -/* - * set or clear the "raw mouse message" mode - */ static void gtkwin_set_raw_mouse_mode(TermWin *tw, bool activate) { GtkFrontend *inst = container_of(tw, GtkFrontend, termwin); inst->send_raw_mouse = activate; +} + +static void gtkwin_set_raw_mouse_mode_pointer(TermWin *tw, bool activate) +{ + GtkFrontend *inst = container_of(tw, GtkFrontend, termwin); + inst->pointer_indicates_raw_mouse = activate; update_mouseptr(inst); } @@ -5023,6 +5027,7 @@ static const TermWinVtable gtk_termwin_vt = { .free_draw_ctx = gtkwin_free_draw_ctx, .set_cursor_pos = gtkwin_set_cursor_pos, .set_raw_mouse_mode = gtkwin_set_raw_mouse_mode, + .set_raw_mouse_mode_pointer = gtkwin_set_raw_mouse_mode_pointer, .set_scrollbar = gtkwin_set_scrollbar, .bell = gtkwin_bell, .clip_write = gtkwin_clip_write, diff --git a/windows/window.c b/windows/window.c index bbd5a8d1..ca778c4d 100644 --- a/windows/window.c +++ b/windows/window.c @@ -202,6 +202,8 @@ static Mouse_Button lastbtn; static bool send_raw_mouse = false; static int wheel_accumulator = 0; +static bool pointer_indicates_raw_mouse = false; + static BusyStatus busy_status = BUSY_NOT; static char *window_name, *icon_name; @@ -226,6 +228,7 @@ static int wintw_char_width(TermWin *, int uc); static void wintw_free_draw_ctx(TermWin *); static void wintw_set_cursor_pos(TermWin *, int x, int y); static void wintw_set_raw_mouse_mode(TermWin *, bool enable); +static void wintw_set_raw_mouse_mode_pointer(TermWin *, bool enable); static void wintw_set_scrollbar(TermWin *, int total, int start, int page); static void wintw_bell(TermWin *, int mode); static void wintw_clip_write( @@ -252,6 +255,7 @@ static const TermWinVtable windows_termwin_vt = { .free_draw_ctx = wintw_free_draw_ctx, .set_cursor_pos = wintw_set_cursor_pos, .set_raw_mouse_mode = wintw_set_raw_mouse_mode, + .set_raw_mouse_mode_pointer = wintw_set_raw_mouse_mode_pointer, .set_scrollbar = wintw_set_scrollbar, .bell = wintw_bell, .clip_write = wintw_clip_write, @@ -1087,7 +1091,7 @@ static void update_mouse_pointer(void) static bool forced_visible = false; switch (busy_status) { case BUSY_NOT: - if (send_raw_mouse) + if (pointer_indicates_raw_mouse) curstype = IDC_ARROW; else curstype = IDC_IBEAM; @@ -1124,12 +1128,14 @@ static void win_seat_set_busy_status(Seat *seat, BusyStatus status) update_mouse_pointer(); } -/* - * set or clear the "raw mouse message" mode - */ static void wintw_set_raw_mouse_mode(TermWin *tw, bool activate) { send_raw_mouse = activate; +} + +static void wintw_set_raw_mouse_mode_pointer(TermWin *tw, bool activate) +{ + pointer_indicates_raw_mouse = activate; update_mouse_pointer(); }