summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-08-03 15:07:23 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-08-22 15:56:52 +1000
commit3a077f246e9ac07a37c1b01c3d321e0f5ceb4153 (patch)
tree5fcbadd5265c9c3495b164e4140786a58164b8e7
parent4b376ddeb4f3c9d9d279ffd2946d88edd5af4cfc (diff)
input: provide a single function to init DeviceEvents to 0
getevents.c already had that function, but XKB was manually initializing it, causing bugs when the event structure was updated in one place but not the other. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--dix/getevents.c19
-rw-r--r--dix/inpututils.c14
-rw-r--r--include/inpututils.h1
-rw-r--r--xkb/xkbAccessX.c8
4 files changed, 21 insertions, 21 deletions
diff --git a/dix/getevents.c b/dix/getevents.c
index f7f4617e7..be2840c47 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -154,17 +154,6 @@ key_autorepeats(DeviceIntPtr pDev, int key_code)
}
static void
-init_event(DeviceIntPtr dev, DeviceEvent* event, Time ms)
-{
- memset(event, 0, sizeof(DeviceEvent));
- event->header = ET_Internal;
- event->length = sizeof(DeviceEvent);
- event->time = ms;
- event->deviceid = dev->id;
- event->sourceid = dev->id;
-}
-
-static void
init_raw(DeviceIntPtr dev, RawDeviceEvent *event, Time ms, int type, int detail)
{
memset(event, 0, sizeof(RawDeviceEvent));
@@ -1006,7 +995,7 @@ GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
set_raw_valuators(raw, &mask, raw->valuators.data);
event = &events->device_event;
- init_event(pDev, event, ms);
+ init_device_event(event, pDev, ms);
event->detail.key = key_code;
if (type == KeyPress) {
@@ -1228,7 +1217,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons
clipValuators(pDev, &mask);
event = &events->device_event;
- init_event(pDev, event, ms);
+ init_device_event(event, pDev, ms);
if (type == MotionNotify) {
event->type = ET_Motion;
@@ -1321,7 +1310,7 @@ GetProximityEvents(InternalEvent *events, DeviceIntPtr pDev, int type, const Val
events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events);
event = &events->device_event;
- init_event(pDev, event, GetTimeInMillis());
+ init_device_event(event, pDev, GetTimeInMillis());
event->type = (type == ProximityIn) ? ET_ProximityIn : ET_ProximityOut;
clipValuators(pDev, &mask);
@@ -1357,7 +1346,7 @@ PostSyntheticMotion(DeviceIntPtr pDev,
#endif
memset(&ev, 0, sizeof(DeviceEvent));
- init_event(pDev, &ev, time);
+ init_device_event(&ev, pDev, time);
ev.root_x = x;
ev.root_y = y;
ev.type = ET_Motion;
diff --git a/dix/inpututils.c b/dix/inpututils.c
index 49e175822..96320767d 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -584,3 +584,17 @@ void verify_internal_event(const InternalEvent *ev)
FatalError("Wrong event type %d. Aborting server\n", ev->any.header);
}
}
+
+/**
+ * Initializes the given event to zero (or default values), for the given
+ * device.
+ */
+void init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms)
+{
+ memset(event, 0, sizeof(DeviceEvent));
+ event->header = ET_Internal;
+ event->length = sizeof(DeviceEvent);
+ event->time = ms;
+ event->deviceid = dev->id;
+ event->sourceid = dev->id;
+}
diff --git a/include/inpututils.h b/include/inpututils.h
index 92a754327..63e1a263a 100644
--- a/include/inpututils.h
+++ b/include/inpututils.h
@@ -38,5 +38,6 @@ struct _ValuatorMask {
};
extern void verify_internal_event(const InternalEvent *ev);
+extern void init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms);
#endif
diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index 12fe2a1f5..4115ff27d 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -124,15 +124,11 @@ AccessXKeyboardEvent(DeviceIntPtr keybd,
Bool isRepeat)
{
DeviceEvent event;
- memset(&event, 0, sizeof(DeviceEvent));
- event.header = ET_Internal;
+
+ init_device_event(&event, keybd, GetTimeInMillis());
event.type = type;
event.detail.key = keyCode;
- event.time = GetTimeInMillis();
- event.length = sizeof(DeviceEvent);
event.key_repeat = isRepeat;
- event.sourceid = keybd->id;
- event.deviceid = keybd->id;
if (xkbDebugFlags&0x8) {
DebugF("[xkb] AXKE: Key %d %s\n", keyCode,