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

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.
This commit is contained in:
Simon Tatham 2021-02-07 19:59:21 +00:00
parent 07aff63e22
commit 99dfc66457
4 changed files with 29 additions and 8 deletions

View File

@ -1246,7 +1246,13 @@ struct TermWinVtable {
void (*set_cursor_pos)(TermWin *, int x, int y); 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)(TermWin *, bool enable);
void (*set_raw_mouse_mode_pointer)(TermWin *, bool enable);
void (*set_scrollbar)(TermWin *, int total, int start, int page); 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); } { win->vt->set_cursor_pos(win, x, y); }
static inline void win_set_raw_mouse_mode(TermWin *win, bool enable) static inline void win_set_raw_mouse_mode(TermWin *win, bool enable)
{ win->vt->set_raw_mouse_mode(win, 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) static inline void win_set_scrollbar(TermWin *win, int t, int s, int p)
{ win->vt->set_scrollbar(win, t, s, p); } { win->vt->set_scrollbar(win, t, s, p); }
static inline void win_bell(TermWin *win, int mode) static inline void win_bell(TermWin *win, int mode)

View File

@ -1357,6 +1357,7 @@ static void power_on(Terminal *term, bool clear)
term->xterm_extended_mouse = false; term->xterm_extended_mouse = false;
term->urxvt_extended_mouse = false; term->urxvt_extended_mouse = false;
win_set_raw_mouse_mode(term->win, false); win_set_raw_mouse_mode(term->win, false);
win_set_raw_mouse_mode_pointer(term->win, false);
term->bracketed_paste = false; term->bracketed_paste = false;
term->srm_echo = 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); 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(term->win, want_raw);
win_set_raw_mouse_mode_pointer(term->win, want_raw);
} }
/* /*

View File

@ -179,6 +179,7 @@ struct GtkFrontend {
int system_mod_mask; int system_mod_mask;
#endif #endif
bool send_raw_mouse; bool send_raw_mouse;
bool pointer_indicates_raw_mouse;
unifont_drawctx uctx; unifont_drawctx uctx;
#if GTK_CHECK_VERSION(2,0,0) #if GTK_CHECK_VERSION(2,0,0)
GdkPixbuf *trust_sigil_pb; GdkPixbuf *trust_sigil_pb;
@ -647,7 +648,7 @@ static void update_mouseptr(GtkFrontend *inst)
if (!inst->mouseptr_visible) { if (!inst->mouseptr_visible) {
gdk_window_set_cursor(gtk_widget_get_window(inst->area), gdk_window_set_cursor(gtk_widget_get_window(inst->area),
inst->blankcursor); 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), gdk_window_set_cursor(gtk_widget_get_window(inst->area),
inst->rawcursor); inst->rawcursor);
} else { } else {
@ -2397,13 +2398,16 @@ static void gtk_seat_set_busy_status(Seat *seat, BusyStatus status)
update_mouseptr(inst); update_mouseptr(inst);
} }
/*
* set or clear the "raw mouse message" mode
*/
static void gtkwin_set_raw_mouse_mode(TermWin *tw, bool activate) static void gtkwin_set_raw_mouse_mode(TermWin *tw, bool activate)
{ {
GtkFrontend *inst = container_of(tw, GtkFrontend, termwin); GtkFrontend *inst = container_of(tw, GtkFrontend, termwin);
inst->send_raw_mouse = activate; 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); update_mouseptr(inst);
} }
@ -5023,6 +5027,7 @@ static const TermWinVtable gtk_termwin_vt = {
.free_draw_ctx = gtkwin_free_draw_ctx, .free_draw_ctx = gtkwin_free_draw_ctx,
.set_cursor_pos = gtkwin_set_cursor_pos, .set_cursor_pos = gtkwin_set_cursor_pos,
.set_raw_mouse_mode = gtkwin_set_raw_mouse_mode, .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, .set_scrollbar = gtkwin_set_scrollbar,
.bell = gtkwin_bell, .bell = gtkwin_bell,
.clip_write = gtkwin_clip_write, .clip_write = gtkwin_clip_write,

View File

@ -202,6 +202,8 @@ static Mouse_Button lastbtn;
static bool send_raw_mouse = false; static bool send_raw_mouse = false;
static int wheel_accumulator = 0; static int wheel_accumulator = 0;
static bool pointer_indicates_raw_mouse = false;
static BusyStatus busy_status = BUSY_NOT; static BusyStatus busy_status = BUSY_NOT;
static char *window_name, *icon_name; 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_free_draw_ctx(TermWin *);
static void wintw_set_cursor_pos(TermWin *, int x, int y); 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(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_set_scrollbar(TermWin *, int total, int start, int page);
static void wintw_bell(TermWin *, int mode); static void wintw_bell(TermWin *, int mode);
static void wintw_clip_write( static void wintw_clip_write(
@ -252,6 +255,7 @@ static const TermWinVtable windows_termwin_vt = {
.free_draw_ctx = wintw_free_draw_ctx, .free_draw_ctx = wintw_free_draw_ctx,
.set_cursor_pos = wintw_set_cursor_pos, .set_cursor_pos = wintw_set_cursor_pos,
.set_raw_mouse_mode = wintw_set_raw_mouse_mode, .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, .set_scrollbar = wintw_set_scrollbar,
.bell = wintw_bell, .bell = wintw_bell,
.clip_write = wintw_clip_write, .clip_write = wintw_clip_write,
@ -1087,7 +1091,7 @@ static void update_mouse_pointer(void)
static bool forced_visible = false; static bool forced_visible = false;
switch (busy_status) { switch (busy_status) {
case BUSY_NOT: case BUSY_NOT:
if (send_raw_mouse) if (pointer_indicates_raw_mouse)
curstype = IDC_ARROW; curstype = IDC_ARROW;
else else
curstype = IDC_IBEAM; curstype = IDC_IBEAM;
@ -1124,12 +1128,14 @@ static void win_seat_set_busy_status(Seat *seat, BusyStatus status)
update_mouse_pointer(); update_mouse_pointer();
} }
/*
* set or clear the "raw mouse message" mode
*/
static void wintw_set_raw_mouse_mode(TermWin *tw, bool activate) static void wintw_set_raw_mouse_mode(TermWin *tw, bool activate)
{ {
send_raw_mouse = 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(); update_mouse_pointer();
} }