mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
app: [Windows] support TopMost option
Use HWND_TOPMOST and HWND_NOTOPMOST when applying Config.TopMost on Windows. Leave SWP_NOZORDER set when TopMost hasn't changed, so other Configure calls don't reorder the window. Signed-off-by: qiannian <qianniancn@gmail.com>
This commit is contained in:
@@ -209,6 +209,7 @@ const (
|
||||
|
||||
HWND_TOP = syscall.Handle(0)
|
||||
HWND_TOPMOST = ^(syscall.Handle(1) - 1) // -1
|
||||
HWND_NOTOPMOST = ^(syscall.Handle(2) - 1) // -2
|
||||
|
||||
HTCAPTION = 2
|
||||
HTCLIENT = 1
|
||||
|
||||
+11
-2
@@ -747,7 +747,16 @@ func (w *window) Configure(options []Option) {
|
||||
style := windows.GetWindowLong(w.hwnd, windows.GWL_STYLE)
|
||||
var showMode int32
|
||||
var x, y, width, height int32
|
||||
swpStyle := uintptr(windows.SWP_NOZORDER | windows.SWP_FRAMECHANGED)
|
||||
swpStyle := uintptr(windows.SWP_FRAMECHANGED)
|
||||
if cnf.TopMost == w.config.TopMost {
|
||||
// Don't change the z-order if TopMost didn't change.
|
||||
swpStyle |= windows.SWP_NOZORDER
|
||||
}
|
||||
hwndAfter := windows.HWND_NOTOPMOST
|
||||
if cnf.TopMost {
|
||||
hwndAfter = windows.HWND_TOPMOST
|
||||
}
|
||||
w.config.TopMost = cnf.TopMost
|
||||
winStyle := uintptr(windows.WS_OVERLAPPEDWINDOW)
|
||||
style &^= winStyle
|
||||
switch cnf.Mode {
|
||||
@@ -799,7 +808,7 @@ func (w *window) Configure(options []Option) {
|
||||
|
||||
// Note: these invocation all trigger the windows callback method which may process a pending system.ActionCenter
|
||||
// action, so SetWindowPos should come first so as to not "overwrite" system.ActionCenter.
|
||||
windows.SetWindowPos(w.hwnd, 0, x, y, width, height, swpStyle)
|
||||
windows.SetWindowPos(w.hwnd, hwndAfter, x, y, width, height, swpStyle)
|
||||
windows.SetWindowLong(w.hwnd, windows.GWL_STYLE, style)
|
||||
windows.ShowWindow(w.hwnd, showMode)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user