Skip to content

Added SetIcon method and new IconKind type#47

Open
quadrimus wants to merge 1 commit into
webview:masterfrom
quadrimus:master
Open

Added SetIcon method and new IconKind type#47
quadrimus wants to merge 1 commit into
webview:masterfrom
quadrimus:master

Conversation

@quadrimus

Copy link
Copy Markdown

Current implementation works for Windows, for other platforms SetIcon do nothing.

Support for all platform is WIP and will be delivered later (if accepted).

See also: #46

meiser79 added a commit to meiser79/AriaCast-Client-CrossPlatform that referenced this pull request Jun 22, 2026
Build
-----
- Vendor a patched copy of webview/webview_go (third_party/webview_go)
  that links against webkit2gtk-4.1 instead of the removed/deprecated
  webkit2gtk-4.0, wired up via a go.mod replace directive.
- Fix the vendored webview.h's get_webkit_library(): it only looked up
  the unversioned "libwebkit2gtk-4.1.so" symlink, which is provided
  only by the -dev package. On any machine with just the runtime
  package installed, this silently broke every native Go->JS call
  (Eval() pushes and Bind() return values) with no error anywhere.
  Added the actual runtime SONAMEs (libwebkit2gtk-4.1.so.0,
  libwebkit2gtk-4.0.so.37) as fallbacks.
- Add SetIcon([]byte) to the vendored webview_go library, extending
  the Windows-only approach from webview/webview_go#47 to Linux:
  - engine_base gains a set_icon()/set_icon_impl() pair with a default
    no-op so macOS and Windows compile without changes.
  - gtk_webkit_engine overrides set_icon_impl() using GdkPixbuf
    (g_memory_input_stream_new_from_data + gdk_pixbuf_new_from_stream
    + gtk_window_set_icon), loading the icon from raw bytes without
    any temp file.
  - webview_set_icon() C API function added alongside webview_set_title().
  - Go binding: SetIcon(iconData []byte) added to the WebView interface
    and implemented on *webview.

Linux runtime fixes
--------------------
- main_linux.go was missing the appMinimize/appClose/startDrag
  bindings that main_windows.go already had, so the header buttons
  and minimize did nothing. Added them, with minimize implemented via
  a real gtk_window_iconify() call. The same bindings were also
  missing on macOS; fixed there too.
- Default WEBKIT_DISABLE_COMPOSITING_MODE=1 on Linux: WebKitGTK's
  accelerated compositing was breaking pointer-event hit-testing
  (clicks/slider drags silently swallowed) on some GPU/driver
  combinations.
- Fix a mutex deadlock in Stop(): it called setStatus() (which also
  locks mu) while still holding the lock via defer, hanging forever
  and making the stream impossible to stop.
- Stop pinning an explicit capture DeviceID in miniaudio's config:
  this set PA_STREAM_DONT_MOVE on the PulseAudio stream, preventing
  pavucontrol from moving it to a different source while streaming.

Protocol / streaming fixes
---------------------------
- Connect /control and /stats WebSocket channels in addition to
  /audio, as required by the Music Assistant AriaCast receiver plugin
  before it considers a client connected.
- POST {"isPlaying":true} to /metadata on connect (repeated every 30s,
  isPlaying:false on stop): the receiver plugin only starts an audio
  player once it observes this flag, regardless of whether audio
  frames are already streaming.

UI
--
- Set the native program icon via w.SetIcon() from an embedded PNG,
  shown in the WM titlebar/taskbar/Alt+Tab.
- Push status/server-info updates to the page via w.Eval() (JSON-
  encoded, not raw string interpolation), now that the underlying
  webview.h bug is fixed.
meiser79 added a commit to meiser79/AriaCast-Client-CrossPlatform that referenced this pull request Jun 22, 2026
Build
-----
- Vendor a patched copy of webview/webview_go (third_party/webview_go)
  that links against webkit2gtk-4.1 instead of the removed/deprecated
  webkit2gtk-4.0, wired up via a go.mod replace directive.
- Fix the vendored webview.h's get_webkit_library(): it only looked up
  the unversioned "libwebkit2gtk-4.1.so" symlink, which is provided
  only by the -dev package. On any machine with just the runtime
  package installed, this silently broke every native Go->JS call
  (Eval() pushes and Bind() return values) with no error anywhere.
  Added the actual runtime SONAMEs (libwebkit2gtk-4.1.so.0,
  libwebkit2gtk-4.0.so.37) as fallbacks.
