/****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey *
+ * Copyright 2018-2021,2022 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_mouse.c,v 1.193 2021/03/20 12:56:32 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.197 2022/08/13 14:13:12 tom Exp $")
#include <tic.h>
PRESS_POSITION(3);
break;
default:
+ /*
+ * case 3 is sent when the mouse buttons are released.
+ *
+ * If the terminal uses xterm mode 1003, a continuous series of
+ * button-release events is sent as the mouse moves around the screen,
+ * or as the wheel mouse is rotated.
+ *
+ * Return false in this case, so that when running in X10 mode, we will
+ * recalculate bstate.
+ */
+ eventp->bstate = REPORT_MOUSE_POSITION;
result = FALSE;
break;
}
int res;
bool result;
-# if USE_PTHREADS_EINTR
-# if USE_WEAK_SYMBOLS
- if ((pthread_self) && (pthread_kill) && (pthread_equal))
-# endif
- _nc_globals.read_thread = pthread_self();
-# endif
+ _nc_set_read_thread(TRUE);
for (grabbed = 0; grabbed < MAX_KBUF; grabbed += (size_t) res) {
/* For VIO mouse we add extra bit 64 to disambiguate button-up. */
if (res == -1)
break;
}
-#if USE_PTHREADS_EINTR
- _nc_globals.read_thread = 0;
-#endif
+ _nc_set_read_thread(FALSE);
kbuf[MAX_KBUF] = '\0';
TR(TRACE_IEVENT,
coords[0] = 0;
coords[1] = 0;
-# if USE_PTHREADS_EINTR
-# if USE_WEAK_SYMBOLS
- if ((pthread_self) && (pthread_kill) && (pthread_equal))
-# endif
- _nc_globals.read_thread = pthread_self();
-# endif
+ _nc_set_read_thread(TRUE);
for (grabbed = 0; grabbed < limit;) {
int res;
break;
}
}
-#if USE_PTHREADS_EINTR
- _nc_globals.read_thread = 0;
-#endif
+ _nc_set_read_thread(FALSE);
TR(TRACE_IEVENT,
("_nc_mouse_inline sees the following xterm data: %s",
int marker = 1;
memset(result, 0, sizeof(*result));
-# if USE_PTHREADS_EINTR
-# if USE_WEAK_SYMBOLS
- if ((pthread_self) && (pthread_kill) && (pthread_equal))
-# endif
- _nc_globals.read_thread = pthread_self();
-# endif
+ _nc_set_read_thread(TRUE);
do {
int res;
}
++grabbed;
} while (!isFinal(ch));
-#if USE_PTHREADS_EINTR
- _nc_globals.read_thread = 0;
-#endif
+ _nc_set_read_thread(FALSE);
kbuf[++grabbed] = 0;
TR(TRACE_IEVENT,
if (changed) {
merge = FALSE;
for (b = 1; b <= MAX_BUTTONS; ++b) {
- if ((sp->_mouse_mask & MASK_CLICK(b))
+ if ((sp->_mouse_mask2 & MASK_CLICK(b))
&& (ep->bstate & MASK_PRESS(b))) {
next->bstate &= ~MASK_RELEASE(b);
next->bstate |= MASK_CLICK(b);
&& (next->bstate & BUTTON_CLICKED)) {
merge = FALSE;
for (b = 1; b <= MAX_BUTTONS; ++b) {
- if ((sp->_mouse_mask & MASK_DOUBLE_CLICK(b))
+ if ((sp->_mouse_mask2 & MASK_DOUBLE_CLICK(b))
&& (ep->bstate & MASK_CLICK(b))
&& (next->bstate & MASK_CLICK(b))) {
next->bstate &= ~MASK_CLICK(b);
&& (next->bstate & BUTTON_CLICKED)) {
merge = FALSE;
for (b = 1; b <= MAX_BUTTONS; ++b) {
- if ((sp->_mouse_mask & MASK_TRIPLE_CLICK(b))
+ if ((sp->_mouse_mask2 & MASK_TRIPLE_CLICK(b))
&& (ep->bstate & MASK_DOUBLE_CLICK(b))
&& (next->bstate & MASK_CLICK(b))) {
next->bstate &= ~MASK_CLICK(b);
#endif /* TRACE */
/* after all this, do we have a valid event? */
- return ValidEvent(PREV(first_invalid));
+ ep = PREV(first_invalid);
+ return ValidEvent(ep) && ((ep->bstate & sp->_mouse_mask) != 0);
}
static void