From 48e76e5957c78082d09085ce436349df3e89d6b8 Mon Sep 17 00:00:00 2001 From: slava Date: Sat, 3 Jun 2006 05:53:34 +0000 Subject: [PATCH] Attempt to implement mouse enter/leave handling in X11 (untested) --- TODO.FACTOR.txt | 1 + library/ui/gestures.factor | 7 +++++++ library/ui/ui.factor | 9 +-------- library/ui/x11/events.factor | 6 ++++++ library/ui/x11/ui.factor | 4 ++++ 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 4925f4dde9..990dd28d8e 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -6,6 +6,7 @@ - x11 title bars are funny - x11 mouse enter/leave events: update rollover +- x11: when starting with restored windows, caret invisible + httpd: - outliners don't work - browser responder doesn't work diff --git a/library/ui/gestures.factor b/library/ui/gestures.factor index 6d5056d0fc..0caf7f001d 100644 --- a/library/ui/gestures.factor +++ b/library/ui/gestures.factor @@ -92,6 +92,13 @@ V{ } clone hand-buttons set-global fire-motion T{ mouse-enter } swap each-gesture ; +: forget-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 ; + : focus-gestures ( new old -- ) drop-prefix T{ lose-focus } swap each-gesture diff --git a/library/ui/ui.factor b/library/ui/ui.factor index 530bdf336c..f7753cdbad 100644 --- a/library/ui/ui.factor +++ b/library/ui/ui.factor @@ -83,18 +83,11 @@ 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 0 windows get set-length [ dup reset-world open-window* ] each - fix-rollover ; + forget-rollover ; : restore-windows? ( -- ? ) windows get [ empty? not ] [ f ] if* ; diff --git a/library/ui/x11/events.factor b/library/ui/x11/events.factor index 1acc8156d5..6d8ad58613 100644 --- a/library/ui/x11/events.factor +++ b/library/ui/x11/events.factor @@ -12,6 +12,10 @@ GENERIC: button-down-event ( event window -- ) GENERIC: button-up-event ( event window -- ) +GENERIC: enter-event ( event window -- ) + +GENERIC: leave-event ( event window -- ) + GENERIC: wheel-event ( event window -- ) GENERIC: motion-event ( event window -- ) @@ -52,6 +56,8 @@ GENERIC: client-event ( event window -- ) { [ dup ConfigureNotify = ] [ drop configure-event ] } { [ dup ButtonPress = ] [ drop button-down-event$ ] } { [ dup ButtonRelease = ] [ drop button-up-event$ ] } + { [ dup EnterNotify = ] [ drop enter-event ] } + { [ dup LeaveNotify = ] [ drop leave-event ] } { [ dup MotionNotify = ] [ drop motion-event ] } { [ dup KeyPress = ] [ drop key-down-event ] } { [ dup KeyRelease = ] [ drop key-up-event ] } diff --git a/library/ui/x11/ui.factor b/library/ui/x11/ui.factor index f3de955fd1..049ec5747c 100644 --- a/library/ui/x11/ui.factor +++ b/library/ui/x11/ui.factor @@ -37,6 +37,10 @@ M: world button-up-event ( event world -- ) M: world wheel-event ( event world -- ) >r button&loc >r 4 = r> r> send-wheel ; +M: world enter-event ( event world -- ) motion-event ; + +M: world leave-event ( event world -- ) 2drop forget-rollover ; + M: world motion-event ( event world -- ) >r dup XMotionEvent-x swap XMotionEvent-y 0 3array r> move-hand ;