Package: gdk

GBoxed gdk:event

Declaration

(define-gboxed-variant-cstruct event "GdkEvent"
  (type event-type)
  (window (g:object window))
  (send-event (:boolean :int8))
  (:variant type
            ;; GdkEventKey
            ((:key-press :key-release) event-key
             (time :uint32)
             (state modifier-type)
             (keyval :uint)
             (length :int)
             (string (:string :free-from-foreign nil
                              :free-to-foreign nil))
             (hardware-keycode :uint16)
             (group :uint8)
             (is-modifier :uint))
            ;; GdkEventButton
            ((:button-press
              :2button-press
              :double-button-press
              :3button-press
              :triple-button-press
              :button-release) event-button
             (time :uint32)
             (x :double)
             (y :double)
             (axes (fixed-array :double 2))
             (state modifier-type)
             (button :uint)
             (device (g:object device))
             (x-root :double)
             (y-root :double))
            ;; GdkEventTouch
            ((:touch-begin
              :touch-update
              :touch-end
              :touch-cancel) event-touch
             (time :uint32)
             (x :double)
             (y :double)
             (axes (fixed-array :double 2))
             (state modifier-type)
             (sequence (g:boxed event-sequence))
             (emulating-pointer :boolean)
             (device (g:object device))
             (x-root :double)
             (y-root :double))
            ;; GdkEventScroll
            ((:scroll) event-scroll
             (time :uint32)
             (x :double)
             (y :double)
             (state modifier-type)
             (direction scroll-direction)
             (device (g:object device))
             (x-root :double)
             (y-root :double)
             (delta-x :double)
             (delta-y :double))
            ;; GdkEventMotion
            ((:motion-notify) event-motion
             (time :uint32)
             (x :double)
             (y :double)
             (axes (fixed-array :double 2))
             (state modifier-type)
             (is-hint :int16)
             (device (g:object device))
             (x-root :double)
             (y-root :double))
            ;; GdkEventExpose
            ((:expose) event-expose
             (area rectangle :inline t)
             (region (:pointer (:struct cairo:region-t)))
             (count :int))
            ;; GdkEventVisibity
            ((:visibility-notify) event-visibility
             (state visibility-state))
            ;; GdkEventCrossing
            ((:enter-notify :leave-notify) event-crossing
             (subwindow (g:object window))
             (time :uint32)
             (x :double)
             (y :double)
             (x-root :double)
             (y-root :double)
             (mode crossing-mode)
             (detail notify-type)
             (focus :boolean)
             (state modifier-type))
            ;; GdkEventFocus
            ((:focus-change) event-focus
             (in :int16))
            ;; GdkEventConfigure
            ((:configure) event-configure
             (x :int)
             (y :int)
             (width :int)
             (height :int))
            ;; GdkEventProperty
            ((:property-notify) event-property
             (atom :pointer)
             (time :uint32)
             (state property-state))
            ;; GdkEventSelection
            ((:selection-clear
              :selection-notify
              :selection-request) event-selection
             (selection :pointer)
             (target :pointer)
             (property :pointer)
             (time :uint32)
             (requestor (g:object window)))
            ;; GdkEventDND
            ((:drag-enter
              :drag-leave
              :drag-motion
              :drag-status
              :drop-start
              :drop-finished) event-dnd
             (context (g:object drag-context))
             (time :uint32)
             (x-root :short)
             (y-root :short))
            ;; GdkEventProximity
            ((:proximity-in
              :proximity-out) event-proximity
             (time :uint32)
             (device (g:object device)))
            ;; GdkEventWindowState
            ((:window-state) event-window-state
             (changed-mask window-state)
             (new-window-state window-state))
            ;; GdkEventSetting
            ((:setting) event-setting
             (action setting-action)
             (name (:string :free-from-foreign nil :free-to-foreign nil)))
            ;; GdkEventOwnerChange
            ((:owner-change) event-owner-change
             (owner (g:object window))
             (reason owner-change)
             (selection :pointer)
             (time :uint32)
             (selection-time :uint32))
            ;; GdkEventGrabBroken
            ((:grab-broken) event-grab-broken
             (keyboard :boolean)
             (implicit :boolean)
             (grab-window (g:object window)))
            ;; GdkEventTouchpadSwipe
            ((:touchpad-swipe) event-touchpad-swipe
             (phase :int8)
             (n-fingers :int8)
             (time :uint32)
             (x :double)
             (y :double)
             (dx :double)
             (dy :double)
             (x-root :double)
             (y-root :double)
             (state modifier-type))
            ;; GdkEventTouchpadPinch
            ((:touchpad-pinch) event-touchpad-pinch
             (phase :int8)
             (n-fingers :int8)
             (time :uint32)
             (x :double)
             (y :double)
             (dx :double)
             (dy :double)
             (angle-delta :double)
             (scale :double)
             (x-root :double)
             (y-root :double)
             (state modifier-type))
            ;; GdkEventPadButton
            ((:pad-button-press :pad-button-release) event-pad-button
             (time :uint32)
             (group :uint)
             (button :uint)
             (mode :uint)) ; TODO: Check the type of mode
            ;; GdkEventPadAxis
            ((:pad-ring :pad-strip) event-pad-axis
             (time :uint32)
             (group :uint)
             (index :uint)
             (mode :uint)
             (value :double))
            ;; GdkEventPadGroupMode
            ((:pad-group-mode) event-pad-group-mode
             (time :uint32)
             (group :uint)
             (mode :uint))))  

Values

The following fields are common to all event structures.
type
The gdk:event-type type of the event.
window
The gdk:window object which received the event.
send-event
True if the event was sent explicitly.

Details

The gdk:event structure contains a union of all of the event structures, and allows access to the data fields in a number of ways. The event type is always the first field in all of the event structures, and can always be accessed with the following code, no matter what type of event it is:
(let ((event (gdk:event-new :button-press))) (gdk:event-type event))
=> :BUTTON-PRESS  
To access other fields of the event structures, the appropriate event structure accesor can be used. For example if the event type is :button-press then the x coordinate of the button press can be accessed with:
(let ((event (gdk:event-new :button-press :x 10.0))) (gdk:event-button-x event))
=> 10.0  
 

Slot Access Functions

See also

2024-6-28