aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen_play.c
diff options
context:
space:
mode:
authorKalle Wallin <kaw@linux.se>2004-07-02 21:11:56 +0000
committerKalle Wallin <kaw@linux.se>2004-07-02 21:11:56 +0000
commitb268b9992faa303d6283c5a88ba460b5fd73cef6 (patch)
tree9fb9980bc7b231796b79d5abf0de6153ea8228fe /src/screen_play.c
parent8a22ebb6b68d5696ef853f07de96553e4ae506c4 (diff)
downloadmpd-b268b9992faa303d6283c5a88ba460b5fd73cef6.tar.gz
mpd-b268b9992faa303d6283c5a88ba460b5fd73cef6.tar.xz
mpd-b268b9992faa303d6283c5a88ba460b5fd73cef6.zip
Added basic ncurses mouse support
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1770 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/screen_play.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/screen_play.c b/src/screen_play.c
index 20fbe8fe1..e9cb465e2 100644
--- a/src/screen_play.c
+++ b/src/screen_play.c
@@ -367,6 +367,47 @@ play_update(screen_t *screen, mpdclient_t *c)
}
}
+#ifdef HAVE_GETMOUSE
+static int
+handle_mouse_event(screen_t *screen, mpdclient_t *c)
+{
+ int row;
+ int selected;
+ unsigned long bstate;
+
+ if( screen_get_mouse_event(c, lw, c->playlist.length, &bstate, &row) )
+ return 1;
+
+ if( bstate & BUTTON1_DOUBLE_CLICKED )
+ {
+ /* stop */
+ screen_cmd(c, CMD_STOP);
+ return 1;
+ }
+
+ selected = lw->start+row;
+
+ if( bstate & BUTTON1_CLICKED )
+ {
+ /* play */
+ if( lw->start+row < c->playlist.length )
+ mpdclient_cmd_play(c, lw->start+row);
+ }
+ else if( bstate & BUTTON3_CLICKED )
+ {
+ /* delete */
+ if( selected == lw->selected )
+ mpdclient_cmd_delete(c, lw->selected);
+ }
+ lw->selected = selected;
+ list_window_check_selected(lw, c->playlist.length);
+
+ return 1;
+}
+#else
+#define handle_mouse_event(s,c) (0)
+#endif
+
static int
play_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
{
@@ -403,6 +444,8 @@ play_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
return screen_find(screen, c,
lw, c->playlist.length,
cmd, list_callback);
+ case CMD_MOUSE_EVENT:
+ return handle_mouse_event(screen,c);
default:
break;
}