PreviousUpNext

15.3.800  src/lib/x-kit/xclient/src/wire/sendevent-to-wire.api

## sendevent-to-wire.api
#
# Encode X SendEvent values in wire
# (network bytestring) format.
#
# We mostly use this for end-to-end unit testing
# of widgets and applications.  Typically we set
# up a selfcheck_api which allows selfcheck code
# to observe internal widget/app state changes,
# and then use the calls in this file to have the
# X server simulate use mouseclicks, keypresses etc.
#
# NB: We do not send anything to the network here;
# we simply create a bytestring and return it to
# our caller.

# Compiled by:
#     src/lib/x-kit/xclient/xclient-internals.sublib


# This api is implemented in:
#
#     src/lib/x-kit/xclient/src/wire/sendevent-to-wire.pkg

stipulate
    package xt  =  xtypes;                      # xtypes                is from   src/lib/x-kit/xclient/src/wire/xtypes.pkg
    package w8v =  vector_of_one_byte_unts;                     # vector_of_one_byte_unts               is from   src/lib/std/src/vector-of-one-byte-unts.pkg
herein

    # Ask the X server to send event(s) to some window
    # via the SendEvent request. 
    #
    # In the following functions, the first three fields
    # specify the SendEvent record proper, the rest
    # specify the event being sent:

    api Sendevent_To_Wire {

        encode_send_selectionnotify_xevent
            :
            { send_event_to:            xt::Send_Event_To,
              propagate:                Bool,
              event_mask:               xt::Event_Mask,
              #
              property:                 Null_Or( xt::Atom ),
              requesting_window_id:     xt::Xid,
              selection:                xt::Atom,
              target:                   xt::Atom,
              timestamp:                xt::Timestamp
              
            }
            ->
            w8v::Vector
            ;


        encode_send_unmapnotify_xevent
            :
            { send_event_to:            xt::Send_Event_To,
              propagate:                Bool,
              event_mask:               xt::Event_Mask,
              #
              event_window_id:          xt::Xid,
              unmapped_window_id:       xt::Xid,
              from_configure:           Bool
            }
            ->
            w8v::Vector
            ;

        # See   p77  (81)   http://mythryl.org/pub/exene/X-protocol-R6.pdf
        #
        encode_send_keypress_xevent
            :
            { send_event_to:    xt::Send_Event_To,
              propagate:        Bool,
              event_mask:       xt::Event_Mask,
              #
              timestamp:        xt::Timestamp,
              root_window_id:   xt::Xid,
              event_window_id:  xt::Xid,                        # Window handling the keyboard-key press event.
              child_window_id:  Null_Or( xt::Xid ),             # Child of event window containing the keypress point. NULL if none such exists.
              root_x:           Int,                            # Mouse position on root window at time of keypress.
              root_y:           Int,
              event_x:          Int,                            # Mouse position on recipient window at time of keypress.
              event_y:          Int,
              keycode:          xt::Keycode,                    # Keyboard key just pressed.
              buttons:          xt::Mousebuttons_State          # Mouse button state BEFORE buttonclick. (Should contain keyboard modifier keys also. XXX BUGGO FIXME)
            }
            ->
            w8v::Vector
            ;

        # See   p77  (81)   http://mythryl.org/pub/exene/X-protocol-R6.pdf
        #
        encode_send_keyrelease_xevent
            :
            { send_event_to:    xt::Send_Event_To,
              propagate:        Bool,
              event_mask:       xt::Event_Mask,
              #
              timestamp:        xt::Timestamp,
              root_window_id:   xt::Xid,
              event_window_id:  xt::Xid,                        # Window handling the keyboard-key release event.
              child_window_id:  Null_Or( xt::Xid ),             # Child of event window containing the key release point. NULL if none such exists.
              root_x:           Int,                            # Mouse position on root window at time of key release.
              root_y:           Int,
              event_x:          Int,                            # Mouse position on recipient window at time of key release.
              event_y:          Int,
              keycode:          xt::Keycode,                    # Keyboard key just released.
              buttons:          xt::Mousebuttons_State          # Mouse button state BEFORE buttonclick. (Should contain keyboard modifier keys also. XXX BUGGO FIXME)
            }
            ->
            w8v::Vector
            ;

        # See   p77  (81)   http://mythryl.org/pub/exene/X-protocol-R6.pdf
        #
        encode_send_buttonpress_xevent
            :
            { send_event_to:    xt::Send_Event_To,
              propagate:        Bool,
              event_mask:       xt::Event_Mask,
              #
              timestamp:        xt::Timestamp,
              root_window_id:   xt::Xid,
              event_window_id:  xt::Xid,                        # Window handling the mouse-button click event.
              child_window_id:  Null_Or( xt::Xid ),             # Child of event window containing the click point. NULL if none such exists.
              root_x:           Int,                            # Mouse position on root window at time of button click.
              root_y:           Int,
              event_x:          Int,                            # Mouse position on recipient window at time of button click.
              event_y:          Int,
              button:           xt::Mousebutton,                # Mouse button just clicked down.
              buttons:          xt::Mousebuttons_State          # Mouse button state BEFORE buttonclick. (Should contain keyboard modifier keys also. XXX BUGGO FIXME)
            }
            ->
            w8v::Vector
            ;

        # See   p77  (81)   http://mythryl.org/pub/exene/X-protocol-R6.pdf
        #
        encode_send_buttonrelease_xevent
            :
            { send_event_to:    xt::Send_Event_To,
              propagate:        Bool,
              event_mask:       xt::Event_Mask,
              #
              timestamp:        xt::Timestamp,
              root_window_id:   xt::Xid,
              event_window_id:  xt::Xid,                        # Window handling the mouse-button release event.
              child_window_id:  Null_Or( xt::Xid ),             # Child of event window containing the release point. NULL if none such exists.
              root_x:           Int,                            # Mouse position on root window at time of button release.
              root_y:           Int,
              event_x:          Int,                            # Mouse position on recipient window at time of button click.
              event_y:          Int,
              button:           xt::Mousebutton,                # Mouse button just released.
              buttons:          xt::Mousebuttons_State          # Mouse button state BEFORE buttonrelease. (Should contain keyboard modifier keys also. XXX BUGGO FIXME)
            }
            ->
            w8v::Vector
            ;

        # See   p77  (81)   http://mythryl.org/pub/exene/X-protocol-R6.pdf
        #
        encode_send_motionnotify_xevent
            :
            { send_event_to:    xt::Send_Event_To,
              propagate:        Bool,
              event_mask:       xt::Event_Mask,
              #
              timestamp:        xt::Timestamp,
              root_window_id:   xt::Xid,
              event_window_id:  xt::Xid,                        # Window handling the mouse-button release event.
              child_window_id:  Null_Or( xt::Xid ),             # Child of event window containing the release point. NULL if none such exists.
              root_x:           Int,                            # Mouse position on root window.
              root_y:           Int,
              event_x:          Int,                            # Mouse position on recipient window.
              event_y:          Int,
              buttons:          xt::Mousebuttons_State          # Mouse button state. (Should contain keyboard modifier keys also. XXX BUGGO FIXME)
            }
            ->
            w8v::Vector
            ;

        # See  p78  (82)   http://mythryl.org/pub/exene/X-protocol-R6.pdf
        #
        encode_send_enternotify_xevent
            :
            { send_event_to:    xt::Send_Event_To,
              propagate:        Bool,
              event_mask:       xt::Event_Mask,
              #
              timestamp:        xt::Timestamp,
              root_window_id:   xt::Xid,
              event_window_id:  xt::Xid,                        # Window handling the mouse-button release event.
              child_window_id:  Null_Or( xt::Xid ),             # Child of event window containing the release point. NULL if none such exists.
              root_x:           Int,                            # Mouse position on root window at time of button release.
              root_y:           Int,
              event_x:          Int,                            # Mouse position on recipient window at end of entry event.
              event_y:          Int,
              buttons:          xt::Mousebuttons_State          # Mouse buttons state.
            }
            ->
            w8v::Vector
            ;

        # See  p78  (82)   http://mythryl.org/pub/exene/X-protocol-R6.pdf
        #
        encode_send_leavenotify_xevent
            :
            { send_event_to:    xt::Send_Event_To,
              propagate:        Bool,
              event_mask:       xt::Event_Mask,
              #
              timestamp:        xt::Timestamp,
              root_window_id:   xt::Xid,
              event_window_id:  xt::Xid,                        # Window handling the mouse-button release event.
              child_window_id:  Null_Or( xt::Xid ),             # Child of event window containing the release point. NULL if none such exists.
              root_x:           Int,                            # Mouse position on root window at time of button release.
              root_y:           Int,
              event_x:          Int,                            # Mouse position on recipient window at end of exit event.
              event_y:          Int,
              buttons:          xt::Mousebuttons_State          # Mouse buttons state.
            }
            ->
            w8v::Vector
            ;

    };          # package sendevent_to_wire
end;            # stipulate 


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext