2009-07-27 08:54:33 +02:00
|
|
|
/*
|
|
|
|
* Copyright © 2009 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EVENTSTR_H
|
|
|
|
#define EVENTSTR_H
|
|
|
|
|
2015-11-20 16:37:29 +01:00
|
|
|
#include "inputstr.h"
|
2009-07-27 08:54:33 +02:00
|
|
|
#include <events.h>
|
|
|
|
/**
|
|
|
|
* @file events.h
|
|
|
|
* This file describes the event structures used internally by the X
|
|
|
|
* server during event generation and event processing.
|
|
|
|
*
|
|
|
|
* When are internal events used?
|
|
|
|
* Events from input devices are stored as internal events in the EQ and
|
|
|
|
* processed as internal events until late in the processing cycle. Only then
|
|
|
|
* do they switch to their respective wire events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Event types. Used exclusively internal to the server, not visible on the
|
|
|
|
* protocol.
|
|
|
|
*
|
|
|
|
* Note: Keep KeyPress to Motion aligned with the core events.
|
|
|
|
* Keep ET_Raw* in the same order as KeyPress - Motion
|
|
|
|
*/
|
2009-07-29 05:39:38 +02:00
|
|
|
enum EventType {
|
2009-07-27 08:54:33 +02:00
|
|
|
ET_KeyPress = 2,
|
|
|
|
ET_KeyRelease,
|
|
|
|
ET_ButtonPress,
|
|
|
|
ET_ButtonRelease,
|
|
|
|
ET_Motion,
|
2011-12-14 03:45:28 +01:00
|
|
|
ET_TouchBegin,
|
|
|
|
ET_TouchUpdate,
|
|
|
|
ET_TouchEnd,
|
2011-12-14 04:51:12 +01:00
|
|
|
ET_TouchOwnership,
|
2009-07-27 08:54:33 +02:00
|
|
|
ET_Enter,
|
|
|
|
ET_Leave,
|
|
|
|
ET_FocusIn,
|
|
|
|
ET_FocusOut,
|
|
|
|
ET_ProximityIn,
|
|
|
|
ET_ProximityOut,
|
|
|
|
ET_DeviceChanged,
|
|
|
|
ET_Hierarchy,
|
|
|
|
ET_DGAEvent,
|
|
|
|
ET_RawKeyPress,
|
|
|
|
ET_RawKeyRelease,
|
|
|
|
ET_RawButtonPress,
|
|
|
|
ET_RawButtonRelease,
|
|
|
|
ET_RawMotion,
|
2011-12-14 04:21:59 +01:00
|
|
|
ET_RawTouchBegin,
|
|
|
|
ET_RawTouchUpdate,
|
|
|
|
ET_RawTouchEnd,
|
2009-09-28 02:08:12 +02:00
|
|
|
ET_XQuartz,
|
2012-11-01 21:06:40 +01:00
|
|
|
ET_BarrierHit,
|
|
|
|
ET_BarrierLeave,
|
2021-05-30 12:26:30 +02:00
|
|
|
ET_GesturePinchBegin,
|
|
|
|
ET_GesturePinchUpdate,
|
|
|
|
ET_GesturePinchEnd,
|
|
|
|
ET_GestureSwipeBegin,
|
|
|
|
ET_GestureSwipeUpdate,
|
|
|
|
ET_GestureSwipeEnd,
|
2012-03-21 20:55:09 +01:00
|
|
|
ET_Internal = 0xFF /* First byte */
|
2009-07-29 05:39:38 +02:00
|
|
|
};
|
2009-07-27 08:54:33 +02:00
|
|
|
|
2015-11-20 16:37:29 +01:00
|
|
|
/**
|
|
|
|
* How a DeviceEvent was provoked
|
|
|
|
*/
|
|
|
|
enum DeviceEventSource {
|
|
|
|
EVENT_SOURCE_NORMAL = 0, /**< Default: from a user action (e.g. key press) */
|
2015-11-20 16:37:30 +01:00
|
|
|
EVENT_SOURCE_FOCUS, /**< Keys or buttons previously down on focus-in */
|
2015-11-20 16:37:29 +01:00
|
|
|
};
|
|
|
|
|
2009-07-27 08:54:33 +02:00
|
|
|
/**
|
|
|
|
* Used for ALL input device events internal in the server until
|
|
|
|
* copied into the matching protocol event.
|
|
|
|
*
|
|
|
|
* Note: We only use the device id because the DeviceIntPtr may become invalid while
|
|
|
|
* the event is in the EQ.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
struct _DeviceEvent {
|
2009-07-27 08:54:33 +02:00
|
|
|
unsigned char header; /**< Always ET_Internal */
|
2009-07-29 05:45:32 +02:00
|
|
|
enum EventType type; /**< One of EventType */
|
2009-07-27 08:54:33 +02:00
|
|
|
int length; /**< Length in bytes */
|
|
|
|
Time time; /**< Time in ms */
|
|
|
|
int deviceid; /**< Device to post this event for */
|
|
|
|
int sourceid; /**< The physical source device */
|
|
|
|
union {
|
2011-12-14 03:45:28 +01:00
|
|
|
uint32_t button; /**< Button number (also used in pointer emulating
|
|
|
|
touch events) */
|
2009-07-27 08:54:33 +02:00
|
|
|
uint32_t key; /**< Key code */
|
|
|
|
} detail;
|
2011-12-14 03:45:28 +01:00
|
|
|
uint32_t touchid; /**< Touch ID (client_id) */
|
2010-05-07 09:02:43 +02:00
|
|
|
int16_t root_x; /**< Pos relative to root window in integral data */
|
2009-07-27 08:54:33 +02:00
|
|
|
float root_x_frac; /**< Pos relative to root window in frac part */
|
2010-05-07 09:02:43 +02:00
|
|
|
int16_t root_y; /**< Pos relative to root window in integral part */
|
2009-07-27 08:54:33 +02:00
|
|
|
float root_y_frac; /**< Pos relative to root window in frac part */
|
2012-03-21 20:55:09 +01:00
|
|
|
uint8_t buttons[(MAX_BUTTONS + 7) / 8]; /**< Button mask */
|
2009-07-27 08:54:33 +02:00
|
|
|
struct {
|
2012-03-21 20:55:09 +01:00
|
|
|
uint8_t mask[(MAX_VALUATORS + 7) / 8];/**< Valuator mask */
|
|
|
|
uint8_t mode[(MAX_VALUATORS + 7) / 8];/**< Valuator mode (Abs or Rel)*/
|
|
|
|
double data[MAX_VALUATORS]; /**< Valuator data */
|
2009-07-27 08:54:33 +02:00
|
|
|
} valuators;
|
|
|
|
struct {
|
|
|
|
uint32_t base; /**< XKB base modifiers */
|
|
|
|
uint32_t latched; /**< XKB latched modifiers */
|
|
|
|
uint32_t locked; /**< XKB locked modifiers */
|
|
|
|
uint32_t effective;/**< XKB effective modifiers */
|
|
|
|
} mods;
|
|
|
|
struct {
|
|
|
|
uint8_t base; /**< XKB base group */
|
|
|
|
uint8_t latched; /**< XKB latched group */
|
|
|
|
uint8_t locked; /**< XKB locked group */
|
|
|
|
uint8_t effective;/**< XKB effective group */
|
|
|
|
} group;
|
2012-03-21 20:55:09 +01:00
|
|
|
Window root; /**< Root window of the event */
|
2009-07-27 08:54:33 +02:00
|
|
|
int corestate; /**< Core key/button state BEFORE the event */
|
2009-08-21 08:03:36 +02:00
|
|
|
int key_repeat; /**< Internally-generated key repeat event */
|
2010-12-27 14:24:35 +01:00
|
|
|
uint32_t flags; /**< Flags to be copied into the generated event */
|
2013-02-28 04:07:26 +01:00
|
|
|
uint32_t resource; /**< Touch event resource, only for TOUCH_REPLAYING */
|
2015-11-20 16:37:29 +01:00
|
|
|
enum DeviceEventSource source_type; /**< How this event was provoked */
|
2009-07-27 08:54:33 +02:00
|
|
|
};
|
|
|
|
|
2011-12-14 04:51:12 +01:00
|
|
|
/**
|
|
|
|
* Generated internally whenever a touch ownership chain changes - an owner
|
|
|
|
* has accepted or rejected a touch, or a grab/event selection in the delivery
|
|
|
|
* chain has been removed.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
struct _TouchOwnershipEvent {
|
2011-12-14 04:51:12 +01:00
|
|
|
unsigned char header; /**< Always ET_Internal */
|
2012-12-03 02:39:08 +01:00
|
|
|
enum EventType type; /**< ET_TouchOwnership */
|
2011-12-14 04:51:12 +01:00
|
|
|
int length; /**< Length in bytes */
|
|
|
|
Time time; /**< Time in ms */
|
|
|
|
int deviceid; /**< Device to post this event for */
|
|
|
|
int sourceid; /**< The physical source device */
|
|
|
|
uint32_t touchid; /**< Touch ID (client_id) */
|
|
|
|
uint8_t reason; /**< ::XIAcceptTouch, ::XIRejectTouch */
|
|
|
|
uint32_t resource; /**< Provoking grab or event selection */
|
|
|
|
uint32_t flags; /**< Flags to be copied into the generated event */
|
|
|
|
};
|
2009-07-27 08:54:33 +02:00
|
|
|
|
2009-08-11 08:27:40 +02:00
|
|
|
/* Flags used in DeviceChangedEvent to signal if the slave has changed */
|
|
|
|
#define DEVCHANGE_SLAVE_SWITCH 0x2
|
2009-07-27 08:54:33 +02:00
|
|
|
/* Flags used in DeviceChangedEvent to signal whether the event was a
|
|
|
|
* pointer event or a keyboard event */
|
|
|
|
#define DEVCHANGE_POINTER_EVENT 0x4
|
|
|
|
#define DEVCHANGE_KEYBOARD_EVENT 0x8
|
|
|
|
/* device capabilities changed */
|
|
|
|
#define DEVCHANGE_DEVICE_CHANGE 0x10
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sent whenever a device's capabilities have changed.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
struct _DeviceChangedEvent {
|
2009-07-27 08:54:33 +02:00
|
|
|
unsigned char header; /**< Always ET_Internal */
|
2009-07-29 05:45:32 +02:00
|
|
|
enum EventType type; /**< ET_DeviceChanged */
|
2009-07-27 08:54:33 +02:00
|
|
|
int length; /**< Length in bytes */
|
|
|
|
Time time; /**< Time in ms */
|
|
|
|
int deviceid; /**< Device whose capabilities have changed */
|
2009-08-11 08:27:40 +02:00
|
|
|
int flags; /**< Mask of ::HAS_NEW_SLAVE,
|
2009-07-27 08:54:33 +02:00
|
|
|
::POINTER_EVENT, ::KEYBOARD_EVENT */
|
2009-08-11 08:27:40 +02:00
|
|
|
int masterid; /**< MD when event was generated */
|
|
|
|
int sourceid; /**< The device that caused the change */
|
2009-07-27 08:54:33 +02:00
|
|
|
|
|
|
|
struct {
|
|
|
|
int num_buttons; /**< Number of buttons */
|
|
|
|
Atom names[MAX_BUTTONS];/**< Button names */
|
|
|
|
} buttons;
|
|
|
|
|
|
|
|
int num_valuators; /**< Number of axes */
|
|
|
|
struct {
|
|
|
|
uint32_t min; /**< Minimum value */
|
|
|
|
uint32_t max; /**< Maximum value */
|
2014-02-10 01:56:40 +01:00
|
|
|
double value; /**< Current value */
|
2009-07-27 08:54:33 +02:00
|
|
|
/* FIXME: frac parts of min/max */
|
|
|
|
uint32_t resolution; /**< Resolution counts/m */
|
|
|
|
uint8_t mode; /**< Relative or Absolute */
|
|
|
|
Atom name; /**< Axis name */
|
2011-10-18 09:11:27 +02:00
|
|
|
ScrollInfo scroll; /**< Smooth scrolling info */
|
2009-07-27 08:54:33 +02:00
|
|
|
} valuators[MAX_VALUATORS];
|
|
|
|
|
|
|
|
struct {
|
|
|
|
int min_keycode;
|
|
|
|
int max_keycode;
|
|
|
|
} keys;
|
|
|
|
};
|
|
|
|
|
2018-02-18 10:58:34 +01:00
|
|
|
#ifdef XFreeXDGA
|
2009-07-27 08:54:33 +02:00
|
|
|
/**
|
|
|
|
* DGAEvent, used by DGA to intercept and emulate input events.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
struct _DGAEvent {
|
2009-07-27 08:54:33 +02:00
|
|
|
unsigned char header; /**< Always ET_Internal */
|
2009-07-29 05:45:32 +02:00
|
|
|
enum EventType type; /**< ET_DGAEvent */
|
2009-07-27 08:54:33 +02:00
|
|
|
int length; /**< Length in bytes */
|
|
|
|
Time time; /**< Time in ms */
|
|
|
|
int subtype; /**< KeyPress, KeyRelease, ButtonPress,
|
|
|
|
ButtonRelease, MotionNotify */
|
2011-01-24 00:06:39 +01:00
|
|
|
int detail; /**< Button number or key code */
|
2009-07-27 08:54:33 +02:00
|
|
|
int dx; /**< Relative x coordinate */
|
|
|
|
int dy; /**< Relative y coordinate */
|
|
|
|
int screen; /**< Screen number this event applies to */
|
|
|
|
uint16_t state; /**< Core modifier/button state */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Raw event, contains the data as posted by the device.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
struct _RawDeviceEvent {
|
2009-07-27 08:54:33 +02:00
|
|
|
unsigned char header; /**< Always ET_Internal */
|
2009-07-29 05:45:32 +02:00
|
|
|
enum EventType type; /**< ET_Raw */
|
2009-07-27 08:54:33 +02:00
|
|
|
int length; /**< Length in bytes */
|
|
|
|
Time time; /**< Time in ms */
|
|
|
|
int deviceid; /**< Device to post this event for */
|
|
|
|
int sourceid; /**< The physical source device */
|
|
|
|
union {
|
|
|
|
uint32_t button; /**< Button number */
|
|
|
|
uint32_t key; /**< Key code */
|
|
|
|
} detail;
|
|
|
|
struct {
|
2012-03-21 20:55:09 +01:00
|
|
|
uint8_t mask[(MAX_VALUATORS + 7) / 8];/**< Valuator mask */
|
|
|
|
double data[MAX_VALUATORS]; /**< Valuator data */
|
|
|
|
double data_raw[MAX_VALUATORS]; /**< Valuator data as posted */
|
2009-07-27 08:54:33 +02:00
|
|
|
} valuators;
|
2011-06-09 17:02:47 +02:00
|
|
|
uint32_t flags; /**< Flags to be copied into the generated event */
|
2009-07-27 08:54:33 +02:00
|
|
|
};
|
|
|
|
|
2012-11-01 21:06:40 +01:00
|
|
|
struct _BarrierEvent {
|
|
|
|
unsigned char header; /**< Always ET_Internal */
|
|
|
|
enum EventType type; /**< ET_BarrierHit, ET_BarrierLeave */
|
|
|
|
int length; /**< Length in bytes */
|
|
|
|
Time time; /**< Time in ms */
|
|
|
|
int deviceid; /**< Device to post this event for */
|
|
|
|
int sourceid; /**< The physical source device */
|
|
|
|
int barrierid;
|
|
|
|
Window window;
|
|
|
|
Window root;
|
|
|
|
double dx;
|
|
|
|
double dy;
|
|
|
|
double root_x;
|
|
|
|
double root_y;
|
|
|
|
int16_t dt;
|
|
|
|
int32_t event_id;
|
|
|
|
uint32_t flags;
|
|
|
|
};
|
|
|
|
|
2009-09-28 02:08:12 +02:00
|
|
|
#ifdef XQUARTZ
|
|
|
|
#define XQUARTZ_EVENT_MAXARGS 5
|
|
|
|
struct _XQuartzEvent {
|
|
|
|
unsigned char header; /**< Always ET_Internal */
|
|
|
|
enum EventType type; /**< Always ET_XQuartz */
|
|
|
|
int length; /**< Length in bytes */
|
|
|
|
Time time; /**< Time in ms. */
|
|
|
|
int subtype; /**< Subtype defined by XQuartz DDX */
|
|
|
|
uint32_t data[XQUARTZ_EVENT_MAXARGS]; /**< Up to 5 32bit values passed to handler */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2009-07-27 08:54:33 +02:00
|
|
|
/**
|
|
|
|
* Event type used inside the X server for input event
|
|
|
|
* processing.
|
|
|
|
*/
|
|
|
|
union _InternalEvent {
|
2012-03-21 20:55:09 +01:00
|
|
|
struct {
|
|
|
|
unsigned char header; /**< Always ET_Internal */
|
|
|
|
enum EventType type; /**< One of ET_* */
|
|
|
|
int length; /**< Length in bytes */
|
|
|
|
Time time; /**< Time in ms. */
|
|
|
|
} any;
|
|
|
|
DeviceEvent device_event;
|
|
|
|
DeviceChangedEvent changed_event;
|
|
|
|
TouchOwnershipEvent touch_ownership_event;
|
2012-11-01 21:06:40 +01:00
|
|
|
BarrierEvent barrier_event;
|
2018-02-18 10:58:34 +01:00
|
|
|
#ifdef XFreeXDGA
|
2012-03-21 20:55:09 +01:00
|
|
|
DGAEvent dga_event;
|
2009-07-27 08:54:33 +02:00
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
RawDeviceEvent raw_event;
|
2009-09-28 02:08:12 +02:00
|
|
|
#ifdef XQUARTZ
|
2012-03-21 20:55:09 +01:00
|
|
|
XQuartzEvent xquartz_event;
|
2009-09-28 02:08:12 +02:00
|
|
|
#endif
|
2009-07-27 08:54:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|