Skip to content

Conversation

FlexW
Copy link

@FlexW FlexW commented May 2, 2021

This pull request implements D-Bus menus for the tray icons. @ianyfan @nmschulte It seems like #5161 is dead, and I would like to take over. Please tell me if this is not the case, then I will close this pull request.

This pull request is based on #5161 and is a draft for now. Please don't test it yet. When the pull request is ready for testing, I will say so.

@ianyfan @nmschulte I created this early pull request to let you know I'm working on it. Just in case that we do not double the work. Maybe you could add some other points that should be addressed before this pull request can be merged. I would say keyboard navigation and touch support can be done in a second pr.

@emersion
Copy link
Member

emersion commented May 2, 2021

@ianyfan @nmschulte It seems like #5161 is dead

Yes, this PR has been looking for a new owner for a while. Thanks for taking over!

@nmschulte
Copy link
Contributor

@FlexW Thank you for doing this. I would like to support you however I can.

Please see my branch from #5161 work; https://github.com/nmschulte/sway/tree/fix-tray-updates. It has improved message handling to resolve some the standing issues of #5161; it is based upon current master/master, and I rebase it locally about once a week to continue using it. Since 1.6 / wlroots 1.2/1.3, something has broken for me w/re: non-1.0 DPI scaling and popups, such that most apps no longer work to show menus in this scenario.

This is all I have for now; I will be following closely. Later I will check your list and my notes and share any new items I've thought about to incorporate.

@FlexW
Copy link
Author

FlexW commented May 2, 2021

@FlexW Thank you for doing this. I would like to support you however I can.

Please see my branch from #5161 work; https://github.com/nmschulte/sway/tree/fix-tray-updates. It has improved message handling to resolve some the standing issues of #5161; it is based upon current master/master, and I rebase it locally about once a week to continue using it. Since 1.6 / wlroots 1.2/1.3, something has broken for me w/re: non-1.0 DPI scaling and popups, such that most apps no longer work to show menus in this scenario.

This is all I have for now; I will be following closely. Later I will check your list and my notes and share any new items I've thought about to incorporate.

Thank you for your support. I'll check your branch out. I think I had the same scaling issue that you described, and I think that issue is resolved in my branch. There was an issue with not specifying the correct size of the buffer when scaling is activated. If you want you can check out my branch and see if the scaling issue is gone for you too.

@nmschulte
Copy link
Contributor

nmschulte commented May 2, 2021 via email

@Xyene
Copy link
Member

Xyene commented May 2, 2021

something has broken for me w/re: non-1.0 DPI scaling and popups, such that most apps no longer work to show menus in this scenario.

Does #6147 match what you're describing? If so and you're experiencing it with other apps, would be worth leaving a note in that thread.

@nmschulte
Copy link
Contributor

Does #6147 match what you're describing? If so and you're experiencing it with other apps, would be worth leaving a note in that thread.

@Xyene I don't think #6147 describes the issue, but I can try with external displays; experiencing this on a laptop with 4K display, no external monitors.

Zoom does strange things with its menus under Wayland such that the menus popup on the wrong output or don't show at all, depending which output they're parented, on a top-bottom-plus-(rotated-)straddling-sides 4-output DPI==1 stationary desktop setup though. Also I see #6148 with this same setup.

@nmschulte
Copy link
Contributor

Since 1.6 / wlroots 1.2/1.3, something has broken for me w/re: non-1.0 DPI scaling and popups, such that most apps no longer work to show menus in this scenario.

😃 All of the popups seem to be working on this branch (flexw/tray-dbus-menu). swaybar crashed during my first smoke test, however. More to come.

@FlexW
Copy link
Author

FlexW commented May 3, 2021

Since 1.6 / wlroots 1.2/1.3, something has broken for me w/re: non-1.0 DPI scaling and popups, such that most apps no longer work to show menus in this scenario.

All of the popups seem to be working on this branch (flexw/tray-dbus-menu). swaybar crashed during my first smoke test, however. More to come.

Thats great to hear. I'm aware of that crash, it's because I don't handle the hotspots correct fow now. I'll let you know when I fixed it.

@FlexW FlexW force-pushed the feature/tray-dbus-menu branch from 3357c6b to a9e77fe Compare May 10, 2021 18:58
@FlexW
Copy link
Author

FlexW commented May 10, 2021

@nmschulte The crash that you experienced is gone now. You may experience other crashes or bugs. It's WIP. Just wanted to let you know :)

@FlexW FlexW force-pushed the feature/tray-dbus-menu branch from a9e77fe to 8914389 Compare May 23, 2021 16:41
@nmschulte
Copy link
Contributor

