From 9ee9a6f465507760da4435b45b63221d7c7b64fb Mon Sep 17 00:00:00 2001 From: Stian Onarheim <43683888+Feqzz@users.noreply.github.com> Date: Fri, 3 May 2024 21:26:37 +0200 Subject: [PATCH] Close notification with middle mouse button (#413) * Close notification with middle mouse button Signed-off-by: Stian Onarheim * Fix linting issue --------- Signed-off-by: Stian Onarheim Co-authored-by: Erik Reider <35975961+ErikReider@users.noreply.github.com> --- README.md | 2 +- man/swaync.1.scd | 2 +- src/notification/notification.vala | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0b32e502..6bd307c8 100644 --- a/README.md +++ b/README.md @@ -249,7 +249,7 @@ To reload css after changes - Shift+D: Toggle Do Not Disturb - Buttons 1-9: Execute alternative actions - Left click button / actions: Activate notification action -- Right click notification: Close notification +- Middle/Right click notification: Close notification ## Configuring diff --git a/man/swaync.1.scd b/man/swaync.1.scd index a5140de1..2d32832a 100644 --- a/man/swaync.1.scd +++ b/man/swaync.1.scd @@ -44,7 +44,7 @@ swaync - A simple notification daemon with a GTK gui for notifications and the c *Left click button / actions*: Activate notification action -*Right click notification*: Close notification +*Middle/Right click notification*: Close notification # CONFIGURATION diff --git a/src/notification/notification.vala b/src/notification/notification.vala index cc23180f..528737db 100644 --- a/src/notification/notification.vala +++ b/src/notification/notification.vala @@ -204,10 +204,15 @@ namespace SwayNotificationCenter { /// this.button_press_event.connect ((event) => { - if (event.button != Gdk.BUTTON_SECONDARY) return false; - // Right click - this.close_notification (); - return true; + // Close notification on middle and right button click + switch (event.button) { + case Gdk.BUTTON_MIDDLE: + case Gdk.BUTTON_SECONDARY: + this.close_notification (); + return true; + default: + return false; + } }); // Adds CSS :hover selector to EventBox