Commit c3788394 authored by Daniel Stone's avatar Daniel Stone Committed by Peter Hutterer

Input: Add DeviceEventSource enum

Add a flag to DeviceEvents, giving the source of the event. Currently
this only supports a 'normal' flag, but will be used later to add a
'focus-in' flag, noting events synthesised from key/button arrays on
focus-in notifications.
Signed-off-by: 's avatarDaniel Stone <daniels@collabora.com>
Reviewed-by: 's avatarPeter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: 's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 2e61901e
......@@ -1092,6 +1092,7 @@ GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
CARD32 ms = 0;
DeviceEvent *event;
RawDeviceEvent *raw;
enum DeviceEventSource source_type = EVENT_SOURCE_NORMAL;
#if XSERVER_DTRACE
if (XSERVER_INPUT_EVENT_ENABLED()) {
......@@ -1126,14 +1127,15 @@ GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
ms = GetTimeInMillis();
raw = &events->raw_event;
events++;
num_events++;
init_raw(pDev, raw, ms, type, key_code);
if (source_type == EVENT_SOURCE_NORMAL) {
raw = &events->raw_event;
init_raw(pDev, raw, ms, type, key_code);
events++;
num_events++;
}
event = &events->device_event;
init_device_event(event, pDev, ms);
init_device_event(event, pDev, ms, source_type);
event->detail.key = key_code;
if (type == KeyPress) {
......@@ -1468,7 +1470,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
}
event = &events->device_event;
init_device_event(event, pDev, ms);
init_device_event(event, pDev, ms, EVENT_SOURCE_NORMAL);
if (type == MotionNotify) {
event->type = ET_Motion;
......@@ -1804,7 +1806,7 @@ GetProximityEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events);
event = &events->device_event;
init_device_event(event, pDev, GetTimeInMillis());
init_device_event(event, pDev, GetTimeInMillis(), EVENT_SOURCE_NORMAL);
event->type = (type == ProximityIn) ? ET_ProximityIn : ET_ProximityOut;
clipValuators(pDev, &mask);
......@@ -1939,7 +1941,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
event = &events->device_event;
num_events++;
init_device_event(event, dev, ms);
init_device_event(event, dev, ms, EVENT_SOURCE_NORMAL);
switch (type) {
case XI_TouchBegin:
......@@ -2054,7 +2056,7 @@ GetDixTouchEnd(InternalEvent *ievent, DeviceIntPtr dev, TouchPointInfoPtr ti,
BUG_WARN(!dev->enabled);
init_device_event(event, dev, ms);
init_device_event(event, dev, ms, EVENT_SOURCE_NORMAL);
event->sourceid = ti->sourceid;
event->type = ET_TouchEnd;
......@@ -2098,7 +2100,7 @@ PostSyntheticMotion(DeviceIntPtr pDev,
#endif
memset(&ev, 0, sizeof(DeviceEvent));
init_device_event(&ev, pDev, time);
init_device_event(&ev, pDev, time, EVENT_SOURCE_NORMAL);
ev.root_x = x;
ev.root_y = y;
ev.type = ET_Motion;
......
......@@ -727,7 +727,8 @@ verify_internal_event(const InternalEvent *ev)
* device.
*/
void
init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms)
init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms,
enum DeviceEventSource source_type)
{
memset(event, 0, sizeof(DeviceEvent));
event->header = ET_Internal;
......@@ -735,6 +736,7 @@ init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms)
event->time = ms;
event->deviceid = dev->id;
event->sourceid = dev->id;
event->source_type = source_type;
}
int
......
......@@ -25,6 +25,7 @@
#ifndef EVENTSTR_H
#define EVENTSTR_H
#include "inputstr.h"
#include <events.h>
/**
* @file events.h
......@@ -77,6 +78,13 @@ enum EventType {
ET_Internal = 0xFF /* First byte */
};
/**
* How a DeviceEvent was provoked
*/
enum DeviceEventSource {
EVENT_SOURCE_NORMAL = 0, /**< Default: from a user action (e.g. key press) */
};
/**
* Used for ALL input device events internal in the server until
* copied into the matching protocol event.
......@@ -124,6 +132,7 @@ struct _DeviceEvent {
int key_repeat; /**< Internally-generated key repeat event */
uint32_t flags; /**< Flags to be copied into the generated event */
uint32_t resource; /**< Touch event resource, only for TOUCH_REPLAYING */
enum DeviceEventSource source_type; /**< How this event was provoked */
};
/**
......
......@@ -30,6 +30,7 @@
#define INPUTUTILS_H
#include "input.h"
#include "eventstr.h"
#include <X11/extensions/XI2proto.h>
extern Mask event_filters[MAXDEVICES][MAXEVENTS];
......@@ -43,7 +44,8 @@ struct _ValuatorMask {
};
extern void verify_internal_event(const InternalEvent *ev);
extern void init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms);
extern void init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms,
enum DeviceEventSource event_source);
extern int event_get_corestate(DeviceIntPtr mouse, DeviceIntPtr kbd);
extern void event_set_state(DeviceIntPtr mouse, DeviceIntPtr kbd,
DeviceEvent *event);
......
......@@ -126,7 +126,7 @@ AccessXKeyboardEvent(DeviceIntPtr keybd, int type, BYTE keyCode, Bool isRepeat)
{
DeviceEvent event;
init_device_event(&event, keybd, GetTimeInMillis());
init_device_event(&event, keybd, GetTimeInMillis(), EVENT_SOURCE_NORMAL);
event.type = type;
event.detail.key = keyCode;
event.key_repeat = isRepeat;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment