NAME

X11::Xlib::XEvent - Polymorphic class for XEvent structures

DESCRiPTION

This object wraps an XEvent. XEvent is a union of many different C structs, though they all share a few common fields. The storage space of an XEvent is constant regardless of type, and so this class is backed by a simple scalar ref.

The active struct of the union is determined by the "type" field. This object heirarchy attempts to help you make correct usage of the union with respect to the current type, so as you change the value of type the object will automatically re-bless itself into the appropriate subclass, giving you access to new struct fields.

Most of the "magic" occurs from Perl code, not XS, so it is possible to define new event types if this module lacks any in your local copy of Xlib. You can also access the "bytes" directly any time you want. And, you don't even have to use this object at all; any scalar or scalarref of the correct length can be passed to the X11::Xlib methods that expect an XEvent pointer.

METHODS

new

my $xevent= X11::Xlib::XEvent->new();
my $xevent= X11::Xlib::XEvent->new( %fields );
my $xevent= X11::Xlib::XEvent->new( \%fields );

You can construct XEvent as an empty buffer, or initialize it with a hash or hashref of fields. Initialization is performed via "pack". Un-set fields are initialized to zero, and the "bytes" is always padded to the length of an XEvent.

bytes

Direct access to the bytes of the XEvent.

apply

$xevent->apply( %fields );

Alias for pack( \%fields, 1, 1 )

pack

$xevent->pack( \%fields, $consume, $warn );

Assign a set of fields to the packed struct, optionally removing them from the hashref ($consume) and warning about un-known names ($warn). If you supply a new value for "type", the XEvent will get re-blessed to the appropriate type and all union-specific fields will be zeroed before applying the rest of the supplied fields.

unpack

my $field_hashref= $xevent->unpack;

Unpack the fields of an XEvent into a hashref. The Display field gets inflated to an X11::Xlib object.

COMMON ATTRIBUTES

All XEvent subclasses have the following attributes:

type

This is the key attribute that determines all the rest. Setting this value will re-bless the object to the relevant sub-class. If the type is unknown, it becomes X11::Xlib::XEvent.

display

The handle to the X11 connection that this message came from.

serial

The X11 serial number

window

The Window XID the message is associated with, or 0.

send_event

Boolean indicating whether the event was sent with XSendEvent

SUBCLASS ATTRIBUTES

For detailed information about these structures, consult the official documentation

XButtonEvent

Used for event type: ButtonPress, ButtonRelease

button            - unsigned int
root              - Window
same_screen       - Bool
state             - unsigned int
subwindow         - Window
time              - Time
x                 - int
x_root            - int
y                 - int
y_root            - int

XCirculateEvent

Used for event type: CirculateNotify

event             - Window
place             - int

XCirculateRequestEvent

Used for event type: CirculateRequest

parent            - Window
place             - int

XClientMessageEvent

Used for event type: ClientMessage

b                 - char [ 20 ]
l                 - long [ 5 ]
s                 - short [ 10 ]
format            - int
message_type      - Atom

XColormapEvent

Used for event type: ColormapNotify

colormap          - Colormap
new               - Bool
state             - int

XConfigureEvent

Used for event type: ConfigureNotify

above             - Window
border_width      - int
event             - Window
height            - int
override_redirect - Bool
width             - int
x                 - int
y                 - int

XConfigureRequestEvent

Used for event type: ConfigureRequest

above             - Window
border_width      - int
detail            - int
height            - int
parent            - Window
value_mask        - unsigned long
width             - int
x                 - int
y                 - int

XCreateWindowEvent

Used for event type: CreateNotify

border_width      - int
height            - int
override_redirect - Bool
parent            - Window
width             - int
x                 - int
y                 - int

XCrossingEvent

Used for event type: EnterNotify, LeaveNotify

detail            - int
focus             - Bool
mode              - int
root              - Window
same_screen       - Bool
state             - unsigned int
subwindow         - Window
time              - Time
x                 - int
x_root            - int
y                 - int
y_root            - int

XDestroyWindowEvent

Used for event type: DestroyNotify

event             - Window

XExposeEvent

Used for event type: Expose

count             - int
height            - int
width             - int
x                 - int
y                 - int

XFocusChangeEvent

Used for event type: FocusIn, FocusOut

detail            - int
mode              - int

XGenericEvent

Used for event type: GenericEvent

evtype            - int
extension         - int

XGraphicsExposeEvent

Used for event type: GraphicsExpose

count             - int
drawable          - Drawable
height            - int
major_code        - int
minor_code        - int
width             - int
x                 - int
y                 - int

XGravityEvent

Used for event type: GravityNotify

event             - Window
x                 - int
y                 - int

XKeyEvent

Used for event type: KeyPress, KeyRelease

keycode           - unsigned int
root              - Window
same_screen       - Bool
state             - unsigned int
subwindow         - Window
time              - Time
x                 - int
x_root            - int
y                 - int
y_root            - int

XKeymapEvent

Used for event type: KeymapNotify

key_vector        - char [ 32 ]

XMapEvent

Used for event type: MapNotify

event             - Window
override_redirect - Bool

XMapRequestEvent

Used for event type: MapRequest

parent            - Window

XMappingEvent

Used for event type: MappingNotify

count             - int
first_keycode     - int
request           - int

XMotionEvent

Used for event type: MotionNotify

is_hint           - char
root              - Window
same_screen       - Bool
state             - unsigned int
subwindow         - Window
time              - Time
x                 - int
x_root            - int
y                 - int
y_root            - int

XNoExposeEvent

Used for event type: NoExpose

drawable          - Drawable
major_code        - int
minor_code        - int

XPropertyEvent

Used for event type: PropertyNotify

atom              - Atom
state             - int
time              - Time

XReparentEvent

Used for event type: ReparentNotify

event             - Window
override_redirect - Bool
parent            - Window
x                 - int
y                 - int

XResizeRequestEvent

Used for event type: ResizeRequest

height            - int
width             - int

XSelectionClearEvent

Used for event type: SelectionClear

selection         - Atom
time              - Time

XSelectionEvent

Used for event type: SelectionNotify

property          - Atom
requestor         - Window
selection         - Atom
target            - Atom
time              - Time

XSelectionRequestEvent

Used for event type: SelectionRequest

owner             - Window
property          - Atom
requestor         - Window
selection         - Atom
target            - Atom
time              - Time

XUnmapEvent

Used for event type: UnmapNotify

event             - Window
from_configure    - Bool

XVisibilityEvent

Used for event type: VisibilityNotify

state             - int

AUTHOR

Olivier Thauvin, <nanardon@nanardon.zarb.org>

Michael Conrad, <mike@nrdvana.net>

COPYRIGHT AND LICENSE

Copyright (C) 2009-2010 by Olivier Thauvin

Copyright (C) 2017 by Michael Conrad

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.