git: 751c323b829c - main - sc: Use current console rather than first console for mouse input

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sun, 14 Jan 2024 16:32:40 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=751c323b829c36ca63a123a02a51f971ca3bd409

commit 751c323b829c36ca63a123a02a51f971ca3bd409
Author:     Vadim Ushakov <igeekless@gmail.com>
AuthorDate: 2024-01-14 16:22:17 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-01-14 16:24:41 +0000

    sc: Use current console rather than first console for mouse input
    
    When mouse reporting feature is turned on (control sequence ^[[?1000h),
    syscons sends valid mouse coordinates only for ttyv0. Applications
    running on other ttys always (erroneously) get mouse coordinates from
    the first tty, not from tty they actually run.
    
    Steps to reproduce:
    1. On ttyv0, run any application that uses mouse reporting feature. Make
       some clicks. The feature works properly.
    2. Switch to another ttyv, run the application. The application receives
       mouse click events, but mouse position reported by syscons to the
       application does not match with the actual mouse position on the screen.
    
    Expected result:
    Reported mouse position should match with visible mouse position.
    
    PR: 193339
    Reviewed by: imp
---
 sys/dev/syscons/scmouse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/syscons/scmouse.c b/sys/dev/syscons/scmouse.c
index f23f412cc00d..b0c7fcc9d147 100644
--- a/sys/dev/syscons/scmouse.c
+++ b/sys/dev/syscons/scmouse.c
@@ -798,7 +798,7 @@ sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
 	    cur_scp->status &= ~MOUSE_HIDDEN;
 
 	    if (cur_scp->mouse_level > 0) {
-	    	sc_mouse_input(scp, mouse);
+		sc_mouse_input(cur_scp, mouse);
 		break;
 	    }
 
@@ -859,7 +859,7 @@ sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
 	    cur_scp->status &= ~MOUSE_HIDDEN;
 
 	    if (cur_scp->mouse_level > 0) {
-	    	sc_mouse_input(scp, mouse);
+		sc_mouse_input(cur_scp, mouse);
 		break;
 	    }