app: [windows] recover focus on click

Previously, Gio doesn't reclaim the focus when they lose that to a
parent window. In such a case, the child window can steal
keyboard focus, and Gio will never recover it.

Now, Gio will recover the focus when clicked.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
This commit is contained in:
Inkeliz
2022-07-25 13:40:56 +01:00
committed by Elias Naur
parent 26e71011f5
commit fc5689ea44
+7
View File
@@ -53,6 +53,7 @@ type window struct {
placement *windows.WindowPlacement
animating bool
focused bool
deltas winDeltas
borderSize image.Point
@@ -277,8 +278,10 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
Type: pointer.Cancel,
})
case windows.WM_SETFOCUS:
w.focused = true
w.w.Event(key.FocusEvent{Focus: true})
case windows.WM_KILLFOCUS:
w.focused = false
w.w.Event(key.FocusEvent{Focus: false})
case windows.WM_NCHITTEST:
if w.config.Decorated {
@@ -470,6 +473,10 @@ func (w *window) hitTest(x, y int) uintptr {
}
func (w *window) pointerButton(btn pointer.Buttons, press bool, lParam uintptr, kmods key.Modifiers) {
if !w.focused {
windows.SetFocus(w.hwnd)
}
var typ pointer.Type
if press {
typ = pointer.Press