Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #4758, set the correct parameter memory and size for DwmSetWindowAttribute and DWMWA_USE_IMMERSIVE_DARK_MODE on windows. #5180

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 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)
20, // DWMWA_USE_IMMERSIVE_DARK_MODE
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
Loading