Skip to content

Conversation

@XDeme1
Copy link
Contributor

@XDeme1 XDeme1 commented Jun 15, 2024

Release Notes:

  • N/A

I don't think this is gonna be upstreamed to ashpd until StatusNotifier properly becomes a draft in XDG Desktop Portal

If this patch is too big I can split it in 3 parts maybe?

  • Implementation of com.cannonical.dbusmenu
  • Implementation of org.kde.StatusNotifier
  • Implement tray icons for GPUI

I have implemented support for setting only 1 tray icon. I don't know a use case for more than 1 tray item per application.

Todo:

  • Implement com.cannonical.dbusmenu
  • Cleanup

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jun 15, 2024
@mikayla-maki
Copy link
Member

mikayla-maki commented Jun 20, 2024

Oh wow, this is an interesting feature. Is this for the GNOME menu bar kind of area? I didn't know that was accessible over zbus.

@mikayla-maki
Copy link
Member

mikayla-maki commented Jun 20, 2024

As for a fork of ashpd, I think that probably sounds correct. It would be great if this got upstreamed too, so that we're contributing to the ecosystem while we're at it :D

@XDeme1
Copy link
Contributor Author

XDeme1 commented Jun 20, 2024

Oh wow, this is an interesting feature. Is this for the GNOME menu bar kind of area? I didn't know that was accessible over zbus.

This is used to create icons like the discord one:
Screenshot_20240620_173338

They stay at the top right in the GNOME top bar

@mikayla-maki
Copy link
Member

Cool! Thanks for the explanation :)

@XDeme1 XDeme1 marked this pull request as ready for review July 12, 2024 12:29
@XDeme1 XDeme1 changed the title [WIP] linux: Implement tray icons linux: Implement tray icons Jul 12, 2024
Copy link
Member

@mikayla-maki mikayla-maki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR, and I'm sorry I've let this go for so long!

As for the PR itself, the code looks good but I don't think we want to add large APIs to GPUI without a direct usage in Zed itself first. Further, I'm not sure we need the code in system_tray, or a new GPUI API at all. Can we re-use AppContext::set_menus and the related machinery for this feature?

@XDeme1
Copy link
Contributor Author

XDeme1 commented Jul 25, 2024

I don't think we want to add large APIs to GPUI without a direct usage in Zed itself first

I think I can extract the com.canonical.dbusmenu part of this PR and implement Platform::set_menus(Global Application Menu?) for Linux.
And probably close this PR for later in the future.

I'm not sure we need the code in system_tray, or a new GPUI API at all. Can we re-use AppContext::set_menus and the related machinery for this feature?

I can reuse Menu and MenuItem for the System Tray menus, but for this feature we probably need a type like SystemTrayItem.

@mikayla-maki
Copy link
Member

mikayla-maki commented Jul 26, 2024

but for this feature we probably need a type like SystemTrayItem.

What's the major difference between that and the existing menu structs?

I think I can extract the com.canonical.dbusmenu part of this PR and implement Platform::set_menus(Global Application Menu?) for Linux.

Even for that use case, we'd like there to be something to put in the menus on Linux. If you have ideas for what usually goes in a tray icon for editor apps, perhaps copying what VSCode does, that would be perfect!

@jansol
Copy link
Collaborator

jansol commented Jul 26, 2024

I think I can extract the com.canonical.dbusmenu part of this PR and implement Platform::set_menus(Global Application Menu?) for Linux.

Even for that use case, we'd like there to be something to put in the menus on Linux. If you have ideas for what usually goes in a tray icon for editor apps, perhaps copying what VSCode does, that would be perfect!

Global Application Menu is directly equivalent to the macOS menu bar AIUI? The main issue with it is that it's not that widely supported (and on KDE at least it's off by default). Anyway Populating it with the same items as the macOS menus would seem like the obvious thing to do? And if Zed knows that the global menu is being used, it could remove the hamburger menu from the title bar.

@XDeme1
Copy link
Contributor Author

XDeme1 commented Jul 26, 2024

but for this feature we probably need a type like SystemTrayItem.

What's the major difference between that and the existing menu structs?

Menu and MenuItem only describes the menu layout and not the tray icon itself, the SystemTrayItem would describe information like: icon displayed, tooltip, description and the menus displayed. The Menu would only be displayed when a user clicks the SystemTrayItem.

@mikayla-maki
Copy link
Member

Oh I understand! I think that one is ok to keep then :)

@mikayla-maki
Copy link
Member

Populating it with the same items as the macOS menus would seem like the obvious thing to do?

That's what I was thinking. That said I don't think we have as much space as the macOS menu, right? We only get a single drop down, and then everything else has to be in submenus. That could be fine, but I'd be ok with streamlining the list as well :)

@jansol
Copy link
Collaborator

jansol commented Jul 26, 2024

At least on KDE it has everything:
image

@mikayla-maki
Copy link
Member

Oh that's perfect then, we should do that!

@mikayla-maki
Copy link
Member

We're still interested in this, if there's a compelling use case in Zed or in an external project, but as there hasn't been one I'm going to close this PR for now. Please re-open if you want to continue!

@pkptzx
Copy link

pkptzx commented Jul 22, 2025

@XDeme1
I need a system tray. If GPUI doesn't add this feature, is there a way to implement it without modifying the source code of GPUI? If not, can we modify as little of GPUI's source code as possible and place the rest of the code in another crate?

@huacnlee huacnlee mentioned this pull request Dec 5, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants