From e172b4a4ba3a3dc3fbd3afdc9d64b56c7911be6a Mon Sep 17 00:00:00 2001 From: ANSI TV Admin Date: Wed, 11 Nov 2026 12:04:09 -0800 Subject: [PATCH 10/24] SyncTERM: right-click pastes while the host tracks the mouse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Applies after `list-click.patch`. Stock SyncTERM hands every button to the host once it turns on mouse reporting, so a board that tracks the mouse for its menus takes right-click and OS paste is gone. Now right-click (release) pastes in the tracking and X10 modes too, unless the host has hidden the pointer with `CSI = 30 h` (a game with its own pointer, which keeps the button). Also: after Ctrl+Alt in exclusive mode only a LEFT click is spent on recapturing, so a right-click recaptures and pastes. Verified under Xvfb with a shell echoing its input: pastes with no reporting, pastes with `?1003h ?1006h`, sends `ESC[<2;…M/m` to the host after `=30h`, pastes after Ctrl+Alt in exclusive mode. --- src/conio/sdl_con.c | 7 +++++-- src/syncterm/term.c | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c index 87930461..8b67d1d4 100644 --- a/src/conio/sdl_con.c +++ b/src/conio/sdl_con.c @@ -1420,8 +1420,11 @@ void sdl_video_event_thread(void *data) ((km & KMOD_ALT) ? CIOLIB_KMOD_ALT : 0); pthread_once(&ciolib_mouse_initialized, init_mouse); if (sdl_mouse_exclusive_want && !sdl_mouse_exclusive) { - /* Released with Ctrl+Alt: this click takes it back. */ - if (sdl_mouse_grab(1)) { + /* Released with Ctrl+Alt: any click takes it back. + * Only a left click is spent doing so -- a right + * click still pastes. */ + if (sdl_mouse_grab(1) + && ev.button.button == SDL_BUTTON_LEFT) { sdl_swallow_buttons |= 1 << (ev.button.button & 31); break; } diff --git a/src/syncterm/term.c b/src/syncterm/term.c index e22f565e..e17b3070 100644 --- a/src/syncterm/term.c +++ b/src/syncterm/term.c @@ -4775,6 +4775,25 @@ handle_mouse_event(struct mouse_state *ms) getmouse(&mevent); if (wren_host_dispatch_mouse(&mevent)) return; + /* Right-click pastes from the OS clipboard even while the host has + * mouse reporting on -- a board that tracks the mouse for its menus + * would otherwise take the right button and paste would be gone. + * The exception is a host that has hidden our pointer (CSI = 30 h): + * that is a game drawing its own, and it keeps the right button. */ + if ((ms->mode == MM_NORMAL_TRACKING + || ms->mode == MM_BUTTON_EVENT_TRACKING + || ms->mode == MM_ANY_EVENT_TRACKING + || ms->mode == MM_X10) + && !(cterm != NULL && cterm->pointer_hidden)) { + switch (mevent.event) { + case CIOLIB_BUTTON_3_PRESS: + return; + case CIOLIB_BUTTON_3_RELEASE: + case CIOLIB_BUTTON_3_CLICK: + do_paste(); + return; + } + } switch (mevent.event) { case CIOLIB_BUTTON_1_PRESS: if ((mevent.kbmodifiers & CIOLIB_KMOD_CTRL) -- 2.47.3