@FlexW after merging master and dealing with wayland-protocol version issues, I've managed to build this branch and use it for about a week. I haven't yet had time to review the code changes, however.
I do see a few bugs and swaybar crashes still, related to sub-menu interactions. I'll investigate and follow up when I can.

@TimB87
Copy link

TimB87 commented Jun 21, 2021

uneducated question: is there a possibility that this might work with basu as well?

@emersion
Copy link
Member

It should, yes.

@FlexW FlexW force-pushed the feature/tray-dbus-menu branch 4 times, most recently from c56a8cb to e212e13 Compare July 31, 2021 19:31
@FlexW
Copy link
Author

FlexW commented Jul 31, 2021

@nmschulte Finally I found some time to work on it. Should now work better. So far I couldn't crash it anymore and it works as I would expect it with all my tray icons (nmapplet, nextcloud, udiskie, blueman, gammastep-indicator). I would appreciate it if you could do some tests too (I rebased against the latest master). Maybe you also know some more applications with which I can test.

@FlexW
Copy link
Author

FlexW commented Aug 1, 2021

@ianyfan @emersion One more question: It seems like the wl_pointer_button, wl_pointer_motion event and dbus events etc run in parallel. How would you advise avoiding race conditions while operating on the swaybar_dbusmenu structure? Mutexes?

@emersion
Copy link
Member

emersion commented Aug 1, 2021

They don't run "in parallel", there's only one thread. The event loop will dispatch D-Bus events and Wayland events one after the other. No need for any kind of locking or race condition prevention.

@FlexW
Copy link
Author

FlexW commented Aug 1, 2021

@emersion Thank you for clarifying. Will a call to wl_display_roundtrip() lead to dispatching events? So if I call it in a function I will after wl_display_roundtrip() returns have code running in parallel?

EDIT: Probably not, because there is only one thread.

@nmschulte
Copy link
Contributor

I finally managed to build this (caved and built libdrm, wayland-protocols); sorry my report is shallow.

I managed to crash swaybar playing with udiskie again; I only managed it once and have no logs.

Both udiskie and nm-applet menus seem to flicker more than I'd like to see as a user.

Sub-menus are placed a bit off for me (2x scale), and there's an odd looking "bar"/line/border at the bottom of the sub-menus.

image

Finally, and I'm not confident in my sway-term/understanding here, there's still something odd with focus, popups, and xwayland vs xdg_shell (backends?).
I was unable to use my key binding to launch dmenu; gimp's menubar would not... popup, even though the interaction feedback seemed to work. Just prior, I was using screenshot.sh (dmenu) to take a shot of the open popup(s) from swaybar (which works great/is possible as long as I don't have to click), which uses mako to notify the success (popup?).
In the end, I was able to rectify things after mashing the keyboard, switching workspaces, clicking / changing focus, etc. without restarting sway. 🤷 I've spoke about similar things in the original PR.

@FlexW FlexW force-pushed the feature/tray-dbus-menu branch 5 times, most recently from 5944eb9 to f641e58 Compare September 10, 2021 22:35
@FlexW
Copy link
Author

FlexW commented Sep 10, 2021

Thank you for your feedback @nmschulte. I would like to get this pr reviewed, because I think it works well enough and provides everything to do basic work with tray menus. There are some things that could be better, but I think it is usable. I can not crash it anymore, udiskie does just sometimes blink for me one time when I open the menu. Submenus work also fine.

Maybe one of the maintainers can help with getting the last flickering and focus problems away.

@emersion

@DemiMarie
Copy link

It’s quite possible that some of the crashes are due to libdbusmenu being buggy — it is unmaintained for several years now (since 2017, IIUC) and Waybar also has problems with it.

@kittybwained
Copy link

Any news on this?

Guanran928 added a commit to Guanran928/flake that referenced this pull request Feb 24, 2024
swaywm/sway#7226 is merged
swaywm/sway#6249 looks dead :(

also simplified ./overlays
@NickHu
Copy link

NickHu commented Mar 2, 2024

This patch no longer cleanly applies on newer versions of sway.
I've rebased this on top of sway 1.9 here: https://github.com/NickHu/sway/tree/feature/tray-dbus-menu-1.9, incorporating @FlorianFranzen's changes above.
As far as I am concerned, I have been using this patch for years and never experienced any instability, so even if it's not perfect and there are edge cases I would be happy to see this merged.

@Jamim
Copy link

Jamim commented Mar 16, 2024

Hello @NickHu,

I've rebased this on top of sway 1.9 here: NickHu/sway@feature/tray-dbus-menu-1.9, incorporating @FlorianFranzen's changes above.

Would you mind submitting an alternative PR?

Thanks in advance!

@DemiMarie
Copy link

