fix focus for windows within a floating frame
Make the `focus` method shift focus to a floating frame. Also, shift focus away from the floating frame when `focus` is used in an window within the current main frame.
This commit is contained in:
parent
9fdc917295
commit
30c8202656
|
@ -65,7 +65,9 @@ If @racket[enable?] is true, the window is enabled, otherwise it is
|
|||
@index['("keyboard focus" "setting")]{Moves} the keyboard focus to the
|
||||
window, relative to its top-level window, if the window ever accepts
|
||||
the keyboard focus. If the focus is in the window's top-level
|
||||
window, then the focus is immediately moved to this
|
||||
window or if the window's top-level window is visible and floating
|
||||
(i.e., created with the @racket['float] style), then the focus is
|
||||
immediately moved to this
|
||||
window. Otherwise, the focus is not immediately moved, but when the
|
||||
window's top-level window gets the keyboard focus, the focus is
|
||||
delegated to this window.
|
||||
|
|
|
@ -761,7 +761,16 @@
|
|||
(is-enabled-to-root?))
|
||||
(let ([w (tell cocoa window)])
|
||||
(when w
|
||||
(tellv w makeFirstResponder: (get-cocoa-focus))))))
|
||||
(tellv w makeFirstResponder: (get-cocoa-focus))
|
||||
;; Within a floating frame or when potentially taking
|
||||
;; focus from a floating frame, also make the frame the
|
||||
;; key window:
|
||||
(let ([top (get-wx-window)])
|
||||
(when (and (or (send top floating?)
|
||||
(tell #:type _BOOL w isMainWindow))
|
||||
(tell #:type _bool w isVisible))
|
||||
(tellv w makeKeyAndOrderFront: #f)))))))
|
||||
|
||||
(define/public (on-set-focus) (void))
|
||||
(define/public (on-kill-focus) (void))
|
||||
|
||||
|
|
|
@ -706,7 +706,15 @@
|
|||
(send parent in-floating?))
|
||||
|
||||
(define/public (set-focus)
|
||||
(gtk_widget_grab_focus (get-client-gtk)))
|
||||
(define gtk (get-client-gtk))
|
||||
(gtk_widget_grab_focus gtk)
|
||||
;; Force focus to or away from a floating window:
|
||||
(cond
|
||||
[(and (in-floating?)
|
||||
(is-shown-to-root?))
|
||||
(gdk_keyboard_grab (widget-window gtk) #t 0)]
|
||||
[else
|
||||
(gdk_keyboard_ungrab 0)]))
|
||||
|
||||
(define cursor-handle #f)
|
||||
(define/public (set-cursor v)
|
||||
|
|
|
@ -428,9 +428,18 @@
|
|||
(set! focus-window-path #f)))
|
||||
(define/override (set-top-focus win win-path child-hwnd)
|
||||
(set! focus-window-path (cons this win-path))
|
||||
(when (ptr-equal? hwnd (GetActiveWindow))
|
||||
(define active-hwnd (GetActiveWindow))
|
||||
(when (or (ptr-equal? hwnd active-hwnd)
|
||||
(and (or float-without-caption?
|
||||
(let ([wx (any-hwnd->wx active-hwnd)])
|
||||
(and wx
|
||||
(send wx is-floating?))))
|
||||
(is-shown?)))
|
||||
(void (SetFocus child-hwnd))))
|
||||
|
||||
(define/public (is-floating?)
|
||||
float-without-caption?)
|
||||
|
||||
(define/private (set-frame-focus)
|
||||
(let ([p focus-window-path])
|
||||
(when (pair? p)
|
||||
|
|
Loading…
Reference in New Issue
Block a user