]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_mouse.c
ncurses 6.0 - patch 20151219
[ncurses.git] / ncurses / base / lib_mouse.c
index cd46d0c9e21250db77404b061c7f9b2812341ee3..b6c888c1708ac0ae49fea3d73a1369863cef18d5 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2014,2015 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            *
@@ -84,7 +84,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_mouse.c,v 1.162 2014/10/12 00:03:37 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.168 2015/10/31 20:47:41 tom Exp $")
 
 #include <tic.h>
 
@@ -432,7 +432,7 @@ enable_xterm_mouse(SCREEN *sp, int enable)
 
 #if USE_GPM_SUPPORT
 static bool
-allow_gpm_mouse(SCREEN *sp)
+allow_gpm_mouse(SCREEN *sp GCC_UNUSED)
 {
     bool result = FALSE;
 
@@ -446,8 +446,8 @@ allow_gpm_mouse(SCREEN *sp)
 #endif
        /* GPM does printf's without checking if stdout is a terminal */
     if (NC_ISATTY(fileno(stdout))) {
-       char *list = getenv("NCURSES_GPM_TERMS");
-       char *env = getenv("TERM");
+       const char *list = getenv("NCURSES_GPM_TERMS");
+       const char *env = getenv("TERM");
        if (list != 0) {
            if (env != 0) {
                result = _nc_name_match(list, env, "|:");
@@ -608,7 +608,7 @@ initialize_mousetype(SCREEN *sp)
            int rc;
 
            if (!sp->_emxmouse_buttons[0]) {
-               char *s = getenv("MOUSE_BUTTONS_123");
+               const char *s = getenv("MOUSE_BUTTONS_123");
 
                sp->_emxmouse_buttons[0] = 1;
                if (s && strlen(s) >= 3) {
@@ -641,13 +641,14 @@ initialize_mousetype(SCREEN *sp)
 
 #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);
 
@@ -888,7 +889,7 @@ _nc_mouse_event(SCREEN *sp)
     do { \
            eventp->bstate = MASK_PRESS(n); \
            sp->_mouse_bstate |= MASK_PRESS(n); \
-           if (kbuf[0] & 0x40) { \
+           if (button & 0x40) { \
                    eventp->bstate = MASK_RELEASE(n); \
                    sp->_mouse_bstate &= ~MASK_PRESS(n); \
            } \
@@ -1097,7 +1098,7 @@ decode_xterm_1005(SCREEN *sp, MEVENT * eventp)
                            kbuf + grabbed, 1);
        if (res == -1)
            break;
-       grabbed += res;
+       grabbed += (size_t) res;
        if (grabbed > 1) {
            size_t check = 1;
            int n;
@@ -1105,10 +1106,11 @@ decode_xterm_1005(SCREEN *sp, MEVENT * eventp)
            for (n = 0; n < 2; ++n) {
                if (check >= grabbed)
                    break;
-               rc = _nc_conv_to_utf32(&coords[n], kbuf + check, grabbed - check);
+               rc = _nc_conv_to_utf32(&coords[n], kbuf + check, (unsigned)
+                                      (grabbed - check));
                if (!rc)
                    break;
-               check += rc;
+               check += (size_t) rc;
            }
            if (n >= 2)
                break;
@@ -1127,8 +1129,8 @@ decode_xterm_1005(SCREEN *sp, MEVENT * eventp)
 
     result = decode_X10_bstate(sp, eventp, UChar(kbuf[0]));
 
-    eventp->x = (coords[0] - ' ') - 1;
-    eventp->y = (coords[1] - ' ') - 1;
+    eventp->x = (int) (coords[0] - ' ') - 1;
+    eventp->y = (int) (coords[1] - ' ') - 1;
 
     return result;
 }
@@ -1247,7 +1249,6 @@ decode_xterm_SGR1006(SCREEN *sp, MEVENT * eventp)
        int b = data.params[0];
        int b3 = 1 + (b & 3);
 
-       result = TRUE;
        eventp->id = NORMAL_EVENT;
        if (data.final == 'M') {
            (void) handle_wheel(sp, eventp, b, (b & 64) == 64);