Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closing updated notifications is impossible or requires many clicks #99

Open
balsoft opened this issue Oct 26, 2020 · 5 comments
Open
Labels

Comments

@balsoft
Copy link
Contributor

balsoft commented Oct 26, 2020

First of all, this is a really cool project, thank you for developing and maintaining it!

Note: I'm using this on sway but with GDK_BACKEND=x11. All other features work (surprisingly) well, so I don't think this bug is Xwayland-related, but at the same time I don't have an X11 box to check that it's not.

Anyways, I have this project: https://github.com/balsoft/simple-osd-daemons/ which shows on-screen display for volume via pulseaudio and the currently playing song via mpris. To achieve this, it creates notifications when it first receives an event from pulseaudio or mpris, and then updates those notifications upon subsequent events. This works pretty well with mako, which I used previously, but for some reason with linux_notification_center I can't close those notifications by either clicking on them with mouse1 or dismissing them from the notification drawer. I can easily close most other notifications (from notify-send, firefox, etc), and I can also close notifications from simple-osd-daemons if they weren't updated (e.g. when I just change the volume once and then dismiss the notification) so I assume this is either a problem with my project somehow not following the spec or with linux_notification_center. Help would be appreciated either way.

@balsoft
Copy link
Contributor Author

balsoft commented Oct 26, 2020

Those notifications also seem to crash the notification center sometimes, but it's pretty random so I don't have a way to reproduce it yet. Error message is:

deadd-notification-center: src/NotificationCenter/Notifications/NotificationPopup.hs:(138,5)-(156,18): Non-exhaustive guards in multi-way if

Also sometimes those notifications forcefully close the drawer or prevent it from being opened, don't know how to reliably reproduce this either.

EDIT: opened #101 for this specifically

@Mesabloo
Copy link

Mesabloo commented Oct 31, 2020

Inspecting the source code at the given position (in the error):

onWidgetButtonPressEvent mainWindow $ \eventButton -> do
mouseButton <- (\n -> "mouse" ++ n) . show <$> getEventButtonButton eventButton
let validMouseButtons = ["mouse1", "mouse2", "mouse3", "mouse4", "mouse5"]
validInput = mouseButton `elem` validMouseButtons
validDismiss = configPopupDismissButton config `elem` validMouseButtons
validDefaultAction = configPopupDefaultActionButton config `elem` validMouseButtons
valid = validInput && validDismiss && validDefaultAction
dismiss = configPopupDismissButton config == mouseButton
defaultAction = configPopupDefaultActionButton config == mouseButton
if | valid && dismiss -> do
notiOnClosed noti $ User
onClose
| valid && defaultAction -> do
notiOnAction noti "default"
notiOnClosed noti $ User
onClose
| not validDismiss -> do
putStrLn $ "Warning: Unknown mouse button '" ++ (show $ configPopupDismissButton config) ++ "'."
notiOnClosed noti $ User
onClose
| not validDefaultAction -> do
putStrLn $ "Warning: Unknown mouse button '" ++ (show $ configPopupDefaultActionButton config) ++ "'."
notiOnClosed noti $ User
onClose
| not validInput -> do
putStrLn $ "Warning: Popup received unknown mouse input '" ++ (show mouseButton) ++ "'."
notiOnClosed noti $ User
onClose
return False
widgetShowAll mainWindow

You can see that there is an edge-case (I think) where valid is True (so the mouse button pressed is in the list, the dismiss button also is, and the default action also is), but where you did not press any of the dismiss button or the default action, which according to
, configPopupDismissButton = r' "mouse1" p nPopup "dismissButton"
, configPopupDefaultActionButton = r' "mouse3" p nPopup "defaultActionButton"
is either mouse1 (left click I believe) or mouse3 (right click) or some custom value in your configuration. Because you did not share any of your configuration, I'm assuming you have the default one from now on.

There should be a case where valid is True, but you pressed none of the configured buttons, to prevent this crash (I believe). I'll leave this to confirm to people who actually contributed and know the codebase way better than me.
Something like adding this case

      | valid -> do
          putStrLn $ "Mouse button " <> mouseButton <> " has been recognized as a valid input but is not configured"
          notiOnClosed noti $ User
          onClose
          -- or do a better action there, up to you

should fix it.

I do believe this helped isolating this issue, if really it was it. Can you confirm that pressing a non-configured button happens to crash the notification center?

@balsoft
Copy link
Contributor Author

balsoft commented Oct 31, 2020

Yes, the issue with notification center crashing was indeed because I made a middle mouse button click on one of the notifications. This is probably separate from my main issue, so I'll report a new one.

@phuhl
Copy link
Owner

phuhl commented Oct 31, 2020

Thanks for reporting :)

The fix proposed by @Mesabloo should work (to fix #101). If you want, open a working PR and I'll merge it. Otherwise, I will do it, but don't know when, yet

I, too, had the issue with not being able to close notifications but I couldn't produce a fix for it, yet. If it helps, for the time being, you can open and close the notification center to make notifications disappear, or you can bind notify-send.py a --hint boolean:deadd-notification-center:true string:type:clearPopups to a key to clear the notification-popups.

@balsoft
Copy link
Contributor Author

balsoft commented Oct 31, 2020

@phuhl fix for #101 is in #102 (although a bit of a different solution).

Thanks for the tips on working around the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants