## xevent-types.pkg
#
# Define the representation of X events
# used throughout x-kit. These get created in
#
#
src/lib/x-kit/xclient/src/wire/wire-to-value.pkg#
# and then routed through the widget mail system by
#
#
src/lib/x-kit/xclient/src/window/xsocket-to-hostwindow-router-old.pkg#
src/lib/x-kit/xclient/src/window/hostwindow-to-widget-router-old.pkg#
# and finally consumed by clients like
#
#
src/lib/x-kit/xclient/src/window/window-old.pkg#
# These may be printed using
#
#
src/lib/x-kit/xclient/src/to-string/xevent-to-string.pkg# Compiled by:
#
src/lib/x-kit/xclient/xclient-internals.sublibstipulate
package g2d = geometry2d; # geometry2d is from
src/lib/std/2d/geometry2d.pkg package ts = xserver_timestamp; # xserver_timestamp is from
src/lib/x-kit/xclient/src/wire/xserver-timestamp.pkg package xt = xtypes; # xtypes is from
src/lib/x-kit/xclient/src/wire/xtypes.pkgherein
package xevent_types {
stipulate
my (&) = unt::bitwise_and;
my (
|) = unt::bitwise_or;
my (<<) = unt::(<<);
infix my
| << & ;
herein
# X event names
#
package n {
Xevent_Name
#
= KEY_PRESS
| KEY_RELEASE
| BUTTON_PRESS
| BUTTON_RELEASE
| ENTER_WINDOW
| LEAVE_WINDOW
| POINTER_MOTION
| POINTER_MOTION_HINT
| BUTTON1MOTION
| BUTTON2MOTION
| BUTTON3MOTION
| BUTTON4MOTION
| BUTTON5MOTION
| BUTTON_MOTION
| KEYMAP_STATE
| EXPOSURE
| VISIBILITY_CHANGE
| STRUCTURE_NOTIFY
| RESIZE_REDIRECT
| SUBSTRUCTURE_NOTIFY
| SUBSTRUCTURE_REDIRECT
| FOCUS_CHANGE
| PROPERTY_CHANGE
| COLORMAP_CHANGE
| OWNER_GRAB_BUTTON
;
};
# The types of the information
# carried by some XEvents:
#
Key_Xevtinfo # KeyPress and KeyRelease
=
{ root_window_id: xt::Window_Id, # Root of the source window.
event_window_id: xt::Window_Id, # The window in which this was generated.
child_window_id: Null_Or( xt::Window_Id ), # The child of the event window that is the
# ancestor of the source window.
same_screen: Bool, #
root_point: g2d::Point, # Event coordinates in the root window.
event_point: g2d::Point, # Event coordinates in the event window.
keycode: xt::Keycode, # Keycode of the depressed key.
modifier_keys_state: xt::Modifier_Keys_State, # State of the modifier keys (shift, ctrl...).
mousebuttons_state: xt::Mousebuttons_State, # State of mouse buttons.
timestamp: ts::Xserver_Timestamp
};
Button_Xevtinfo # ButtonPress and ButtonRelease.
=
{
root_window_id: xt::Window_Id, # Root of the source window.
event_window_id: xt::Window_Id, # Window in which this was generated.
child_window_id: Null_Or( xt::Window_Id ), # The child of the event window that is the
# ancestor of the source window.
same_screen: Bool, #
root_point: g2d::Point, # Event coordinates in the root window.
event_point: g2d::Point, # Event coordinates in the event window.
mouse_button: xt::Mousebutton, # The button that was pressed.
modifier_keys_state: xt::Modifier_Keys_State, # State of the modifier keys (shift, ctrl...).
mousebuttons_state: xt::Mousebuttons_State, # State of mouse buttons.
timestamp: ts::Xserver_Timestamp
};
Motion_Xevtinfo
=
{
root_window_id: xt::Window_Id, # The root of the source window.
event_window_id: xt::Window_Id, # The window in which this was generated.
child_window_id: Null_Or(xt::Window_Id), # The child of the event window that is the
# ancestor of the source window
same_screen: Bool, #
root_point: g2d::Point, # Event coords in the root window.
event_point: g2d::Point, # Event coords in the event window.
hint: Bool, # TRUE if PointerMotionHint is selected.
modifier_keys_state: xt::Modifier_Keys_State,
mousebuttons_state: xt::Mousebuttons_State,
timestamp: ts::Xserver_Timestamp
};
Inout_Xevtinfo # EnterNotify and LeaveNotify
=
{
root_window_id: xt::Window_Id, # Root window for the pointer position.
event_window_id: xt::Window_Id, # Event window.
child_window_id: Null_Or( xt::Window_Id ), # Child of event containing the pointer.
same_screen: Bool, #
root_point: g2d::Point, # Final pointer position in root coordinates.
event_point: g2d::Point, # Final pointer position in event coordinates
mode: xt::Focus_Mode, #
detail: xt::Focus_Detail, #
modifier_keys_state: xt::Modifier_Keys_State,
mousebuttons_state: xt::Mousebuttons_State,
focus: Bool, # TRUE, if event is the focus
timestamp: ts::Xserver_Timestamp
};
Focus_Xevtinfo # FocusIn and FocusOut
=
{ event_window_id: xt::Window_Id, # The window that gained the focus
mode: xt::Focus_Mode,
detail: xt::Focus_Detail
};
# X event messages:
#
package x {
Graphics_Expose_Record
=
{ drawable: xt::Drawable_Id,
box: g2d::Box, # The obscured rectangle.
count: Int, # The number of additional GraphicsExpose events.
major_opcode: Unt, # The graphics operation code.
minor_opcode: Unt # Always 0 for core protocol.
};
Expose_Record
=
{ exposed_window_id: xt::Window_Id, # The exposed window.
boxes: List( g2d::Box ), # The exposed rectangle. The list is
# so that multiple events can be packed.
count: Int # Number of subsequent expose events.
};
Event
= KEY_PRESS Key_Xevtinfo
| KEY_RELEASE Key_Xevtinfo
| BUTTON_PRESS Button_Xevtinfo
| BUTTON_RELEASE Button_Xevtinfo
#
| MOTION_NOTIFY Motion_Xevtinfo
#
| ENTER_NOTIFY Inout_Xevtinfo
| LEAVE_NOTIFY Inout_Xevtinfo
#
| FOCUS_IN Focus_Xevtinfo
| FOCUS_OUT Focus_Xevtinfo
#
| KEYMAP_NOTIFY { }
| EXPOSE Expose_Record
| GRAPHICS_EXPOSE Graphics_Expose_Record
| NO_EXPOSE
{ drawable: xt::Drawable_Id,
major_opcode: Unt, # The graphics operation code.
minor_opcode: Unt # Always 0 for core protocol.
}
| VISIBILITY_NOTIFY
{ changed_window_id: xt::Window_Id, # The window with changed visibility state.
state: xt::Visibility # The new visibility state.
}
| CREATE_NOTIFY
{ parent_window_id: xt::Window_Id, # The created window's parent.
created_window_id: xt::Window_Id, # The created window.
box: g2d::Box, # The window's rectangle.
border_wid: Int, # The width of the border.
override_redirect: Bool #
}
| DESTROY_NOTIFY
{ event_window_id: xt::Window_Id, # The window on which this was generated.
destroyed_window_id: xt::Window_Id # The destroyed window.
}
| UNMAP_NOTIFY
{ event_window_id: xt::Window_Id, # The window on which this was generated.
unmapped_window_id: xt::Window_Id, # The window being unmapped.
from_config: Bool # TRUE if parent was resized.
}
| MAP_NOTIFY
{ event_window_id: xt::Window_Id, # The window on which this was generated.
mapped_window_id: xt::Window_Id, # The window being mapped.
override_redirect: Bool #
}
| MAP_REQUEST
{ parent_window_id: xt::Window_Id, # The parent.
mapped_window_id: xt::Window_Id # The mapped window.
}
| REPARENT_NOTIFY
{ event_window_id: xt::Window_Id, # The window on which this was generated.
parent_window_id: xt::Window_Id, # The new parent.
rerooted_window_id: xt::Window_Id, # The re-rooted window.
upperleft_corner: g2d::Point, # The upper-left corner.
override_redirect: Bool #
}
| CONFIGURE_NOTIFY
{ event_window_id: xt::Window_Id, # The window on which this was generated.
configured_window_id: xt::Window_Id, # The reconfigured window.
sibling_window_id: Null_Or(xt::Window_Id), # The sibling that window is above (if any).
box: g2d::Box, # The window's rectangle.
border_wid: Int, # The width of the border.
override_redirect: Bool #
}
| CONFIGURE_REQUEST
{ parent_window_id: xt::Window_Id, # The parent.
configure_window_id: xt::Window_Id, # The window to reconfigure.
sibling_window_id: Null_Or(xt::Window_Id), # The new sibling (if any).
x: Null_Or(Int), # The window's rectangle.
y: Null_Or(Int),
wide: Null_Or(Int),
high: Null_Or(Int),
border_wid: Null_Or(Int), # The width of the border.
stack_mode: Null_Or(xt::Stack_Mode) # The mode for stacking windows.
}
| GRAVITY_NOTIFY {
event_window_id: xt::Window_Id, # The window on which this was generated.
moved_window_id: xt::Window_Id, # The window being moved.
upperleft_corner: g2d::Point # Upper-left corner of window.
}
| RESIZE_REQUEST {
resize_window_id: xt::Window_Id, # The window to resize.
req_size: g2d::Size # The requested new size.
}
| CIRCULATE_NOTIFY {
event_window_id: xt::Window_Id, # The window on which this was generated.
circulated_window_id: xt::Window_Id, # The window being circulated.
parent_window_id: xt::Window_Id, # The parent.
place: xt::Stack_Pos # The new place.
}
| CIRCULATE_REQUEST {
parent_window_id: xt::Window_Id, # The parent.
circulate_window_id: xt::Window_Id, # The window to circulate.
place: xt::Stack_Pos # The place to circulate the window to.
}
| PROPERTY_NOTIFY {
changed_window_id: xt::Window_Id, # The window with the changed property.
atom: xt::Atom, # The affected property.
timestamp: ts::Xserver_Timestamp, # When the property was changed.
deleted: Bool # TRUE if the property was deleted.
}
| SELECTION_CLEAR {
owning_window_id: xt::Window_Id, # The current owner of the selection.
selection: xt::Atom, # The selection.
timestamp: ts::Xserver_Timestamp # The last-change time.
}
| SELECTION_REQUEST {
owning_window_id: xt::Window_Id, # The owner of the selection.
selection: xt::Atom, # The selection.
target: xt::Atom, # The requested type for the selection.
requesting_window_id: xt::Window_Id, # The requesting window.
property: Null_Or( xt::Atom ), # The property to store the selection in.
timestamp: xt::Timestamp #
}
| SELECTION_NOTIFY {
requesting_window_id: xt::Window_Id, # The requestor of the selection.
selection: xt::Atom, # The selection.
target: xt::Atom, # The requested type of the selection.
property: Null_Or( xt::Atom ), # The property to store the selection in.
timestamp: xt::Timestamp #
}
| COLORMAP_NOTIFY {
window_id: xt::Window_Id, # The affected window.
cmap: Null_Or( xt::Colormap_Id ), # The colormap.
new: Bool, # TRUE, if the colormap attribute is changed.
installed: Bool # TRUE, if the colormap is installed.
}
| CLIENT_MESSAGE {
window_id: xt::Window_Id, #
type: xt::Atom, # The type of the message.
value: xt::Raw_Data # The message value.
}
| MODIFIER_MAPPING_NOTIFY
# Really a MappingNotify event.
| KEYBOARD_MAPPING_NOTIFY
# Really a MappingNotify event.
{
first_keycode: xt::Keycode,
count: Int
}
| POINTER_MAPPING_NOTIFY
# Really a MappingNotify event.
;
};
fun mask_of_xevent n::KEY_PRESS => xt::EVENT_MASK (0u1 << 0u0);
mask_of_xevent n::KEY_RELEASE => xt::EVENT_MASK (0u1 << 0u1);
mask_of_xevent n::BUTTON_PRESS => xt::EVENT_MASK (0u1 << 0u2);
mask_of_xevent n::BUTTON_RELEASE => xt::EVENT_MASK (0u1 << 0u3);
mask_of_xevent n::ENTER_WINDOW => xt::EVENT_MASK (0u1 << 0u4);
mask_of_xevent n::LEAVE_WINDOW => xt::EVENT_MASK (0u1 << 0u5);
mask_of_xevent n::POINTER_MOTION => xt::EVENT_MASK (0u1 << 0u6);
mask_of_xevent n::POINTER_MOTION_HINT => xt::EVENT_MASK (0u1 << 0u7);
mask_of_xevent n::BUTTON1MOTION => xt::EVENT_MASK (0u1 << 0u8);
mask_of_xevent n::BUTTON2MOTION => xt::EVENT_MASK (0u1 << 0u9);
mask_of_xevent n::BUTTON3MOTION => xt::EVENT_MASK (0u1 << 0u10);
mask_of_xevent n::BUTTON4MOTION => xt::EVENT_MASK (0u1 << 0u11);
mask_of_xevent n::BUTTON5MOTION => xt::EVENT_MASK (0u1 << 0u12);
mask_of_xevent n::BUTTON_MOTION => xt::EVENT_MASK (0u1 << 0u13);
mask_of_xevent n::KEYMAP_STATE => xt::EVENT_MASK (0u1 << 0u14);
mask_of_xevent n::EXPOSURE => xt::EVENT_MASK (0u1 << 0u15);
mask_of_xevent n::VISIBILITY_CHANGE => xt::EVENT_MASK (0u1 << 0u16);
mask_of_xevent n::STRUCTURE_NOTIFY => xt::EVENT_MASK (0u1 << 0u17);
mask_of_xevent n::RESIZE_REDIRECT => xt::EVENT_MASK (0u1 << 0u18);
mask_of_xevent n::SUBSTRUCTURE_NOTIFY => xt::EVENT_MASK (0u1 << 0u19);
mask_of_xevent n::SUBSTRUCTURE_REDIRECT => xt::EVENT_MASK (0u1 << 0u20);
mask_of_xevent n::FOCUS_CHANGE => xt::EVENT_MASK (0u1 << 0u21);
mask_of_xevent n::PROPERTY_CHANGE => xt::EVENT_MASK (0u1 << 0u22);
mask_of_xevent n::COLORMAP_CHANGE => xt::EVENT_MASK (0u1 << 0u23);
mask_of_xevent n::OWNER_GRAB_BUTTON => xt::EVENT_MASK (0u1 << 0u24);
end;
fun mask_of_xevent_list l
=
f (l, 0u0)
where
fun f ([], m)
=>
xt::EVENT_MASK m;
f (xevent ! r, m)
=>
{ my (xt::EVENT_MASK m')
=
mask_of_xevent xevent;
f (r, m
| m');
};
end;
end;
fun union_xevent_masks (xt::EVENT_MASK m1, xt::EVENT_MASK m2) = xt::EVENT_MASK (m1
| m2);
fun inter_xevent_masks (xt::EVENT_MASK m1, xt::EVENT_MASK m2) = xt::EVENT_MASK (m1 & m2);
end; # stipulate
}; # package xevent_types
end;