Skip to content

Commit

Permalink
Fixes fyne-io#4758, set the correct parameter memory and size for Dwm…
Browse files Browse the repository at this point in the history
…SetWindowAttribute and DWMWA_USE_IMMERSIVE_DARK_MODE on windows.
  • Loading branch information
beeblebrox committed Oct 5, 2024
1 parent 7d81356 commit 1effa92
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/driver/glfw/window_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ func (w *window) setDarkMode() {
if runtime.GOOS == "windows" {
hwnd := w.view().GetWin32Window()
dark := isDark()

// cannot use a go bool.
var winBool int32
if dark {
winBool = 1
}
dwm := syscall.NewLazyDLL("dwmapi.dll")
setAtt := dwm.NewProc("DwmSetWindowAttribute")
ret, _, err := setAtt.Call(uintptr(unsafe.Pointer(hwnd)), // window handle
20, // DWMWA_USE_IMMERSIVE_DARK_MODE
uintptr(unsafe.Pointer(&dark)), // on or off
8) // sizeof(darkMode)
uintptr(unsafe.Pointer(&winBool)), // on or off
4) // sizeof(bool for windows)

if ret != 0 && ret != 0x80070057 { // err is always non-nil, we check return value (except erroneous code)
fyne.LogError("Failed to set dark mode", err)
Expand Down

0 comments on commit 1effa92

Please sign in to comment.