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

Linux: checkbox item Uncheck doesn't work in submenu #72

Open
nohajc opened this issue Dec 27, 2023 · 14 comments
Open

Linux: checkbox item Uncheck doesn't work in submenu #72

nohajc opened this issue Dec 27, 2023 · 14 comments

Comments

@nohajc
Copy link

nohajc commented Dec 27, 2023

When I try to programmatically deselect a checkbox menu item (call Uncheck), it doesn't work if the menu item is part of a submenu.

I wrote a minimal example reproducing the issue. Basically, I wanted to emulate radio button group behavior which means only one item can be selected at a time and I need to deselect the previous selection without any associated input event.

While it works correctly in the root menu, it breaks when I use the same logic for submenu items.
The clicked item gets selected but the state of the others in the group doesn't change.

Here's the demonstration (tested in KDE):
https://github.com/nohajc/systray-issue-minimal-example

Thanks for any help.

BTW, I also wanted to submit a PR adding support for actual radio buttons (which are part of the dbusmenu interface) but I got stuck because of this issue. D-Bus basically only lets you select the type of the "tick" icon. It doesn't enforce any particular behavior so multiselect is still possible unless you add your own logic. Now, I believe my logic is correct but I was very surprised to see it doesn't work consistently.

@andydotxyz
Copy link
Member

Are you testing only on Linux?

For radio vs checkbox we are restricted by the different OS implementations like macOS and Window as well.

@nohajc
Copy link
Author

nohajc commented Dec 29, 2023

I understand but that's beside the point. My example uses normal checkboxes with additional logic which just happens to emulate radio button behavior. There's obviously a problem with updating the submenu checkbox state when I call Uncheck explicitly.

I only tested on Linux but I also tried a different StatusNotifierItem implementation in Rust which doesn't exhibit this issue (i.e. uncheck works the same in both root menu and submenu).

@andydotxyz
Copy link
Member

I was responding to the two parts of your bug report. Initially curious about what systems you test on to help track down the issue. My comments about radio were in response to you considering a radio pull request.
Sorry I didn't make that more clear.

@nohajc
Copy link
Author

nohajc commented Dec 29, 2023

I was responding to the two parts of your bug report. Initially curious about what systems you test on to help track down the issue. My comments about radio were in response to you considering a radio pull request.
Sorry I didn't make that more clear.

Sure, no problem. Anyway, the checkbox item is already a Linux only feature (or at least it says so in the code). I suppose it will be the same for radio buttons.

@andydotxyz
Copy link
Member

Sure, no problem. Anyway, the checkbox item is already a Linux only feature (or at least it says so in the code). I suppose it will be the same for radio buttons.

Oh, that shouldn't be the case - can you point me to where that is? The ability for items to be checked is on all platforms now, I think that Linux uses a checkbox but nonetheless checks can be displayed on macOS and Windows too.

@nohajc
Copy link
Author

nohajc commented Dec 30, 2023

I was referring to this comment:
https://github.com/fyne-io/systray/blob/master/systray.go#L147-L149

Maybe it's not up to date?

@andydotxyz
Copy link
Member

Thanks for that, hopefully this PR helps fix the comments:

#73

@acastruc
Copy link

@nohajc any luck on this? I am encountering the same bug - submenus cannot be programmatically checked/unchecked via Check()/Uncheck(). Works fine for first level menu items

Item 1
Item 2 >
     Subitem 1
     Subitem 2
Item 3

Invoking Check() or Uncheck() on Item1, Item3 works fine
On Linux only, Invoking Check() or Uncheck() on Subitem1 or Subitem2 does not work.

@nohajc
Copy link
Author

nohajc commented Jun 13, 2024

No luck, I'm afraid. I was hoping somebody would investigate after I reported it.

@andydotxyz
Copy link
Member

I just tested on Cinnamon and the demo code works as expected...

@andydotxyz
Copy link
Member

I just coded up a simple client and can confirm that the data structures through DBus are updated correctly. The update signal is also sent.

This makes me wonder if there is a bug in the KDE menu handling, or if there is some special case where we are not sending the right signals and KDE is strict where Gnome/others are flexible...

@acastruc
Copy link

@andydotxyz just to be clear, your test has you clicking on one submenu item (not a top level menu item, but at least one level deep), which programmatically checks/unchecks a completely different submenu item ?

@nohajc
Copy link
Author

nohajc commented Jun 17, 2024

I think it's my test I posted above.
https://github.com/nohajc/systray-issue-minimal-example

Now I'm curious to try it with Cinnamon myself. But IIRC I had the same issue in Gnome too.

@andydotxyz
Copy link
Member

andydotxyz commented Jun 17, 2024

@andydotxyz just to be clear, your test has you clicking on one submenu item (not a top level menu item, but at least one level deep), which programmatically checks/unchecks a completely different submenu item ?

Yes

I think it's my test I posted above.

Correct, thanks

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

No branches or pull requests

3 participants