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

Support for system tray icon? #7822

Open
Semphriss opened this issue Jun 14, 2023 · 12 comments · May be fixed by #10873
Open

Support for system tray icon? #7822

Semphriss opened this issue Jun 14, 2023 · 12 comments · May be fixed by #10873
Milestone

Comments

@Semphriss
Copy link
Contributor

Would it be useful to support system tray icons within SDL?


Screenshots for Windows, macOS and Ubuntu

Windows:
Windows system tray

macOS:
macOS system tray

Ubuntu:
Ubuntu system tray

Some potentially useful repositories:

@icculus
Copy link
Collaborator

icculus commented Jun 14, 2023

I want to say no here, because this probably either gets watered down to an array of strings that represent possible menu items, or it starts really getting into the specifics of various OSes in ways we don't want to expose in the API.

@smcv
Copy link
Contributor

smcv commented Jun 14, 2023

The API for "system tray" icons on Linux is a bit of a disaster area, even if we assume that a "system tray" is even desirable, which not everyone agrees; so supporting anything non-trivial in a portable way is going to be a struggle.

(Link is from 2019, there has been more recent work but nothing very conclusive)

@slouken
Copy link
Collaborator

slouken commented Jun 14, 2023

Yeah, I think this is outside the scope of SDL for now.

@slouken slouken closed this as completed Jun 14, 2023
@Semphriss
Copy link
Contributor Author

Generally speaking, what sorts of idea should I consider worth suggesting to add in SDL?

I have a few changes I'm making for my personal projects and I'd like to contribute them back, but I don't want to flood the issue tracker with my ideas. How should I decide what to share and what not to share?

@slouken
Copy link
Collaborator

slouken commented Jun 16, 2023

Feel free to share and we'll let you know if we think it's appropriate. Even if we don't include it in mainline, having it here will let other people find your changes and use them.

@Semphriss
Copy link
Contributor Author

For future reference, I managed to implement system trays on Windows, macOS, and Unix.

The source is available at https://github.com/Semphriss/SDL/tree/tray

Windows screenshot
macOS screenshot
Unix screenshot

It supports:

  • Custom tray icon (I used test/trashcan.bmp as an example)
  • Tooltip on the tray icon
  • Menus including:
    • Items
    • Disabled items
    • Checkboxes
    • Separators
    • Submenus
    • Custom callbacks on any item

I still have a few rough edges to iron out, but it generally works well at the moment. If anybody would need help to use it, please let me know!

@slouken
Copy link
Collaborator

slouken commented Sep 16, 2024

This actually looks pretty good! I'm going to go ahead and reopen this.

@slouken slouken reopened this Sep 16, 2024
@slouken slouken added this to the 3.2.0 milestone Sep 16, 2024
@Semphriss
Copy link
Contributor Author

Should I open it as a pull request?

@slouken
Copy link
Collaborator

slouken commented Sep 16, 2024

Should I open it as a pull request?

Sure!

@slouken
Copy link
Collaborator

slouken commented Sep 16, 2024

One thing I expected to see was a show/hide or some way of letting the system know you're done creating the menus. It looks like right now you can keep adding entries over time and they dynamically show up, and if you need to remove one, you have to destroy the tray and start over.

I don't know if you actually need that, just an observation.

@Semphriss
Copy link
Contributor Author

One thing I expected to see was a show/hide or some way of letting the system know you're done creating the menus. It looks like right now you can keep adding entries over time and they dynamically show up, and if you need to remove one, you have to destroy the tray and start over.

I haven't created all the possible functions, I went for the easiest path to quick results. AFAIK, all platforms support dynamically removing items at any position, so it's just a matter of adding what's missing.

@Semphriss Semphriss linked a pull request Sep 16, 2024 that will close this issue
16 tasks
@icculus
Copy link
Collaborator

icculus commented Sep 16, 2024

This actually looks pretty good! I'm going to go ahead and reopen this.

Nothing changes minds faster than working code. :)

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

Successfully merging a pull request may close this issue.

4 participants