From 289f63e655ede89e328f86ea55aad320e52d7349 Mon Sep 17 00:00:00 2001 From: slava Date: Sun, 28 May 2006 23:12:33 +0000 Subject: [PATCH] Stacking order is now saved along with window contents --- TODO.FACTOR.txt | 1 - library/test/math/float.factor | 3 ++- library/ui/gestures.factor | 8 ------- library/ui/ui.factor | 38 +++++++++++++++++++++++++--------- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 1df92d8d81..ef116b08ff 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -12,7 +12,6 @@ - x11 title bars are funny - save window positions on x11 - do top-level window focus on x11 -- restore windows with the correct stacking order - if the listener is running a command when the image is saved, it restores to an unresponsive gadget - track: don't allow negative dimensions diff --git a/library/test/math/float.factor b/library/test/math/float.factor index bf90620a38..6c48f4ecec 100644 --- a/library/test/math/float.factor +++ b/library/test/math/float.factor @@ -49,9 +49,10 @@ USE: test [ -4.0 ] [ -4.0 floor ] unit-test [ -4.0 ] [ -4.0 ceiling ] unit-test -[ t ] [ 0.0/0.0 0.0/0.0 = ] unit-test [ t ] [ -0.0 -0.0 = ] unit-test [ f ] [ 0.0 -0.0 = ] unit-test [ t ] [ 0.0 zero? ] unit-test [ t ] [ -0.0 zero? ] unit-test + +[ t ] [ 0.0/0.0 0.0/0.0 = ] unit-test diff --git a/library/ui/gestures.factor b/library/ui/gestures.factor index b7c00bebfb..abeee90b3e 100644 --- a/library/ui/gestures.factor +++ b/library/ui/gestures.factor @@ -105,14 +105,6 @@ V{ } clone hand-buttons set-global : request-focus ( gadget -- ) dup focusable-child swap find-world request-focus* ; -: focus-world ( world -- ) - #! Sent when native window receives focus - focused-ancestors f focus-gestures ; - -: unfocus-world ( world -- ) - #! Sent when native window loses focus. - focused-ancestors f swap focus-gestures ; - : modifier ( mod modifiers -- seq ) [ second swap bitand 0 > ] subset-with [ first ] map f like ; diff --git a/library/ui/ui.factor b/library/ui/ui.factor index 6fb84ec0e9..cef40dc446 100644 --- a/library/ui/ui.factor +++ b/library/ui/ui.factor @@ -1,20 +1,28 @@ ! Copyright (C) 2006 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. IN: gadgets -USING: gadgets gadgets-labels gadgets-layouts gadgets-theme -gadgets-viewports hashtables kernel math namespaces queues -sequences threads ; +USING: arrays gadgets gadgets-labels gadgets-layouts +gadgets-theme gadgets-viewports hashtables kernel math +namespaces queues sequences threads ; -! Hash mapping aliens to gadgets +! Assoc mapping aliens to gadgets SYMBOL: windows -: reset-windows ( hash -- hash ) H{ } clone windows set-global ; +: reset-windows ( hash -- hash ) V{ } clone windows set-global ; -: window ( handle -- world ) windows get hash ; +: window ( handle -- world ) windows get-global assoc ; -: register-window ( world handle -- ) windows get set-hash ; +: register-window ( world handle -- ) + swap 2array windows get-global push ; -: unregister-window ( handle -- ) windows get remove-hash ; +: unregister-window ( handle -- ) + windows get-global + [ first = ] subset-with + windows set-global ; + +: raised-window ( world -- ) + windows get-global [ second eq? ] find-with drop + windows get-global [ length 1- ] keep exchange ; : layout-queued ( -- ) invalid dup queue-empty? [ @@ -68,11 +76,12 @@ C: titled-gadget ( gadget title -- ) open-window ; : restore-windows ( -- ) - windows get hash-values reset-windows + windows get [ second ] map + reset-windows [ dup reset-world open-window* ] each ; : restore-windows? ( -- ? ) - windows get [ hash-empty? not ] [ f ] if* ; + windows get [ empty? not ] [ f ] if* ; : (open-tool) ( arg cons setter -- ) >r call tuck r> call open-window ; inline @@ -97,6 +106,15 @@ C: titled-gadget ( gadget title -- ) dup get-global find-world rot eq? [ f swap set-global ] [ drop ] if ; +: focus-world ( world -- ) + #! Sent when native window receives focus + dup raised-window + focused-ancestors f focus-gestures ; + +: unfocus-world ( world -- ) + #! Sent when native window loses focus. + focused-ancestors f swap focus-gestures ; + : close-world ( world -- ) dup hand-clicked close-global dup hand-gadget close-global