Xi: use fixed define for extenion base opcode
Several places outside Xi (eg. dix, security hooks, ...) need to know the actual XI base opcode. This formerly had been done by a global variable, which is filled on XI init. This has some drawbacks, eg. requires that XI really is initialized before anybody else attempting to access this variable - changes in extension init order could be dangerous. Since extension opcodes are now (compile-time) fixed for all known extensions (including XI), this isn't needed anymore. We can really rely on the XI extension always having the same opcode base. So we can drop that variable entirely and use the corresponding define instead. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
c6eaca88cd
commit
86cf2c5ce3
|
@ -36,7 +36,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#ifndef EXGLOBALS_H
|
||||
#define EXGLOBALS_H 1
|
||||
|
||||
extern int IReqCode;
|
||||
extern int IEventBase;
|
||||
extern int BadDevice;
|
||||
extern int BadMode;
|
||||
|
|
10
Xi/extinit.c
10
Xi/extinit.c
|
@ -53,6 +53,8 @@ SOFTWARE.
|
|||
|
||||
#include <dix-config.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <X11/extensions/XI.h>
|
||||
#include <X11/extensions/XIproto.h>
|
||||
#include <X11/extensions/XI2proto.h>
|
||||
|
@ -60,6 +62,7 @@ SOFTWARE.
|
|||
|
||||
#include "dix/dix_priv.h"
|
||||
#include "dix/exevents_priv.h"
|
||||
#include "dix/extension_priv.h"
|
||||
#include "Xext/geext_priv.h"
|
||||
|
||||
#include "inputstr.h"
|
||||
|
@ -321,7 +324,6 @@ static int (*SProcIVector[]) (ClientPtr) = {
|
|||
*
|
||||
*/
|
||||
|
||||
int IReqCode = 0;
|
||||
int IEventBase = 0;
|
||||
int BadDevice = 0;
|
||||
static int BadEvent = 1;
|
||||
|
@ -1029,7 +1031,6 @@ RestoreExtensionEvents(void)
|
|||
{
|
||||
int i, j;
|
||||
|
||||
IReqCode = 0;
|
||||
IEventBase = 0;
|
||||
|
||||
for (i = 0; i < ExtEventIndex - 1; i++) {
|
||||
|
@ -1230,7 +1231,8 @@ XInputExtensionInit(void)
|
|||
extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch,
|
||||
SProcIDispatch, IResetProc, StandardMinorOpcode);
|
||||
if (extEntry) {
|
||||
IReqCode = extEntry->base;
|
||||
assert(extEntry->base == EXTENSION_MAJOR_XINPUT);
|
||||
|
||||
IEventBase = extEntry->eventBase;
|
||||
XIVersion = thisversion;
|
||||
MakeDeviceTypeAtoms();
|
||||
|
@ -1256,7 +1258,7 @@ XInputExtensionInit(void)
|
|||
EventSwapVector[ChangeDeviceNotify] = SEventIDispatch;
|
||||
EventSwapVector[DevicePresenceNotify] = SEventIDispatch;
|
||||
|
||||
GERegisterExtension(IReqCode, XI2EventSwap);
|
||||
GERegisterExtension(EXTENSION_MAJOR_XINPUT, XI2EventSwap);
|
||||
|
||||
memset(&xi_all_devices, 0, sizeof(xi_all_devices));
|
||||
memset(&xi_all_master_devices, 0, sizeof(xi_all_master_devices));
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include "dix/dix_priv.h"
|
||||
#include "dix/exevents_priv.h"
|
||||
#include "dix/extension_priv.h"
|
||||
#include "dix/input_priv.h"
|
||||
#include "os/bug_priv.h"
|
||||
|
||||
|
@ -75,7 +76,7 @@ XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
|
|||
if (!ev)
|
||||
return;
|
||||
ev->type = GenericEvent;
|
||||
ev->extension = IReqCode;
|
||||
ev->extension = EXTENSION_MAJOR_XINPUT;
|
||||
ev->evtype = XI_HierarchyChanged;
|
||||
ev->time = GetTimeInMillis();
|
||||
ev->flags = 0;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <X11/extensions/XI2proto.h>
|
||||
|
||||
#include "dix/exevents_priv.h"
|
||||
#include "dix/extension_priv.h"
|
||||
#include "dix/input_priv.h"
|
||||
|
||||
#include "dix.h"
|
||||
|
@ -194,7 +195,7 @@ send_property_event(DeviceIntPtr dev, Atom property, int what)
|
|||
};
|
||||
xXIPropertyEvent xi2 = {
|
||||
.type = GenericEvent,
|
||||
.extension = IReqCode,
|
||||
.extension = EXTENSION_MAJOR_XINPUT,
|
||||
.length = 0,
|
||||
.evtype = XI_PropertyEvent,
|
||||
.deviceid = dev->id,
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "dix/dix_priv.h"
|
||||
#include "dix/eventconvert.h"
|
||||
#include "dix/extension_priv.h"
|
||||
#include "dix/input_priv.h"
|
||||
#include "os/bug_priv.h"
|
||||
|
||||
|
@ -787,7 +788,7 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
|
|||
return;
|
||||
|
||||
xi2event->type = GenericEvent;
|
||||
xi2event->extension = IReqCode;
|
||||
xi2event->extension = EXTENSION_MAJOR_XINPUT;
|
||||
xi2event->evtype = type;
|
||||
xi2event->length = bytes_to_int32(len - sizeof(xEvent));
|
||||
xi2event->buttons_len = btlen;
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "dix/dix_priv.h"
|
||||
#include "dix/eventconvert.h"
|
||||
#include "dix/exevents_priv.h"
|
||||
#include "dix/extension_priv.h"
|
||||
|
||||
#include "dix.h"
|
||||
#include "inputstr.h"
|
||||
|
@ -604,7 +605,7 @@ eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi)
|
|||
}
|
||||
|
||||
dcce->type = GenericEvent;
|
||||
dcce->extension = IReqCode;
|
||||
dcce->extension = EXTENSION_MAJOR_XINPUT;
|
||||
dcce->evtype = XI_DeviceChanged;
|
||||
dcce->time = dce->time;
|
||||
dcce->deviceid = dce->deviceid;
|
||||
|
@ -687,7 +688,7 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi)
|
|||
return BadAlloc;
|
||||
xde = (xXIDeviceEvent *) * xi;
|
||||
xde->type = GenericEvent;
|
||||
xde->extension = IReqCode;
|
||||
xde->extension = EXTENSION_MAJOR_XINPUT;
|
||||
xde->evtype = GetXI2Type(ev->type);
|
||||
xde->time = ev->time;
|
||||
xde->length = bytes_to_int32(len - sizeof(xEvent));
|
||||
|
@ -757,7 +758,7 @@ eventToTouchOwnershipEvent(TouchOwnershipEvent *ev, xEvent **xi)
|
|||
return BadAlloc;
|
||||
xtoe = (xXITouchOwnershipEvent *) * xi;
|
||||
xtoe->type = GenericEvent;
|
||||
xtoe->extension = IReqCode;
|
||||
xtoe->extension = EXTENSION_MAJOR_XINPUT;
|
||||
xtoe->length = bytes_to_int32(len - sizeof(xEvent));
|
||||
xtoe->evtype = GetXI2Type(ev->type);
|
||||
xtoe->deviceid = ev->deviceid;
|
||||
|
@ -789,7 +790,7 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi)
|
|||
return BadAlloc;
|
||||
raw = (xXIRawEvent *) * xi;
|
||||
raw->type = GenericEvent;
|
||||
raw->extension = IReqCode;
|
||||
raw->extension = EXTENSION_MAJOR_XINPUT;
|
||||
raw->evtype = GetXI2Type(ev->type);
|
||||
raw->time = ev->time;
|
||||
raw->length = bytes_to_int32(len - sizeof(xEvent));
|
||||
|
@ -826,7 +827,7 @@ eventToBarrierEvent(BarrierEvent *ev, xEvent **xi)
|
|||
return BadAlloc;
|
||||
barrier = (xXIBarrierEvent*) *xi;
|
||||
barrier->type = GenericEvent;
|
||||
barrier->extension = IReqCode;
|
||||
barrier->extension = EXTENSION_MAJOR_XINPUT;
|
||||
barrier->evtype = GetXI2Type(ev->type);
|
||||
barrier->length = bytes_to_int32(len - sizeof(xEvent));
|
||||
barrier->deviceid = ev->deviceid;
|
||||
|
@ -857,7 +858,7 @@ eventToGesturePinchEvent(GestureEvent *ev, xEvent **xi)
|
|||
return BadAlloc;
|
||||
xpe = (xXIGesturePinchEvent *) * xi;
|
||||
xpe->type = GenericEvent;
|
||||
xpe->extension = IReqCode;
|
||||
xpe->extension = EXTENSION_MAJOR_XINPUT;
|
||||
xpe->evtype = GetXI2Type(ev->type);
|
||||
xpe->time = ev->time;
|
||||
xpe->length = bytes_to_int32(len - sizeof(xEvent));
|
||||
|
@ -901,7 +902,7 @@ eventToGestureSwipeEvent(GestureEvent *ev, xEvent **xi)
|
|||
return BadAlloc;
|
||||
xde = (xXIGestureSwipeEvent *) * xi;
|
||||
xde->type = GenericEvent;
|
||||
xde->extension = IReqCode;
|
||||
xde->extension = EXTENSION_MAJOR_XINPUT;
|
||||
xde->evtype = GetXI2Type(ev->type);
|
||||
xde->time = ev->time;
|
||||
xde->length = bytes_to_int32(len - sizeof(xEvent));
|
||||
|
|
|
@ -121,9 +121,10 @@ Equipment Corporation.
|
|||
#include "dix/cursor_priv.h"
|
||||
#include "dix/dix_priv.h"
|
||||
#include "dix/dixgrabs_priv.h"
|
||||
#include "dix/input_priv.h"
|
||||
#include "dix/eventconvert.h"
|
||||
#include "dix/exevents_priv.h"
|
||||
#include "dix/extension_priv.h"
|
||||
#include "dix/input_priv.h"
|
||||
#include "dix/reqhandlers_priv.h"
|
||||
#include "dix/resource_priv.h"
|
||||
#include "os/bug_priv.h"
|
||||
|
@ -196,7 +197,7 @@ xi2_get_type(const xEvent *event)
|
|||
const xGenericEvent *e = (const xGenericEvent *) event;
|
||||
|
||||
return (e->type != GenericEvent ||
|
||||
e->extension != IReqCode) ? 0 : e->evtype;
|
||||
e->extension != EXTENSION_MAJOR_XINPUT) ? 0 : e->evtype;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4763,7 +4764,7 @@ DeviceEnterLeaveEvent(DeviceIntPtr mouse,
|
|||
return;
|
||||
|
||||
event->type = GenericEvent;
|
||||
event->extension = IReqCode;
|
||||
event->extension = EXTENSION_MAJOR_XINPUT;
|
||||
event->evtype = type;
|
||||
event->length = (len - sizeof(xEvent)) / 4;
|
||||
event->buttons_len = btlen;
|
||||
|
@ -6299,7 +6300,7 @@ IsWrongPointerBarrierClient(ClientPtr client, DeviceIntPtr dev, xEvent *event)
|
|||
{
|
||||
xXIBarrierEvent *ev = (xXIBarrierEvent*)event;
|
||||
|
||||
if (ev->type != GenericEvent || ev->extension != IReqCode)
|
||||
if (ev->type != GenericEvent || ev->extension != EXTENSION_MAJOR_XINPUT)
|
||||
return FALSE;
|
||||
|
||||
if (ev->evtype != XI_BarrierHit && ev->evtype != XI_BarrierLeave)
|
||||
|
|
Loading…
Reference in New Issue