From 6ed073347e610bcc4fe1857f1de6864aa47627e1 Mon Sep 17 00:00:00 2001 From: depsterr Date: Thu, 4 Feb 2021 21:14:22 +0100 Subject: [PATCH] added ability to close window by right clicking --- README.md | 2 +- mpdart.c | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 8eef726..76bebbe 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ These options can also be configured in the enviorment variables `MPDART_DIR`, ` To make these changes persistent, export them in your `~/.profile`. -Once mpdart is running you can press the window to toggle mpd's pause/play. +Once mpdart is running you can left click the window to toggle mpd's pause/play or right click it to close it. Contributing ------------ diff --git a/mpdart.c b/mpdart.c index 8b119d3..3a8377f 100644 --- a/mpdart.c +++ b/mpdart.c @@ -450,19 +450,24 @@ int main(int argc, char** argv) { /* toggle pause on press */ case ButtonPress: - if (ev.xbutton.button == Button1) { + switch (ev.xbutton.button) { + case Button1: + DEBUG("Toggling pause\n"); - DEBUG("Toggling pause\n"); + mpd_run_noidle(connection); + mpd_check_error(); - mpd_run_noidle(connection); - mpd_check_error(); + /* deprecated but they provide nothing better so fuck them */ + mpd_run_toggle_pause(connection); + mpd_check_error(); - /* deprecated but they provide nothing better so fuck them */ - mpd_run_toggle_pause(connection); - mpd_check_error(); - - mpd_send_idle_mask(connection, MPD_IDLE_PLAYER); - mpd_check_error(); + mpd_send_idle_mask(connection, MPD_IDLE_PLAYER); + mpd_check_error(); + break; + case Button3: + DEBUG("Exiting due to MB2 pree"); + exit(0); + break; } break;