diff --git a/library/collections/namespaces.factor b/library/collections/namespaces.factor index 82445c2c1d..b8f7d8095f 100644 --- a/library/collections/namespaces.factor +++ b/library/collections/namespaces.factor @@ -57,6 +57,8 @@ SYMBOL: building : # ( n -- ) number>string % ; +: init-namespaces ( -- ) global 1array >vector set-namestack ; + IN: sequences : prune ( seq -- seq ) @@ -69,7 +71,3 @@ IN: sequences : join ( seq glue -- seq ) [ swap [ % ] [ dup % ] interleave drop ] over make ; flushable - -IN: kernel-internals - -: init-namespaces ( -- ) global 1array >vector set-namestack ; diff --git a/library/ui/cocoa/ui.factor b/library/ui/cocoa/ui.factor index c3aaca5857..931ff348ad 100644 --- a/library/ui/cocoa/ui.factor +++ b/library/ui/cocoa/ui.factor @@ -22,9 +22,8 @@ namespaces objc sequences errors freetype ; : install-app-delegate ( -- ) NSApp FactorApplicationDelegate install-delegate ; -: init-cocoa-ui ( -- ) +: init-cocoa ( -- ) reset-callbacks - init-ui install-app-delegate register-services default-main-menu ; @@ -68,11 +67,12 @@ IN: shells ] unless [ [ - init-cocoa-ui + init-timers + init-cocoa restore-windows? [ restore-windows ] [ - reset-windows + init-ui listener-window ] if finish-launching diff --git a/library/ui/timers.factor b/library/ui/timers.factor index 872061369c..6e0819feac 100644 --- a/library/ui/timers.factor +++ b/library/ui/timers.factor @@ -16,6 +16,8 @@ GENERIC: tick ( ms object -- ) : timers \ timers get-global ; +: init-timers ( -- ) H{ } clone \ timers set-global ; + : add-timer ( object delay -- ) over >r r> timers set-hash ; diff --git a/library/ui/tools/listener.factor b/library/ui/tools/listener.factor index b8152e9de2..897da14c47 100644 --- a/library/ui/tools/listener.factor +++ b/library/ui/tools/listener.factor @@ -44,7 +44,8 @@ TUPLE: listener-gadget scroller stack ; : ( -- gadget ) dup highlight-theme ; : start-listener ( listener -- ) - [ >r clear r> listener-thread ] in-thread drop ; + [ >r clear r> init-namespaces listener-thread ] in-thread + drop ; C: listener-gadget ( -- gadget ) { diff --git a/library/ui/ui.factor b/library/ui/ui.factor index 28115cf661..530bdf336c 100644 --- a/library/ui/ui.factor +++ b/library/ui/ui.factor @@ -8,8 +8,6 @@ sequences threads ; ! Assoc mapping aliens to gadgets SYMBOL: windows -: reset-windows ( hash -- hash ) V{ } clone windows set-global ; - : window ( handle -- world ) windows get-global assoc ; : register-window ( world handle -- ) @@ -41,9 +39,9 @@ SYMBOL: windows ] if ; : init-ui ( -- ) - H{ } clone \ timers set-global - \ invalid set-global ; - + \ invalid set-global + V{ } clone windows set-global ; + : ui-step ( -- ) do-timers [ layout-queued ] make-hash hash-values [ @@ -85,10 +83,18 @@ C: titled-gadget ( gadget title -- ) : open-titled-window ( gadget title -- ) open-window ; +: fix-rollover ( -- ) + #! After we restore the UI, send mouse leave events to all + #! gadgets that were under the mouse at the time of the + #! save, since the mouse is in a different location now. + f hand-gadget [ get-global ] 2keep set-global + parents hand-gestures ; + : restore-windows ( -- ) windows get [ second ] map - reset-windows - [ dup reset-world open-window* ] each ; + 0 windows get set-length + [ dup reset-world open-window* ] each + fix-rollover ; : restore-windows? ( -- ? ) windows get [ empty? not ] [ f ] if* ; diff --git a/library/ui/x11/ui.factor b/library/ui/x11/ui.factor index b188911063..f3de955fd1 100644 --- a/library/ui/x11/ui.factor +++ b/library/ui/x11/ui.factor @@ -145,11 +145,11 @@ IN: shells : ui ( -- ) [ f [ - init-ui + init-timers restore-windows? [ restore-windows ] [ - reset-windows + init-ui launchpad-window listener-window ] if diff --git a/library/windows/ui.factor b/library/windows/ui.factor index bf0b55ab81..3a373ab8cb 100644 --- a/library/windows/ui.factor +++ b/library/windows/ui.factor @@ -239,6 +239,7 @@ SYMBOL: hWnd "MSG" msg-obj set class-name ui-wndproc register-wndclassex win32-error=0 H{ } clone windows set + init-timers init-ui ; : cleanup-win32-ui ( -- ) class-name f UnregisterClass drop ;