Code

screen_utils: move KEY_MOUSE check to ignore_key(), avoid recursion
[ncmpc.git] / src / screen_utils.c
index fee0e2a5c2d748380be37250b7d874371467cfad..8f69930d64126752b048164fcd1a8d7e9d0df379 100644 (file)
@@ -38,6 +38,17 @@ screen_bell(void)
                flash();
 }
 
+static bool
+ignore_key(int key)
+{
+       return
+#ifdef HAVE_GETMOUSE
+               /* ignore mouse events */
+               key == KEY_MOUSE ||
+#endif
+               key == ERR;
+}
+
 int
 screen_getch(const char *prompt)
 {
@@ -52,14 +63,7 @@ screen_getch(const char *prompt)
        curs_set(1);
 
        int key;
-       while ((key = wgetch(w)) == ERR)
-               ;
-
-#ifdef HAVE_GETMOUSE
-       /* ignore mouse events */
-       if (key == KEY_MOUSE)
-               return screen_getch(prompt);
-#endif
+       while (ignore_key(key = wgetch(w))) {}
 
        noecho();
        curs_set(0);
@@ -153,28 +157,5 @@ screen_display_completion_list(GList *list)
        }
 
        wrefresh(w);
-       doupdate();
        colors_use(w, COLOR_LIST);
 }
-
-#ifndef NCMPC_MINI
-void
-set_xterm_title(const char *format, ...)
-{
-       /* the current xterm title exists under the WM_NAME property */
-       /* and can be retrieved with xprop -id $WINDOWID */
-
-       if (options.enable_xterm_title) {
-               if (g_getenv("WINDOWID")) {
-                       va_list ap;
-                       va_start(ap,format);
-                       char *msg = g_strdup_vprintf(format,ap);
-                       va_end(ap);
-                       printf("\033]0;%s\033\\", msg);
-                       fflush(stdout);
-                       g_free(msg);
-               } else
-                       options.enable_xterm_title = FALSE;
-       }
-}
-#endif