From 95365d587865d24a0cdf7f208e1fe79faa5371ef Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 2 Mar 2022 18:14:45 +0100 Subject: [PATCH] app/internal/windows,app: [Windows] generalize windows.GetPointerLong We're about to use it to store the Go window cgo.Handle. Signed-off-by: Elias Naur --- app/internal/windows/windows.go | 14 +++++++------- app/os_windows.go | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/internal/windows/windows.go b/app/internal/windows/windows.go index 3b4c9615..0289507b 100644 --- a/app/internal/windows/windows.go +++ b/app/internal/windows/windows.go @@ -99,7 +99,7 @@ const ( CW_USEDEFAULT = -2147483648 - GWL_STYLE = ^(uint32(16) - 1) // -16 + GWL_STYLE = ^(uintptr(16) - 1) // -16 GCS_COMPSTR = 0x0008 GCS_COMPREADSTR = 0x0001 @@ -525,11 +525,11 @@ func GetMonitorInfo(hwnd syscall.Handle) MonitorInfo { return mi } -func GetWindowLong(hwnd syscall.Handle) (style uintptr) { +func GetWindowLong(hwnd syscall.Handle, index uintptr) (val uintptr) { if runtime.GOARCH == "386" { - style, _, _ = _GetWindowLong32.Call(uintptr(hwnd), uintptr(GWL_STYLE)) + val, _, _ = _GetWindowLong32.Call(uintptr(hwnd), index) } else { - style, _, _ = _GetWindowLong.Call(uintptr(hwnd), uintptr(GWL_STYLE)) + val, _, _ = _GetWindowLong.Call(uintptr(hwnd), index) } return } @@ -582,11 +582,11 @@ func ImmSetCandidateWindow(imc syscall.Handle, x, y int) { _ImmSetCandidateWindow.Call(uintptr(imc), uintptr(unsafe.Pointer(&f))) } -func SetWindowLong(hwnd syscall.Handle, idx uint32, style uintptr) { +func SetWindowLong(hwnd syscall.Handle, idx uintptr, style uintptr) { if runtime.GOARCH == "386" { - _SetWindowLong32.Call(uintptr(hwnd), uintptr(idx), style) + _SetWindowLong32.Call(uintptr(hwnd), idx, style) } else { - _SetWindowLong.Call(uintptr(hwnd), uintptr(idx), style) + _SetWindowLong.Call(uintptr(hwnd), idx, style) } } diff --git a/app/os_windows.go b/app/os_windows.go index 2563a9b8..c09413b9 100644 --- a/app/os_windows.go +++ b/app/os_windows.go @@ -198,7 +198,7 @@ func (w *window) update() { // Check the window mode. mode := w.config.Mode p := windows.GetWindowPlacement(w.hwnd) - style := windows.GetWindowLong(w.hwnd) + style := windows.GetWindowLong(w.hwnd, windows.GWL_STYLE) if style&windows.WS_OVERLAPPEDWINDOW == 0 { mode = Fullscreen mi := windows.GetMonitorInfo(w.hwnd).Monitor @@ -603,7 +603,7 @@ func (w *window) Configure(options []Option) { case Maximized: // Set window style. - style := windows.GetWindowLong(w.hwnd) & (^uintptr(windows.WS_MAXIMIZE)) + style := windows.GetWindowLong(w.hwnd, windows.GWL_STYLE) & (^uintptr(windows.WS_MAXIMIZE)) windows.SetWindowLong(w.hwnd, windows.GWL_STYLE, style|windows.WS_OVERLAPPEDWINDOW) mi := windows.GetMonitorInfo(w.hwnd).Monitor w.config.Size = image.Point{X: int(mi.Right - mi.Left), Y: int(mi.Bottom - mi.Top)} @@ -612,7 +612,7 @@ func (w *window) Configure(options []Option) { case Windowed: windows.SetWindowText(w.hwnd, w.config.Title) // Set window style. - style := windows.GetWindowLong(w.hwnd) & (^uintptr(windows.WS_MAXIMIZE)) + style := windows.GetWindowLong(w.hwnd, windows.GWL_STYLE) & (^uintptr(windows.WS_MAXIMIZE)) windows.SetWindowLong(w.hwnd, windows.GWL_STYLE, style|windows.WS_OVERLAPPEDWINDOW) // Get target for client areaa size. width := int32(w.config.Size.X) @@ -645,7 +645,7 @@ func (w *window) Configure(options []Option) { windows.ShowWindow(w.hwnd, windows.SW_SHOWNORMAL) case Fullscreen: - style := windows.GetWindowLong(w.hwnd) + style := windows.GetWindowLong(w.hwnd, windows.GWL_STYLE) windows.SetWindowLong(w.hwnd, windows.GWL_STYLE, style&^windows.WS_OVERLAPPEDWINDOW) mi := windows.GetMonitorInfo(w.hwnd) w.config.Size = image.Point{X: int(mi.Monitor.Right - mi.Monitor.Left), Y: int(mi.Monitor.Bottom - mi.Monitor.Top)}