From 58eb7edfd586f397024561fbf7acf6140d9e01e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Sun, 23 Jul 2023 15:51:22 +0200 Subject: Make the scroll wheel act on the gauge and volume --- nncmpp.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/nncmpp.c b/nncmpp.c index 8784b88..97a0031 100644 --- a/nncmpp.c +++ b/nncmpp.c @@ -1148,8 +1148,8 @@ pulse_volume_status (struct pulse *self, struct str *s) // Widget identification, mostly for mouse events. enum { - WIDGET_NONE = 0, WIDGET_BUTTON, WIDGET_GAUGE, WIDGET_TAB, WIDGET_SPECTRUM, - WIDGET_LIST, WIDGET_SCROLLBAR, WIDGET_MESSAGE, + WIDGET_NONE = 0, WIDGET_BUTTON, WIDGET_GAUGE, WIDGET_VOLUME, + WIDGET_TAB, WIDGET_SPECTRUM, WIDGET_LIST, WIDGET_SCROLLBAR, WIDGET_MESSAGE, }; struct layout @@ -1866,7 +1866,8 @@ app_layout_status (struct layout *out) if (volume.len) { app_push (&l, g.ui->padding (attrs[0], 1, 1)); - app_push (&l, g.ui->label (attrs[0], volume.str)); + app_push (&l, g.ui->label (attrs[0], volume.str)) + ->id = WIDGET_VOLUME; } str_free (&volume); @@ -2854,12 +2855,28 @@ app_process_mouse (termo_mouse_event_t type, int x, int y, int button, g.ui_dragging = target->id; return app_process_left_mouse_click (target, x, y, modifiers); case 4: - if (target->id == WIDGET_LIST) + switch (target->id) + { + case WIDGET_LIST: return app_process_action (ACTION_SCROLL_UP); + case WIDGET_VOLUME: + return app_process_action (g.pulse_control_requested + ? ACTION_PULSE_VOLUME_UP : ACTION_MPD_VOLUME_UP); + case WIDGET_GAUGE: + return app_process_action (ACTION_MPD_FORWARD); + } break; case 5: - if (target->id == WIDGET_LIST) + switch (target->id) + { + case WIDGET_LIST: return app_process_action (ACTION_SCROLL_DOWN); + case WIDGET_VOLUME: + return app_process_action (g.pulse_control_requested + ? ACTION_PULSE_VOLUME_DOWN : ACTION_MPD_VOLUME_DOWN); + case WIDGET_GAUGE: + return app_process_action (ACTION_MPD_BACKWARD); + } break; } return false; -- cgit v1.2.3