Skip to content

Commit f4c82ad

Browse files
inkelizeliasnaur
authored andcommitted
app/internal/windows: don't crash on app.Fullscreen on windows/386
Before this patch, use of `app.Fullscreen` would result in "Failed to find SetWindowLongPtrW procedure in user32.dll" when running on 32 bit Windows. Signed-off-by: Inkeliz <[email protected]>
1 parent 6bfd980 commit f4c82ad

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

app/internal/windows/windows.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ var (
268268
_GetMessageTime = user32.NewProc("GetMessageTime")
269269
_GetMonitorInfo = user32.NewProc("GetMonitorInfoW")
270270
_GetWindowLong = user32.NewProc("GetWindowLongPtrW")
271+
_GetWindowLong32 = user32.NewProc("GetWindowLongW")
271272
_GetWindowPlacement = user32.NewProc("GetWindowPlacement")
272273
_KillTimer = user32.NewProc("KillTimer")
273274
_LoadCursor = user32.NewProc("LoadCursorW")
@@ -293,6 +294,7 @@ var (
293294
_SetProcessDPIAware = user32.NewProc("SetProcessDPIAware")
294295
_SetTimer = user32.NewProc("SetTimer")
295296
_SetWindowLong = user32.NewProc("SetWindowLongPtrW")
297+
_SetWindowLong32 = user32.NewProc("SetWindowLongW")
296298
_SetWindowPlacement = user32.NewProc("SetWindowPlacement")
297299
_SetWindowPos = user32.NewProc("SetWindowPos")
298300
_SetWindowText = user32.NewProc("SetWindowTextW")
@@ -471,12 +473,20 @@ func GetMonitorInfo(hwnd syscall.Handle) MonitorInfo {
471473
}
472474

473475
func GetWindowLong(hwnd syscall.Handle) (style uintptr) {
474-
style, _, _ = _GetWindowLong.Call(uintptr(hwnd), uintptr(GWL_STYLE))
476+
if runtime.GOARCH == "386" {
477+
style, _, _ = _GetWindowLong32.Call(uintptr(hwnd), uintptr(GWL_STYLE))
478+
} else {
479+
style, _, _ = _GetWindowLong.Call(uintptr(hwnd), uintptr(GWL_STYLE))
480+
}
475481
return
476482
}
477483

478484
func SetWindowLong(hwnd syscall.Handle, idx uint32, style uintptr) {
479-
_SetWindowLong.Call(uintptr(hwnd), uintptr(idx), style)
485+
if runtime.GOARCH == "386" {
486+
_SetWindowLong32.Call(uintptr(hwnd), uintptr(idx), style)
487+
} else {
488+
_SetWindowLong.Call(uintptr(hwnd), uintptr(idx), style)
489+
}
480490
}
481491

482492
func SetWindowPlacement(hwnd syscall.Handle, wp *WindowPlacement) {

0 commit comments

Comments
 (0)