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