mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
app: [Windows] make custom decorated windows behave like regular windows
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -245,6 +245,7 @@ const (
|
|||||||
WM_MOUSEHWHEEL = 0x020E
|
WM_MOUSEHWHEEL = 0x020E
|
||||||
WM_NCACTIVATE = 0x0086
|
WM_NCACTIVATE = 0x0086
|
||||||
WM_NCHITTEST = 0x0084
|
WM_NCHITTEST = 0x0084
|
||||||
|
WM_NCCALCSIZE = 0x0083
|
||||||
WM_PAINT = 0x000F
|
WM_PAINT = 0x000F
|
||||||
WM_QUIT = 0x0012
|
WM_QUIT = 0x0012
|
||||||
WM_SETCURSOR = 0x0020
|
WM_SETCURSOR = 0x0020
|
||||||
|
|||||||
+10
-5
@@ -325,6 +325,11 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
|
|||||||
// The system destroys the HWND for us.
|
// The system destroys the HWND for us.
|
||||||
w.hwnd = 0
|
w.hwnd = 0
|
||||||
windows.PostQuitMessage(0)
|
windows.PostQuitMessage(0)
|
||||||
|
case windows.WM_NCCALCSIZE:
|
||||||
|
if !w.config.Decorated {
|
||||||
|
// No client areas; we draw decorations ourselves.
|
||||||
|
return 0
|
||||||
|
}
|
||||||
case windows.WM_PAINT:
|
case windows.WM_PAINT:
|
||||||
w.draw(true)
|
w.draw(true)
|
||||||
case windows.WM_SIZE:
|
case windows.WM_SIZE:
|
||||||
@@ -669,9 +674,6 @@ func (w *window) Configure(options []Option) {
|
|||||||
swpStyle := uintptr(windows.SWP_NOZORDER | windows.SWP_FRAMECHANGED)
|
swpStyle := uintptr(windows.SWP_NOZORDER | windows.SWP_FRAMECHANGED)
|
||||||
winStyle := uintptr(windows.WS_OVERLAPPEDWINDOW)
|
winStyle := uintptr(windows.WS_OVERLAPPEDWINDOW)
|
||||||
style &^= winStyle
|
style &^= winStyle
|
||||||
if !w.config.Decorated {
|
|
||||||
winStyle = 0
|
|
||||||
}
|
|
||||||
switch w.config.Mode {
|
switch w.config.Mode {
|
||||||
case Minimized:
|
case Minimized:
|
||||||
style |= winStyle
|
style |= winStyle
|
||||||
@@ -695,9 +697,12 @@ func (w *window) Configure(options []Option) {
|
|||||||
// Set desired window size.
|
// Set desired window size.
|
||||||
wr.Right = wr.Left + width
|
wr.Right = wr.Left + width
|
||||||
wr.Bottom = wr.Top + height
|
wr.Bottom = wr.Top + height
|
||||||
// Convert from client size to window size.
|
// Compute client size and position. Note that the client size is
|
||||||
|
// equal to the window size when we are in control of decorations.
|
||||||
r := wr
|
r := wr
|
||||||
windows.AdjustWindowRectEx(&r, uint32(style), 0, dwExStyle)
|
if w.config.Decorated {
|
||||||
|
windows.AdjustWindowRectEx(&r, uint32(style), 0, dwExStyle)
|
||||||
|
}
|
||||||
// Calculate difference between client and full window sizes.
|
// Calculate difference between client and full window sizes.
|
||||||
w.deltas.width = r.Right - wr.Right + wr.Left - r.Left
|
w.deltas.width = r.Right - wr.Right + wr.Left - r.Left
|
||||||
w.deltas.height = r.Bottom - wr.Bottom + wr.Top - r.Top
|
w.deltas.height = r.Bottom - wr.Bottom + wr.Top - r.Top
|
||||||
|
|||||||
Reference in New Issue
Block a user