zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
45.4k stars 2.48k forks source link

Windows & Linux: Support `set_dock_menu` equivalents across platforms in a unified way #12068

Open versecafe opened 3 months ago

versecafe commented 3 months ago

Check for existing issues

Describe the feature

Add support for set_dock_menu to Windows and Linux called Dock : MacOS, Desktop Launcher Actions : Linux, Taskbar Customization : Windows

Windows

Called User Tasks form a menu that supports

Linux ~

Writing to .desktop file allows custom actions within some linux desktop environments

More information at freedesktop.org # Table 2. Standard Keys

Key Goal

Avoid fragmenting implementations of this into a per OS custom system and falling into the same pit electron has when handling dock menus

If applicable, add mockups / screenshots to help present your vision of the feature

Linux Sample

image

Windows Sample

image

SomeoneToIgnore commented 3 months ago

https://github.com/zed-industries/zed/pull/9919 (and the PR it follows-up) https://github.com/zed-industries/zed/pull/12067 established the API as

https://github.com/zed-industries/zed/blob/ba1d28f160459bc13c6ec9f044afff1f97fae294/crates/gpui/src/platform.rs#L138-L139

So far, only macOS code provides impls for the methods, but nominally the issue is implemented already — there's a unified way to set menu items and recently opened files. Other platforms are sure welcome to add those, and that sure happens eventually, so should we close the issue?

bbb651 commented 3 months ago

Unfortunately, I don't think it's possible to add desktop actions dynamically on linux, they are the equivalent of the dock menu but they work more like iOS when you long press an app on the homescreen, in that they are accessible even when Zed is closed. They are currently only used once with a constant value, so it should be simple to add it (for reference, this is vscode's desktop file with the same action), avoiding duplicating action definitions and having it work for arbitrary GPUI applications sounds complicated and depends on their build/packaging scripts...

For recent files, I found this ancient Recent File Storage Specification which sounds like it might be used by desktops, but then this Desktop Bookmark Specification seems to replace it. It could've sworn this was supported on gnome but apparently not, I'm still trying to decipher what spec is used, I found this gnome extension that uses Gtk.RecentManager which uses gio's recent://, and on the KDE side I found this which and the backend code it's referring to.

JunkuiZhang commented 3 months ago

Like on Linux, it is also pretty complicated on Windows. On macOS, dock menu acts like a button, on Windows, it is something like:

Command::new("Zed.exe").with_args("...")

It tries to open a new instance of the app, the only infomation is the args we pass.

dovakin0007 commented 2 months ago

found some docs for creating jumplist in windows https://learn.microsoft.com/en-us/samples/microsoft/windows-universal-samples/jumplist/ this is a sample provided by Microsoft to create a sample jump list for an app

dovakin0007 commented 4 weeks ago

Is this something similar to the set_dock_menu should I achieve in windows Screenshot 2024-07-28 222636

JunkuiZhang commented 4 weeks ago

Is this something similar to the set_dock_menu should I achieve in windows

As I mentioned before, this will open a new instance of the app, unlike on macOS where it behaves like a button.

If you don’t believe me, please give it a try.

versecafe commented 4 weeks ago

@JunkuiZhang That could be handled by passing along a flag that tells GPUI to merge the instances a bit hacky but it's a way around windows having poor handling

dovakin0007 commented 4 weeks ago

Is this something similar to the set_dock_menu should I achieve in windows

As I mentioned before, this will open a new instance of the app, unlike on macOS where it behaves like a button.

If you don’t believe me, please give it a try.

https://github.com/zed-industries/zed/pull/15371 seems like you are already working on it

JunkuiZhang commented 4 weeks ago

Yes, this approach is somewhat hacky, but Chrome handles it in a similar way.

dovakin0007 commented 2 weeks ago

image so is this a part of this feature?