aboutsummaryrefslogtreecommitdiffstats
path: root/src/list_window.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-22 10:04:46 +0200
committerMax Kellermann <max@duempel.org>2008-09-22 10:04:46 +0200
commite6d6231b4de336f60bc5b07331e2f1f01096c66c (patch)
treeca99bb77e967d794af8b88aebd3fdf9c50dc474b /src/list_window.c
parent07632841df4ff1d8fcfac33bd93e06ee43a4498e (diff)
downloadmpd-e6d6231b4de336f60bc5b07331e2f1f01096c66c.tar.gz
mpd-e6d6231b4de336f60bc5b07331e2f1f01096c66c.tar.xz
mpd-e6d6231b4de336f60bc5b07331e2f1f01096c66c.zip
screen: moved list_window mouse code to list_window.c
Move the portion of screen_get_mouse_event() which handles list_window clicks to list_window.c. The code contained a NULL pointer dereference, which is now fixed.
Diffstat (limited to 'src/list_window.c')
-rw-r--r--src/list_window.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/list_window.c b/src/list_window.c
index 5ab8f9c9c..215a531dd 100644
--- a/src/list_window.c
+++ b/src/list_window.c
@@ -25,6 +25,7 @@
#include "command.h"
#include "colors.h"
+#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
@@ -362,6 +363,35 @@ list_window_scroll_cmd(struct list_window *lw, unsigned rows, command_t cmd)
return 1;
}
+#ifdef HAVE_GETMOUSE
+int
+list_window_mouse(struct list_window *lw, unsigned rows,
+ unsigned long bstate, int y)
+{
+ assert(lw != NULL);
+
+ /* if the even occured above the list window move up */
+ if (y < 0) {
+ if (bstate & BUTTON3_CLICKED)
+ list_window_first(lw);
+ else
+ list_window_previous_page(lw);
+ return 1;
+ }
+
+ /* if the even occured below the list window move down */
+ if ((unsigned)y >= rows) {
+ if (bstate & BUTTON3_CLICKED)
+ list_window_last(lw, rows);
+ else
+ list_window_next_page(lw, rows);
+ return 1;
+ }
+
+ return 0;
+}
+#endif
+
list_window_state_t *
list_window_init_state(void)
{