Added a basic example of how to use webview with VTray to create a de…
Added a basic example of how to use webview with VTray to create a desktop app with a custom notification tray icon with menus.
Thanks for the PR @Ouri028. Good joob with the lib. Since webview is a cross-platform library, I would like to wait until VTray supports at least two of the major OSes before adding it as example to the repo. Also, I'm currently not able to test Windows things as I'm only having a mac arm machine available where I cannot virtualise x64 architecture on and V is not running on windows arm.
Thanks for the PR @Ouri028. Good joob with the lib. Since webview is a cross-platform library, I would like to wait until VTray supports at least two of the major OSes before adding it as example to the repo. Also, I'm currently not able to test Windows things as I'm only having a mac arm machine available where I cannot virtualise x64 architecture on and V is not running on windows arm.
Hey man,
That's fine, I just pushed a new version that supports Linux, I am currently working on the MacOS version (managed to secure myself a Mac :D), currently working off the example that was on the V repo to display the Mac tray, but will let you know as soon as MacOS is also supported.
Please keep in mind that the Linux version was only tested on Debian based images (Ubuntu, Lubuntu, etc), so no idea if it will work with all distros.
To be honest, I do not plan to support a large amount of distros as it can get a bit much.
Nice to hear about the linux support. Covering the main desktop environments like Gnome and Plasma is totally sufficient imho. Extended support can come over time. Also good to hear about the mac situation 😁.
When I have a Windows device available for checking I'll add a review, so we can come to merge this. Thanks already!
Added MacOS support for VTray.
I only tested it on macos ventura, since that's what I currently use.
Trying to run the example on macOS ventrua I'm encountering:
2023-10-01 20:14:13.888 app-with-systray[59082:3120931] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the
Main Thread!'
*** First throw call stack:
(
0 CoreFoundation 0x000000019a05b154 __exceptionPreprocess + 176
1 libobjc.A.dylib 0x0000000199b7a4d4 objc_exception_throw + 60
2 CoreFoundation 0x000000019a0843a0 _CFBundleGetValueForInfoKey + 0
3 AppKit 0x000000019d22a638 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 320
4 AppKit 0x000000019d21890c -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 816
5 AppKit 0x000000019d2185d0 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 48
6 AppKit 0x000000019d89f69c -[NSStatusBarWindow initForStatusItem:] + 112
7 AppKit 0x000000019d8a2068 -[NSStatusItem _initWithStatusBar:length:priority:systemInsertOrder:] + 312
8 AppKit 0x000000019d426010 -[NSStatusBar _statusItemWithLength:withPriority:] + 64
9 app-with-systray 0x0000000104b39484 -[AppDelegate initTrayMenuItem] + 56
10 app-with-systray 0x0000000104b39694 vtray_init_mac + 128
11 app-with-systray 0x0000000104b638e8 vtray__VTrayApp_vtray_init + 268
12 app-with-systray 0x0000000104b650a4 main__create_tray + 344
13 app-with-systray 0x0000000104b39868 main__create_tray_thread_wrapper + 28
14 app-with-systray 0x0000000104b73910 GC_pthread_start + 104
15 libsystem_pthread.dylib 0x0000000199f03fa8 _pthread_start + 148
16 libsystem_pthread.dylib 0x0000000199efeda0 thread_start + 8
)
libc++abi: terminating due to uncaught exception of type NSException
Trying to run the example on macOS ventrua I'm encountering:
2023-10-01 20:14:13.888 app-with-systray[59082:3120931] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!' *** First throw call stack: ( 0 CoreFoundation 0x000000019a05b154 __exceptionPreprocess + 176 1 libobjc.A.dylib 0x0000000199b7a4d4 objc_exception_throw + 60 2 CoreFoundation 0x000000019a0843a0 _CFBundleGetValueForInfoKey + 0 3 AppKit 0x000000019d22a638 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 320 4 AppKit 0x000000019d21890c -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 816 5 AppKit 0x000000019d2185d0 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 48 6 AppKit 0x000000019d89f69c -[NSStatusBarWindow initForStatusItem:] + 112 7 AppKit 0x000000019d8a2068 -[NSStatusItem _initWithStatusBar:length:priority:systemInsertOrder:] + 312 8 AppKit 0x000000019d426010 -[NSStatusBar _statusItemWithLength:withPriority:] + 64 9 app-with-systray 0x0000000104b39484 -[AppDelegate initTrayMenuItem] + 56 10 app-with-systray 0x0000000104b39694 vtray_init_mac + 128 11 app-with-systray 0x0000000104b638e8 vtray__VTrayApp_vtray_init + 268 12 app-with-systray 0x0000000104b650a4 main__create_tray + 344 13 app-with-systray 0x0000000104b39868 main__create_tray_thread_wrapper + 28 14 app-with-systray 0x0000000104b73910 GC_pthread_start + 104 15 libsystem_pthread.dylib 0x0000000199f03fa8 _pthread_start + 148 16 libsystem_pthread.dylib 0x0000000199efeda0 thread_start + 8 ) libc++abi: terminating due to uncaught exception of type NSException
Hey man,
So, I had a look into this issue and it seems MacOS does not like running tray processes in other threads, but there is a fix for this, will post an update to the example a little later with the changes.
Here is a screenshot of the working example.
Updated the code example to include the fix for MacOS threading.
Thanks for the update @Ouri028
Now it builds and runs! The things I'm noticing now:
-
The window has issues staying in the foreground unless it's directly clicked on else it will move back to the background, e.g., when it's clicked from mission control. Video example:
https://github.com/ttytm/webview/assets/34311583/ac4792ac-2ce6-477d-a19b-bb114c55c70d
It's probably a window hint that needs to be set for the NSApplication that vtray creates and handles.
-
The
icon.pngfile is missing. -
Now there are log messages whenever running a V app on macos which uses vtray, which probably shouldn't always be there. E.g.:
2023-10-02 00:43:43.752 app-with-systray[91696:3401607] applicationWillFinishLaunching called 2023-10-02 00:44:26.854 app-with-systray[91696:3401560] applicationShouldTerminate called 2023-10-02 00:44:26.855 app-with-systray[91696:3401560] applicationWillTerminate called
Thanks for the update @Ouri028
Now it builds and runs! The things I'm noticing now:
* The window has issues staying in the foreground unless it's directly clicked on else it will move back to the background, e.g., when it's clicked from mission control. Video example: vtray-mc.mp4 It's probably a window hint that needs to be set for the NSApplication that vtray creates and handles. * The `icon.png` file is missing. * Now there are log messages whenever running a V app on macos which uses vtray, which probably shouldn't always be there. E.g.: ``` 2023-10-02 00:43:43.752 app-with-systray[91696:3401607] applicationWillFinishLaunching called 2023-10-02 00:44:26.854 app-with-systray[91696:3401560] applicationShouldTerminate called 2023-10-02 00:44:26.855 app-with-systray[91696:3401560] applicationWillTerminate called ```
Hey @ttytm ,
Thanks for the detailed issue, I have fixed them and pushed a new version of VTray and the example, please let me know if you encounter anything else. 😄
PR is on hold:
[...] I will ask that you please put my PR on hold for the webview until the rework is done ☺️ [...]
ref: https://github.com/Ouri028/VTray/pull/2#issuecomment-1749444186