- Extend webview/webview_go#47 (SetIcon, Windows-only) to Linux:
  - icon.go: build tag changed from !windows to !windows && !linux;
    remains a no-op stub for macOS and other platforms.
  - icon_linux.go (new, //go:build linux): converts image.Image to
    PNG bytes via image/png, passes them to a CGo helper
    (webviewSetWindowIcon) that loads them with GdkPixbuf
    (g_memory_input_stream_new_from_data + gdk_pixbuf_new_from_stream)
    and calls gtk_window_set_icon. IconKind is ignored on GTK since
    the WM scales a single icon itself.
  - icon_windows.go (new): taken directly from PR #47, unchanged.
  - webview.go: IconKind type and constants added, image import added,
    icons field added to the webview struct, w.i.free() called in
    Destroy(), SetIcon(image.Image, IconKind) added to the WebView
    interface and implemented as w.i.setIcon(w.Window(), icon, kind).
  - main_linux.go: decodes the embedded ui/icon.png to image.Image
    and calls w.SetIcon(img, webview.IconKindDefault) via Dispatch.

Linux runtime fixes
--------------------
- main_linux.go was missing the appMinimize/appClose/startDrag
  bindings that main_windows.go already had, so the header buttons
  and minimize did nothing. Added them, with minimize implemented via
  a real gtk_window_iconify() call. The same bindings were also
  missing on macOS; fixed there too.
- Default WEBKIT_DISABLE_COMPOSITING_MODE=1 on Linux: WebKitGTK's
  accelerated compositing was breaking pointer-event hit-testing
  (clicks/slider drags silently swallowed) on some GPU/driver
  combinations.
- Fix a mutex deadlock in Stop(): it called setStatus() (which also
  locks mu) while still holding the lock via defer, hanging forever
  and making the stream impossible to stop.
- Stop pinning an explicit capture DeviceID in miniaudio's config:
  this set PA_STREAM_DONT_MOVE on the PulseAudio stream, preventing
  pavucontrol from moving it to a different source while streaming.

Protocol / streaming fixes
---------------------------
- Connect /control and /stats WebSocket channels in addition to
  /audio, as required by the Music Assistant AriaCast receiver plugin
  before it considers a client connected.
- POST {"isPlaying":true} to /metadata on connect (repeated every 30s,
  isPlaying:false on stop): the receiver plugin only starts an audio
  player once it observes this flag, regardless of whether audio
  frames are already streaming.

UI
--
- Set the native program icon via w.SetIcon() from an embedded PNG,
  shown in the WM titlebar/taskbar/Alt+Tab.
- Push status/server-info updates to the page via w.Eval() (JSON-
  encoded, not raw string interpolation).
meiser79 added a commit to meiser79/AriaCast-Client-CrossPlatform that referenced this pull request Jun 23, 2026
Build
-----
- Vendor a patched copy of webview/webview_go (third_party/webview_go)
  that links against webkit2gtk-4.1 instead of the removed/deprecated
  webkit2gtk-4.0, wired up via a go.mod replace directive.
- Fix the vendored webview.h's get_webkit_library(): it only looked up
  the unversioned "libwebkit2gtk-4.1.so" symlink, which is provided
  only by the -dev package. On any machine with just the runtime
  package installed, this silently broke every native Go->JS call
  (Eval() pushes and Bind() return values) with no error anywhere.
  Added the actual runtime SONAMEs (libwebkit2gtk-4.1.so.0,
  libwebkit2gtk-4.0.so.37) as fallbacks.
- Extend webview/webview_go#47 (SetIcon, Windows-only) to Linux:
  - icon.go: build tag changed from !windows to !windows && !linux;
    remains a no-op stub for macOS and other platforms.
  - icon_linux.go (new, //go:build linux): converts image.Image to
    PNG bytes via image/png, passes them to a CGo helper
    (webviewSetWindowIcon) that loads them with GdkPixbuf
    (g_memory_input_stream_new_from_data + gdk_pixbuf_new_from_stream)
    and calls gtk_window_set_icon. IconKind is ignored on GTK since
    the WM scales a single icon itself.
  - icon_windows.go (new): taken directly from PR #47, unchanged.
  - webview.go: IconKind type and constants added, image import added,
    icons field added to the webview struct, w.i.free() called in
    Destroy(), SetIcon(image.Image, IconKind) added to the WebView
    interface and implemented as w.i.setIcon(w.Window(), icon, kind).
  - main_linux.go: decodes the embedded ui/icon.png to image.Image
    and calls w.SetIcon(img, webview.IconKindDefault) via Dispatch.

Linux runtime fixes
--------------------
- main_linux.go was missing the appMinimize/appClose/startDrag
  bindings that main_windows.go already had, so the header buttons
  and minimize did nothing. Added them, with minimize implemented via
  a real gtk_window_iconify() call. The same bindings were also
  missing on macOS; fixed there too.
- Default WEBKIT_DISABLE_COMPOSITING_MODE=1 on Linux: WebKitGTK's
  accelerated compositing was breaking pointer-event hit-testing
  (clicks/slider drags silently swallowed) on some GPU/driver
  combinations.
- Fix a mutex deadlock in Stop(): it called setStatus() (which also
  locks mu) while still holding the lock via defer, hanging forever
  and making the stream impossible to stop.
- Stop pinning an explicit capture DeviceID in miniaudio's config:
  this set PA_STREAM_DONT_MOVE on the PulseAudio stream, preventing
  pavucontrol from moving it to a different source while streaming.

Protocol / streaming fixes
---------------------------
- Connect /control and /stats WebSocket channels in addition to
  /audio, as required by the Music Assistant AriaCast receiver plugin
  before it considers a client connected.
- POST {"isPlaying":true} to /metadata on connect (repeated every 10s,
  isPlaying:false on stop): the receiver plugin only starts an audio
  player once it observes this flag, regardless of whether audio
  frames are already streaming.

UI
--
- Set the native program icon via w.SetIcon() from an embedded PNG,
  shown in the WM titlebar/taskbar/Alt+Tab.
- Push status/server-info updates to the page via w.Eval() (JSON-
  encoded, not raw string interpolation).
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 this pull request may close these issues.

1 participant