Update X11 UI backend to handle focus and window motion events (untested)

slava 2006-05-29 00:23:54 +00:00
parent 289f63e655
commit c35a4b63b9
4 changed files with 25 additions and 9 deletions

View File

@ -10,8 +10,7 @@
- code walker & exceptions -- test and debug problems
- another i/o bug: on factorcode eventually all i/o times out
- x11 title bars are funny
- save window positions on x11
- do top-level window focus on x11
- quit fep
- if the listener is running a command when the image is saved, it
restores to an unresponsive gadget
- track: don't allow negative dimensions

View File

@ -6,7 +6,7 @@ namespaces prettyprint sequences strings threads ;
GENERIC: expose-event ( event window -- )
GENERIC: resize-event ( event window -- )
GENERIC: configure-event ( event window -- )
GENERIC: button-down-event ( event window -- )
@ -20,6 +20,10 @@ GENERIC: key-down-event ( event window -- )
GENERIC: key-up-event ( event window -- )
GENERIC: focus-in-event ( event window -- )
GENERIC: focus-out-event ( event window -- )
GENERIC: client-event ( event window -- )
: next-event ( -- event )
@ -45,12 +49,14 @@ GENERIC: client-event ( event window -- )
: handle-event ( event window -- )
over XAnyEvent-type {
{ [ dup Expose = ] [ drop expose-event ] }
{ [ dup ConfigureNotify = ] [ drop resize-event ] }
{ [ dup ConfigureNotify = ] [ drop configure-event ] }
{ [ dup ButtonPress = ] [ drop button-down-event$ ] }
{ [ dup ButtonRelease = ] [ drop button-up-event$ ] }
{ [ dup MotionNotify = ] [ drop motion-event ] }
{ [ dup KeyPress = ] [ drop key-down-event ] }
{ [ dup KeyRelease = ] [ drop key-up-event ] }
{ [ dup FocusIn = ] [ drop focus-in-event ] }
{ [ dup FocusOut = ] [ drop focus-out-event ] }
{ [ dup ClientMessage = ] [ drop client-event ] }
{ [ t ] [ 3drop ] }
} cond ;

View File

@ -12,11 +12,17 @@ strings x11 ;
M: world expose-event ( event world -- ) nip relayout ;
M: world resize-event ( event world -- )
>r
: configured-loc ( event -- dim )
dup XConfigureEvent-x swap XConfigureEvent-y
0 3array ;
: configured-dim ( event -- dim )
dup XConfigureEvent-width swap XConfigureEvent-height 0
3array
r> set-gadget-dim ;
3array ;
M: world configure-event ( event world -- )
over configured-loc over set-world-loc
swap configured-dim swap set-gadget-dim ;
: button&loc ( event -- button# loc )
dup XButtonEvent-button
@ -94,6 +100,10 @@ M: world key-up-event ( event world -- )
2drop
] if* ;
M: world focus-in-event ( event world -- ) nip focus-world ;
M: world focus-out-event ( event world -- ) nip unfocus-world ;
: close-box? ( event -- ? )
dup XClientMessageEvent-message_type "WM_PROTOCOLS" x-atom =
swap XClientMessageEvent-data "WM_DELETE_WINDOW" x-atom =

View File

@ -18,7 +18,8 @@ USING: alien gadgets hashtables kernel math namespaces sequences ;
KeyReleaseMask bitor
ButtonPressMask bitor
ButtonReleaseMask bitor
PointerMotionMask bitor ;
PointerMotionMask bitor
FocusChangeMask bitor ;
: window-attributes ( visinfo -- attributes )
"XSetWindowAttributes" <c-object>