Match window border color to app theme rather than OS theme (#958)

* MacOS: match window chrome to app light/dark mode when app setting is different from OS

* match window border to app theme on Windows
This commit is contained in:
Drew Weymouth
2026-06-24 13:46:09 -07:00
committed by GitHub
parent 2774970ca8
commit 67623366f5
9 changed files with 139 additions and 0 deletions
+21
View File
@@ -10,6 +10,7 @@ import (
"log"
"os"
"path/filepath"
"runtime"
"time"
fynetooltip "github.com/dweymouth/fyne-tooltip"
@@ -26,6 +27,7 @@ import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/driver"
"fyne.io/fyne/v2/lang"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/theme"
@@ -655,3 +657,22 @@ func (c *Controller) GetSongRadioTracks(sourceTrack *mediaprovider.Track) ([]*me
tracks = append(tracks, filteredTracks...)
return tracks, nil
}
func SetWindowThemeMode(win fyne.Window, mode myTheme.AppearanceMode) {
arg := 0
switch fyne.CurrentApp().Settings().Theme().(*myTheme.MyTheme).AppearanceMode() {
case myTheme.AppearanceDark:
arg = 1
case myTheme.AppearanceLight:
arg = 2
}
win.(driver.NativeWindow).RunNative(func(ctx any) {
switch runtime.GOOS {
case "darwin":
// ensure dark mode setting is applied to window controls in title bar on Mac
setWindowDarkTheme(ctx.(driver.MacWindowContext).NSWindow, arg)
case "windows":
setWindowDarkTheme(ctx.(driver.WindowsWindowContext).HWND, arg)
}
})
}