From 3b7971341651ff01d52f1529ba4315b38549a0b3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 18 Oct 2009 00:55:26 +0200 Subject: [PATCH] screen_queue: set cursor before button handlers This allows us to use screen_queue_selected_song(). --- src/screen_queue.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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(); -- 2.30.2