mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
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 <mail@eliasnaur.com>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -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)}
|
||||
|
||||
Reference in New Issue
Block a user