/****************************************************************************
- * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2015,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_mouse.c,v 1.167 2015/10/17 22:08:05 KO.Myung-Hun Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.170 2016/09/10 18:36:08 tom Exp $")
#include <tic.h>
char buf[6];
unsigned long ignore;
- strcpy(buf, "\033[M"); /* should be the same as key_mouse */
+ _nc_STRCPY(buf, "\033[M", sizeof(buf)); /* should be the same as key_mouse */
buf[3] = ' ' + (button - 1) + (down ? 0 : 0x40);
buf[4] = ' ' + x - LEFT_COL + 1;
buf[5] = ' ' + y - TOP_ROW + 1;
#if USE_SYSMOUSE
{
+ static char dev_tty[] = "/dev/tty";
struct mouse_info the_mouse;
char *the_device = 0;
if (NC_ISATTY(sp->_ifd))
the_device = ttyname(sp->_ifd);
if (the_device == 0)
- the_device = "/dev/tty";
+ the_device = dev_tty;
sp->_mouse_fd = open(the_device, O_RDWR);
/* initialize the mouse */
{
bool result = FALSE;
- int i;
if (sp != 0) {
if (!sp->_mouse_initialized) {
+ int i;
+
sp->_mouse_initialized = TRUE;
TR(MY_TRACE, ("_nc_mouse_init() called"));
#else
#define PRESS_POSITION(n) \
do { \
- eventp->bstate = (mmask_t) (sp->_mouse_bstate & MASK_PRESS(n) \
+ eventp->bstate = (mmask_t) ((sp->_mouse_bstate & MASK_PRESS(n)) \
? REPORT_MOUSE_POSITION \
: MASK_PRESS(n)); \
sp->_mouse_bstate |= MASK_PRESS(n); \
decode_X10_bstate(SCREEN *sp, MEVENT * eventp, unsigned intro)
{
bool result;
- int b;
eventp->bstate = 0;
if (!handle_wheel(sp, eventp, (int) intro, (intro & 96) == 96)) {
+
/*
* Release events aren't reported for individual buttons, just for
* the button set as a whole. However, because there are normally
* the previous event.
*/
if (sp->_mouse_bstate & BUTTON_PRESSED) {
+ int b;
+
eventp->bstate = BUTTON_RELEASED;
for (b = 1; b <= MAX_BUTTONS; ++b) {
if (!(sp->_mouse_bstate & MASK_PRESS(b)))
size_t grabbed;
size_t limit = (sizeof(kbuf) - 1);
unsigned coords[2];
- int res;
bool result;
coords[0] = 0;
_nc_globals.read_thread = pthread_self();
# endif
for (grabbed = 0; grabbed < limit;) {
+ int res;
res = (int) read(
#if USE_EMX_MOUSE
if (grabbed > 1) {
size_t check = 1;
int n;
- int rc;
+
for (n = 0; n < 2; ++n) {
+ int rc;
+
if (check >= grabbed)
break;
rc = _nc_conv_to_utf32(&coords[n], kbuf + check, (unsigned)
{
char kbuf[80]; /* bigger than any possible mouse response */
int grabbed = 0;
- int res;
int ch = 0;
int now = -1;
int marker = 1;
# endif
_nc_globals.read_thread = pthread_self();
# endif
+
do {
+ int res;
+
res = (int) read(
#if USE_EMX_MOUSE
(M_FD(sp) >= 0) ? M_FD(sp) : sp->_ifd,
/* set the mouse event mask */
{
mmask_t result = 0;
- int b;
T((T_CALLED("mousemask(%p,%#lx,%p)"),
(void *) SP_PARM,
if (newmask || SP_PARM->_mouse_initialized) {
_nc_mouse_init(SP_PARM);
+
if (SP_PARM->_mouse_type != M_NONE) {
+ int b;
+
result = newmask &
(REPORT_MOUSE_POSITION
| BUTTON_ALT