@NickHu would you mind fuzzing this to ensure it is safe and secure against malicious D-Bus clients?

@NickHu
Copy link

NickHu commented Mar 18, 2024

No thank you, I don't have either the expertise nor the willingness to undertake any development in sway. Anyone else is free to do whatever they like with my tiny contribution of rebasing.

@llyyr
Copy link
Contributor

llyyr commented Aug 22, 2024

I've been daily driving this for a few days now, and besides one issue that I fixed here (llyyr@84481c2), it seems mostly stable now across the clients I use.

fwiw I also rebased it on master here in case there's other people that want to test it out. https://github.com/llyyr/sway/tree/dbus-tray

I don't really know what's needed to push this further besides some style nits I noticed

@DemiMarie
Copy link

I've been daily driving this for a few days now, and besides one issue that I fixed here (llyyr@84481c2), it seems mostly stable now across the clients I use.

fwiw I also rebased it on master here in case there's other people that want to test it out. https://github.com/llyyr/sway/tree/dbus-tray

I don't really know what's needed to push this further besides some style nits I noticed

Can you make a PR with all of the fixes?

@grazzolini
Copy link

I have been keeping these patches on my own fork for a while now and I building a version of this package on Arch without any issues. What is preventing this from being merged?

@eclairevoyant
Copy link

eclairevoyant commented Oct 22, 2024

The changes won't merge, so a new PR has to be made, or this one needs to be rebased/force-pushed. Additionally someone would need to incorporate the testing mentioned here and the fix mentioned here. So far no one else has submitted a PR to supercede this one.

@grazzolini
Copy link

The changes won't merge, so a new PR has to be made, or this one needs to be rebased/force-pushed. Additionally someone would need to incorporate the testing mentioned here and the fix mentioned here. So far no one else has submitted a PR to supercede this one.

The tray-dbus-menu-1.9 branch on my fork contains all the patches and fixes from this branch. However, I'm not sure about the testing part.

@eclairevoyant
Copy link

The tray-dbus-menu-1.9 branch on my fork contains all the patches and fixes from this branch.

Feel free to open a PR then to drive this forward.

@grazzolini
Copy link

The tray-dbus-menu-1.9 branch on my fork contains all the patches and fixes from this branch.

Feel free to open a PR then to drive this forward.

Sure, I'll create a new branch, because that one is targeting the latest release, not main.

@grazzolini grazzolini mentioned this pull request Oct 24, 2024
@grazzolini
Copy link

Created #8405. Rebased it against master.

@jackpurrin
Copy link

I kinda need to use this patch, and I see people using it, but how can I actually start using it?

@GreyXor
Copy link
Contributor

GreyXor commented Jun 26, 2025

I kinda need to use this patch, and I see people using it, but how can I actually start using it?

You more want to use this PR : #8698
and this this branch : https://github.com/rogueai/sway/tree/tray-dbus-menu
the method to compile it is described here : https://github.com/rogueai/sway/tree/tray-dbus-menu?tab=readme-ov-file#compiling-from-source

if you use arch I can provide you a PKGBUILD to automate everything, just ask.

@Dantali0n
Copy link

We now have at least #8698 #8405 and this one, #6249 should we try to consolidate a bit? because otherwise we might run in to more and more confused users, especially since some of the patches are already used in the wild.

@jackpurrin
Copy link

@GreyXor Yeah I use Arch, so a PKGBUILD would be appreciated!!

@grazzolini
Copy link

I am not using sway at the moment, which is the reason I haven't touched this patch in a while. I was using a fork of sway on my personal account on top of which I applied the patches and then used Arch's sway PKGBUILD to point to this fork as the source.

@mattfbacon
Copy link
Contributor

@Dantali0n #8698 is a rebase of #8405 which is a cleaned-up and patched version of this PR. So if we were to move forward it would be with #8698.

@jackpurrin
Copy link

@GreyXor Also if you are going to provide a PKGBUILD, do I need to uninstall sway before I make it or will it replace my current sway install?

@GreyXor
Copy link
Contributor

GreyXor commented Jun 27, 2025

@GreyXor Also if you are going to provide a PKGBUILD, do I need to uninstall sway before I make it or will it replace my current sway install?

Hello, it will replace it.
here is the PKGBUILD
So basically you can git clone the sway-git repo replace the PKGBUILD with mine and run makepkg -si in the directory. You also need to wait for #8698 to be rebased from sway master

@pd2s
Copy link

pd2s commented Aug 6, 2025

This might be useful here: I'm currently working on a new widget library and as an example I implemented a swaybar with full tray dbusmenu support: https://github.com/pd2s/sw/tree/master/examples/sw_swaybar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or incremental improvement

Development

Successfully merging this pull request may close these issues.