[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#954730: marked as done (xterm: two press events sent for single press/release of mouse buttons 6 and 7)



Your message dated Wed, 29 Apr 2020 16:33:59 +0000
with message-id <E1jTpep-000D3x-Oa@fasolo.debian.org>
and subject line Bug#954730: fixed in xterm 354-1
has caused the Debian Bug report #954730,
regarding xterm: two press events sent for single press/release of mouse buttons 6 and 7
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
954730: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=954730
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: xterm
Version: 353-1
Severity: normal

Dear Maintainer,

While developing a console based application using ncurses running under
an exterm, I noticed I was getting double events for the side-scrolling
buttons on my mouse (Elecom Huge: 12 buttons (including side-scrolling
on the wheel)). Upon investigation, I found that while X itself is
sending a press event followed immediately by a release event for
buttons 6 and 7, I found that my program was recieving two press events
for each press of either button 6 or 7
\x27[<0;14;24M      <- button 1 pressed
\x27[<0;14;24m      <- button 1 preleased
\x27[<66;14;24M     <- button 6 presssed ONCE
\x27[<66;14;24M
\x27[<67;14;24M     <- button 7 presssed ONCE
\x27[<67;14;24M
\x27[<65;14;24M     <- one click turning scroll one way
\x27[<64;14;24M     <- one click turning scroll the other way way

It does not matter if 1000 or 1003 mode is used, or if 1006 is on or off
(the above is 1003 + 1006).

I expect either a press followed by a release (M then m in sgr (1006)
mode, or just a single press as for buttons 4 and 5 (though I think I
would prefer press and release).

I have attached the test program used to produce the above.

-- System Information:
Debian Release: bullseye/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.4.0-4-amd64 (SMP w/8 CPU cores)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.utf8), LANGUAGE=en_AU:en (charmap=UTF-8) (ignored: LC_ALL set to en_US.utf8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages xterm depends on:
ii  libc6           2.29-10
ii  libfontconfig1  2.13.1-2+b1
ii  libfreetype6    2.10.1-2
ii  libice6         2:1.0.9-2
ii  libtinfo6       6.1+20191019-1
ii  libutempter0    1.1.6-4
ii  libx11-6        2:1.6.8-1
ii  libxaw7         2:1.0.13-1+b2
ii  libxext6        2:1.3.3-1+b2
ii  libxft2         2.3.2-2
ii  libxinerama1    2:1.1.4-2
ii  libxmu6         2:1.1.2-2+b3
ii  libxpm4         1:3.5.12-1
ii  libxt6          1:1.1.5-1+b3
ii  xbitmaps        1.1.1-2

Versions of packages xterm recommends:
ii  x11-utils  7.7+4

Versions of packages xterm suggests:
pn  xfonts-cyrillic  <none>

-- no debconf information
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

#define MOUSE_MOVES_ON "\033[?1003h"
#define MOUSE_MOVES_OFF "\033[?1003l"
#define SGR_ON "\033[?1006h"
#define SGR_OFF "\033[?1006l"
#define UTF8_ON "\033[?1005h"
#define UTF8_OFF "\033[?1005h"

struct termios save_termios;

void tty_raw(int fd)
{
	struct termios termios;

	tcgetattr (fd, &save_termios);

	termios = save_termios;
	termios.c_lflag &= ~(ECHO | ICANON | ISIG);
	termios.c_cc[VMIN] = 1;
	termios.c_cc[VTIME] = 0;
	tcsetattr (fd, TCSAFLUSH, &termios);
}

void tty_reset(int fd)
{
	tcsetattr (fd, TCSAFLUSH, &save_termios);
}

typedef enum {
	st_idle,
	st_escape,
	st_csi,
	st_mouse1,
	st_mouse2,
	st_mouse3,
} state_t;

state_t state;
unsigned char mouse_chars[3];
int mouse_buttons;

void parse_mouse (void)
{
	int         x = mouse_chars[1] - '!';	// want 0-based coords
	int         y = mouse_chars[2] - '!';	// want 0-based coords
	int         c = mouse_chars[0] - ' ';
	int         b = c & 3;
	int         m = c & 0x20;				// motion + lowest button
	int         e = c & 0xc0;				// extended buttons
	int         shift = (c >> 2) & 7;		// shift state

	if (m) {
		b = -1;
	} else {
		// xterm doesn't send release events for buttons 4-7
		mouse_buttons &= ~(0x7c);
		if (!e && b == 3) {
			mouse_buttons = 0;		// we don't know which one :P
			b = -1;
		} else {
			if (e) {
				b += 4 * (e >> 6) - 1;
			}
			mouse_buttons |= 1 << b;
		}
	}
	printf ("%3d %3d %02x %03x %02x %2d\r", x, y, c, mouse_buttons, e, b + 1);
	fflush (stdout);
}

void process_char (int ch)
{
	if (ch == 0x1b) {
		// always reset if escape is seen, may be a desync
		state = st_escape;
	} else {
		switch (state) {
			case st_idle:
				break;
			case st_escape:
				if (ch == '[') {
					state = st_csi;
				}
				break;
			case st_csi:
				if (ch == 'M') {
					state = st_mouse1;
					memset (mouse_chars, 0, sizeof (mouse_chars));
				}
				break;
			case st_mouse1:
				mouse_chars[0] = ch;
				state = st_mouse2;
				break;
			case st_mouse2:
				mouse_chars[1] = ch;
				state = st_mouse3;
				break;
			case st_mouse3:
				mouse_chars[2] = ch;
				parse_mouse();
				state = st_idle;
				break;
		}
		//printf("state %d\n", state);
	}
}

void
print_bytes (const char *str, int len)
{
	char        c;

	if (!str)
		return;
	while (len-- > 0 && (c = *str++)) {
		switch (c) {
			case '\a':
				fputs ("\\a", stdout);
				break;
			case '\b':
				fputs ("\\b", stdout);
				break;
			case '\f':
				fputs ("\\f", stdout);
				break;
			case '\n':
				fputs ("\\n", stdout);
				break;
			case '\r':
				fputs ("\\r", stdout);
				break;
			case '\t':
				fputs ("\\t", stdout);
				break;
			case '\\':
				fputs ("\\\\", stdout);
				break;
			case '\'':
				fputs ("\\'", stdout);
				break;
			case '\"':
				fputs ("\\\"", stdout);
				break;
			default:
				if (c >= 127 || c < 32)
					printf ("\\x%02d", (unsigned char) c);
				else
					putc (c, stdout);
				break;
		}
	}
	puts("");
	fflush (stdout);
}

int main (void)
{
	char        buf[256];
	int         len;

	tty_raw (0);
	write(1, MOUSE_MOVES_ON, sizeof (MOUSE_MOVES_ON) - 1);
	write(1, SGR_ON, sizeof (SGR_ON) - 1);
	while (1) {
		len = read(0, buf, sizeof (buf));
		//for (int i = 0; i < len; i++) {
		//	process_char (buf[i]);
		//}
		print_bytes (buf, len);
		if (buf[0] == 'x') {
			break;
		}
	}
	write(1, SGR_OFF, sizeof (SGR_OFF) - 1);
	write(1, MOUSE_MOVES_OFF, sizeof (MOUSE_MOVES_OFF) - 1);
	tty_reset (0);
}

--- End Message ---
--- Begin Message ---
Source: xterm
Source-Version: 354-1
Done: Sven Joachim <svenjoac@gmx.de>

We believe that the bug you reported is fixed in the latest version of
xterm, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 954730@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Sven Joachim <svenjoac@gmx.de> (supplier of updated xterm package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Wed, 29 Apr 2020 18:03:39 +0200
Source: xterm
Architecture: source
Version: 354-1
Distribution: unstable
Urgency: medium
Maintainer: Debian X Strike Force <debian-x@lists.debian.org>
Changed-By: Sven Joachim <svenjoac@gmx.de>
Closes: 820803 940626 954730 954845
Changes:
 xterm (354-1) unstable; urgency=medium
 .
   * New upstream release.
     - Work around performance problems of XDrawImageString and
       XDrawImageString16 functions (Closes: #954845).
     - Temporarily set numeric locale category to "C" when parsing
       resources, so that scaleHeight and faceSize settings do not
       depend on locale (Closes: #820803).
     - Two fixes for left/right wheel mouse event reporting
       (Closes: #954730).
       + Filter identical button-events.
       + Correct order of button-range versus protocol type
         (see xterm 345).
     - Modify uxterm to make it possible to select locale C.UTF-8,
       e.g, if the user's locale is set to "C" (Closes: #940626).
   * Cherry-pick a fix from upstream snapshot 354a: build-fix for "make
     check" when building out-of-tree.
   * Update copy of XTerm FAQ to revision 1.392 (dated 2020/03/21).
Checksums-Sha1:
 d9a6a355bb42269a6b5e169139193cafa58859aa 2402 xterm_354-1.dsc
 6bd3ec08cf09a3f8699d6fbfdb8280fed705da96 1414526 xterm_354.orig.tar.gz
 dfe6857c03a2510d91e83c08f6db1a52f60ae0c6 265 xterm_354.orig.tar.gz.asc
 a08989183c5dc80f317b461fa61c8844825c3705 111808 xterm_354-1.debian.tar.xz
 575cccf03b5c923219d8725bbfcf85f1320ccaf6 7379 xterm_354-1_source.buildinfo
Checksums-Sha256:
 58e0670290d01bc709320f542079ea79bc3d33f3ad1aaf65b6ea6ff2e5af45c5 2402 xterm_354-1.dsc
 06c4616031ef840aa376aff8242518742267d99a6603ca89ca4f27254b15804a 1414526 xterm_354.orig.tar.gz
 9eeea260db0cf79b82aea915bac63e1bc70590343970d8f4f21585e1b547a177 265 xterm_354.orig.tar.gz.asc
 43180a2a679580b33b8724265559dd5c978ea0367934b2f2be16dce579a17b8e 111808 xterm_354-1.debian.tar.xz
 469ca89d837b78ba870c8b49f4a16ed3319d00238b612cf4333ca27bfd65b0e2 7379 xterm_354-1_source.buildinfo
Files:
 e698d78e5088dea786a12485fbcbb9be 2402 x11 optional xterm_354-1.dsc
 e5d71c5aeccfb19ca23dff261e7c0a30 1414526 x11 optional xterm_354.orig.tar.gz
 6e7a9d7ff09110ec0be6a8e6efcb7d61 265 x11 optional xterm_354.orig.tar.gz.asc
 deb1f70ad294b2bce11905b7ab849d69 111808 x11 optional xterm_354-1.debian.tar.xz
 6893a872c7bac8ee06539b7991314448 7379 x11 optional xterm_354-1_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKF8heKgv5Jai5p4QOxBucY1rMawFAl6pp0wACgkQOxBucY1r
MayfwQ//QqSrOUeaotSlnxBmy0evkthGi//RhURpw2DLTgMPXV/PezkvnpndRy3Q
w36Q+FBreu6m2jk97Zd4TPZ8L6voOojCL5EWhAWx4gKnXVXYvbAr33oHmwip1mKD
sVrrsT4ba8mlP1ry4EP+frrQBD+OId1nn9g0v2tS/AI+chsUc0NkvJbeHiYPZ15N
NpublAmo3/7D6IaSdCC3YchHYoVN+5y/Way/WtHwSwlQl9G3v6POLGxXy11vJjqX
JRtLCRgDuoXuFtmnh95XwbGn4BomQBfYwvJRt6dLTUUriATouJ0Ovw55DyqhfFZc
IViuMfqBZNmphuuJmQ55GvINvLpr5ZRxEtdPXCabm1xqqoGQssuDy2u+oIkCwXN7
MqhVGHx/L6Xm+1WDMV5ydk+01z9bfpgHsFWhoKo6b29Oh7MykUrM+uJmg1Qj+Fz9
/Gktp7/24i/HlMS1c8DfgOMOsfGJzbyf1Ib4x/AOE2103Ihm7zm7y1yCTryYg0Cz
smyn+m4/cOEEl1heL8nrKuvkxP6V5o6rL3ICiDZZp+Yl9CkFqGR0BCthMLN5/WvI
62Yk2OVWhn76FBCtcCR69if6TXqhOwmn46DoD8hYWzqq+JCObUFRJcEbIK3GGGMA
F+WLUK3R40FL6bPGA72wE87uUw4jrWRktVR8dRd0wKglgvDXnEE=
=mjqD
-----END PGP SIGNATURE-----

--- End Message ---

Reply to: