From: Tammo Block <tammo.block@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>
Subject: [PATCH v0 4/5] Add support for SRG report output format
Date: Fri, 26 Jun 2020 09:23:03 +0200 [thread overview]
Message-ID: <f703a17a02475251e50071354977dca8544f969a.1593155911.git.tammo.block@gmail.com> (raw)
In-Reply-To: <cover.1593155911.git.tammo.block@gmail.com>
Add SRG ("1005") style mouse reports. Always use them to create a report to
userspace if they are available because they may contain more information
(e.g. scroll wheel events).
Do not send reports at all if report information is not sufficient.
Signed-off-by: Tammo Block <tammo.block@gmail.com>
---
drivers/tty/vt/vt.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 5c9c449dc150..af0c58a9b108 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1835,10 +1835,30 @@ static inline void respond_ID(struct tty_struct *tty)
void mouse_report(struct tty_struct *tty, int butt, int mrx, int mry)
{
- char buf[8];
+ char buf[20];
+ char rel;
- sprintf(buf, "\033[M%c%c%c", (char)(' ' + (butt & TIOCL_SELBUTTONMASK)),
- (char)('!' + mrx), (char)('!' + mry));
+ if (butt & TIOCL_SELSRGREPORT) {
+ rel = (butt & TIOCL_SELSRGRELEASE) ? 1 : 0;
+ butt = butt >> 8;
+
+ if (vc_cons[fg_console].d->vc_proto_mouse) {
+ sprintf(buf, "\033[<%d;%d;%d%c", butt, mrx + 1, mry + 1, rel ? 'm' : 'M');
+ } else {
+ if (rel)
+ butt = (3 | butt);
+ sprintf(buf, "\033[M%c%c%c", (char)(' ' + butt),
+ (char)('!' + mrx), (char)('!' + mry));
+ }
+ } else {
+ /* Compatibility for older protocol */
+ if (vc_cons[fg_console].d->vc_proto_mouse)
+ return;
+ if (vc_cons[fg_console].d->vc_report_mouse > 2)
+ return;
+ sprintf(buf, "\033[M%c%c%c", (char)(' ' + (butt & TIOCL_SELBUTTONMASK)),
+ (char)('!' + mrx), (char)('!' + mry));
+ }
respond_string(buf, tty->port);
}
--
2.27.0
next prev parent reply other threads:[~2020-06-26 7:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-26 7:21 [PATCH v0 0/5] vt: Add SRG mouse reporting features Tammo Block
2020-06-26 7:22 ` [PATCH v0 1/5] Change/add data structures for SRG mouse reporting Tammo Block
2020-06-26 10:38 ` Jiri Slaby
2020-06-26 7:22 ` [PATCH v0 2/5] Make it possible to enable/disable " Tammo Block
2020-06-26 10:43 ` Jiri Slaby
2020-06-26 7:22 ` [PATCH v0 3/5] Check for SRG protocol and move bit masking Tammo Block
2020-06-26 7:23 ` Tammo Block [this message]
2020-06-26 10:52 ` [PATCH v0 4/5] Add support for SRG report output format Jiri Slaby
2020-06-26 7:23 ` [PATCH v0 5/5] Add Documentation for console mouse reporting Tammo Block
2020-06-26 11:00 ` Jiri Slaby
2020-06-26 17:55 ` Randy Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f703a17a02475251e50071354977dca8544f969a.1593155911.git.tammo.block@gmail.com \
--to=tammo.block@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).