Code

screen_utils: move KEY_MOUSE check to ignore_key(), avoid recursion
authorMax Kellermann <max.kellermann@gmail.com>
Mon, 20 Mar 2017 16:17:36 +0000 (17:17 +0100)
committerMax Kellermann <max.kellermann@gmail.com>
Mon, 20 Mar 2017 16:17:48 +0000 (17:17 +0100)
src/screen_utils.c

index 891b9b3cb61bac1f673d1d45908712839d84f09d..8f69930d64126752b048164fcd1a8d7e9d0df379 100644 (file)
@@ -41,7 +41,12 @@ screen_bell(void)
 static bool
 ignore_key(int key)
 {
 static bool
 ignore_key(int key)
 {
-       return key == ERR;
+       return
+#ifdef HAVE_GETMOUSE
+               /* ignore mouse events */
+               key == KEY_MOUSE ||
+#endif
+               key == ERR;
 }
 
 int
 }
 
 int
@@ -60,12 +65,6 @@ screen_getch(const char *prompt)
        int key;
        while (ignore_key(key = wgetch(w))) {}
 
        int key;
        while (ignore_key(key = wgetch(w))) {}
 
-#ifdef HAVE_GETMOUSE
-       /* ignore mouse events */
-       if (key == KEY_MOUSE)
-               return screen_getch(prompt);
-#endif
-
        noecho();
        curs_set(0);
 
        noecho();
        curs_set(0);