From: Max Kellermann Date: Sat, 17 Oct 2009 22:55:26 +0000 (+0200) Subject: screen_queue: set cursor before button handlers X-Git-Tag: release-0.16~92 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3b7971341651ff01d52f1529ba4315b38549a0b3;p=ncmpc.git screen_queue: set cursor before button handlers This allows us to use screen_queue_selected_song(). --- diff --git a/src/screen_queue.c b/src/screen_queue.c index 898011d..491d332 100644 --- a/src/screen_queue.c +++ b/src/screen_queue.c @@ -596,8 +596,8 @@ static bool handle_mouse_event(struct mpdclient *c) { int row; - unsigned selected; unsigned long bstate; + unsigned old_selected; if (screen_get_mouse_event(c, &bstate, &row) || list_window_mouse(lw, bstate, row)) { @@ -611,21 +611,21 @@ handle_mouse_event(struct mpdclient *c) return true; } - selected = lw->start + row; + old_selected = lw->selected; + list_window_set_cursor(lw, lw->start + row); if (bstate & BUTTON1_CLICKED) { /* play */ - if (lw->start + row < playlist_length(playlist)) + if (lw->selected < playlist_length(playlist)) mpdclient_cmd_play(c, lw->start + row); } else if (bstate & BUTTON3_CLICKED) { /* delete */ - if (selected == lw->selected) + if (lw->selected == old_selected) mpdclient_cmd_delete(c, lw->selected); list_window_set_length(lw, playlist_length(playlist)); } - list_window_set_cursor(lw, selected); screen_queue_save_selection(); screen_queue_repaint();