aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen.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.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 'src/screen.c')
-rw-r--r--src/screen.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/screen.c b/src/screen.c
index ba155a4cf..7b29f1f1e 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -474,7 +474,10 @@ screen_init(mpdclient_t *c)
keypad(stdscr, TRUE);
/* return from getch() without blocking */
timeout(SCREEN_TIMEOUT);
-
+ /* initialize mouse support */
+#ifdef HAVE_GETMOUSE
+ mousemask(ALL_MOUSE_EVENTS, NULL);
+#endif
if( COLS<SCREEN_MIN_COLS || LINES<SCREEN_MIN_ROWS )
{
@@ -704,6 +707,49 @@ screen_idle(mpdclient_t *c)
seek_id = -1;
}
+#ifdef HAVE_GETMOUSE
+int
+screen_get_mouse_event(mpdclient_t *c,
+ list_window_t *lw, int lw_length,
+ unsigned long *bstate, int *row)
+{
+ MEVENT event;
+
+ /* retreive the mouse event from ncurses */
+ getmouse(&event);
+ D("mouse: id=%d y=%d,x=%d,z=%d\n",event.id,event.y,event.x,event.z);
+ /* calculate the selected row in the list window */
+ *row = event.y - screen->top_window.rows;
+ /* copy button state bits */
+ *bstate = event.bstate;
+ /* if button 2 was pressed switch screen */
+ if( event.bstate & BUTTON2_CLICKED )
+ {
+ screen_cmd(c, CMD_SCREEN_NEXT);
+ return 1;
+ }
+ /* if the even occured above the list window move up */
+ if( *row<0 && lw )
+ {
+ if( event.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( *row>=lw->rows && lw )
+ {
+ if( event.bstate & BUTTON3_CLICKED )
+ list_window_last(lw, lw_length);
+ else
+ list_window_next_page(lw, lw_length);
+ return 1;
+ }
+ return 0;
+}
+#endif
+
void
screen_cmd(mpdclient_t *c, command_t cmd)
{