mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-01-07 10:10:15 +01:00
Input cleanup.
This commit is contained in:
parent
af21ea418b
commit
08987c7ee4
3 changed files with 21 additions and 160 deletions
|
|
@ -124,52 +124,6 @@ void dmxBackendDestroyPrivate(pointer private)
|
|||
if (private) free(private);
|
||||
}
|
||||
|
||||
static void *dmxBackendTestScreen(DMXScreenInfo *dmxScreen, void *closure)
|
||||
{
|
||||
long target = (long)closure;
|
||||
|
||||
if (dmxScreen->index == target) return dmxScreen;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Return non-zero if screen and priv->myScreen are on the same physical
|
||||
* backend display (1 if they are the same screen, 2 if they are
|
||||
* different screens). Since this is a common operation, the results
|
||||
* are cached. The cache is invalidated if \a priv is NULL (this should
|
||||
* be done with each server generation and reconfiguration). */
|
||||
static int dmxBackendSameDisplay(myPrivate *priv, long screen)
|
||||
{
|
||||
static myPrivate *oldpriv = NULL;
|
||||
static int oldscreen = -1;
|
||||
static int retcode = 0;
|
||||
|
||||
if (priv == oldpriv && screen == oldscreen) return retcode;
|
||||
if (!priv) { /* Invalidate cache */
|
||||
oldpriv = NULL;
|
||||
oldscreen = -1;
|
||||
retcode = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (screen == priv->myScreen) retcode = 1;
|
||||
else if (screen < 0 || screen >= dmxNumScreens) retcode = 0;
|
||||
else if (dmxPropertyIterate(priv->be,
|
||||
dmxBackendTestScreen,
|
||||
(void *)screen)) retcode = 2;
|
||||
else retcode = 0;
|
||||
|
||||
oldpriv = priv;
|
||||
oldscreen = screen;
|
||||
return retcode;
|
||||
}
|
||||
|
||||
static void *dmxBackendTestWindow(DMXScreenInfo *dmxScreen, void *closure)
|
||||
{
|
||||
Window win = (Window)(long)closure;
|
||||
if (dmxScreen->scrnWin == win) return dmxScreen;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void dmxBackendUpdatePosition(pointer private, int x, int y)
|
||||
{
|
||||
}
|
||||
|
|
@ -932,9 +886,7 @@ static DMXScreenInfo *dmxBackendInitPrivate(DevicePtr pDev)
|
|||
|
||||
/* Fill in myPrivate */
|
||||
for (i = 0,dmxScreen = &dmxScreens[0]; i<dmxNumScreens; i++,dmxScreen++) {
|
||||
if ((dmxInput->scrnIdx == -1 &&
|
||||
dmxPropertySameDisplay (dmxScreen, dmxInput->name)) ||
|
||||
dmxInput->scrnIdx == i) {
|
||||
if (dmxInput->scrnIdx == i) {
|
||||
priv->display = dmxScreen->beDisplay;
|
||||
priv->window = dmxScreen->scrnWin;
|
||||
priv->be = dmxScreen;
|
||||
|
|
@ -959,7 +911,6 @@ void dmxBackendLateReInit(DevicePtr pDev)
|
|||
DMXDBG1("dmxBackendLateReInit miPointerCurrentScreen() = %p\n",
|
||||
miPointerCurrentScreen());
|
||||
|
||||
dmxBackendSameDisplay(NULL, 0); /* Invalidate cache */
|
||||
dmxBackendInitPrivate(pDev);
|
||||
dmxGetGlobalPosition(&x, &y);
|
||||
dmxInvalidateGlobalPosition(); /* To force event processing */
|
||||
|
|
@ -971,8 +922,6 @@ void dmxBackendInit(DevicePtr pDev)
|
|||
GETPRIVFROMPDEV;
|
||||
DMXScreenInfo *dmxScreen;
|
||||
|
||||
dmxBackendSameDisplay(NULL, 0); /* Invalidate cache */
|
||||
|
||||
if (dmxLocal->type == DMX_LOCAL_MOUSE) priv->mou = pDev;
|
||||
if (dmxLocal->type == DMX_LOCAL_KEYBOARD) priv->kbd = pDev;
|
||||
if (priv->initialized++) return; /* Only do once for mouse/keyboard pair */
|
||||
|
|
|
|||
|
|
@ -223,8 +223,8 @@ void dmxCommonKbdGetMap(DevicePtr pDev, KeySymsPtr pKeySyms, CARD8 *pModMap)
|
|||
int min_keycode;
|
||||
int max_keycode;
|
||||
int map_width;
|
||||
KeySym *keyboard_mapping;
|
||||
XModifierKeymap *modifier_mapping;
|
||||
KeySym *keyboard_mapping = NULL;
|
||||
XModifierKeymap *modifier_mapping = NULL;
|
||||
int i, j;
|
||||
|
||||
/* Compute pKeySyms. Cast
|
||||
|
|
@ -517,35 +517,16 @@ void dmxCommonMouGetMap(DevicePtr pDev, unsigned char *map, int *nButtons)
|
|||
for (i = 0; i <= *nButtons; i++) map[i] = i;
|
||||
}
|
||||
|
||||
static void *dmxCommonXSelect(DMXScreenInfo *dmxScreen, void *closure)
|
||||
{
|
||||
myPrivate *priv = closure;
|
||||
XLIB_PROLOGUE (dmxScreen);
|
||||
XSelectInput(dmxScreen->beDisplay, dmxScreen->scrnWin, priv->eventMask);
|
||||
XLIB_EPILOGUE (dmxScreen);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *dmxCommonAddEnabledDevice(DMXScreenInfo *dmxScreen, void *closure)
|
||||
{
|
||||
AddEnabledDevice(XConnectionNumber(dmxScreen->beDisplay));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *dmxCommonRemoveEnabledDevice(DMXScreenInfo *dmxScreen,
|
||||
void *closure)
|
||||
{
|
||||
RemoveEnabledDevice(XConnectionNumber(dmxScreen->beDisplay));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Turn \a pDev on (i.e., take input from \a pDev). */
|
||||
int dmxCommonMouOn(DevicePtr pDev)
|
||||
{
|
||||
GETPRIVFROMPDEV;
|
||||
GETDMXINPUTFROMPRIV;
|
||||
|
||||
if (priv->be && dmxLocal->deviceId >= 0)
|
||||
if (!priv->be)
|
||||
return -1;
|
||||
|
||||
if (dmxLocal->deviceId >= 0)
|
||||
{
|
||||
XEventClass cls[5];
|
||||
int type;
|
||||
|
|
@ -571,23 +552,9 @@ int dmxCommonMouOn(DevicePtr pDev)
|
|||
else
|
||||
{
|
||||
priv->eventMask |= DMX_POINTER_EVENT_MASK;
|
||||
if (dmxShadowFB) {
|
||||
XLIB_PROLOGUE (&dmxScreens[dmxInput->scrnIdx]);
|
||||
XWarpPointer(priv->display, priv->window, priv->window,
|
||||
0, 0, 0, 0,
|
||||
priv->initPointerX,
|
||||
priv->initPointerY);
|
||||
XLIB_EPILOGUE (&dmxScreens[dmxInput->scrnIdx]);
|
||||
dmxSync(&dmxScreens[dmxInput->scrnIdx], TRUE);
|
||||
}
|
||||
if (!priv->be) {
|
||||
XLIB_PROLOGUE (&dmxScreens[dmxInput->scrnIdx]);
|
||||
XSelectInput(priv->display, priv->window, priv->eventMask);
|
||||
XLIB_EPILOGUE (&dmxScreens[dmxInput->scrnIdx]);
|
||||
AddEnabledDevice(XConnectionNumber(priv->display));
|
||||
} else {
|
||||
dmxPropertyIterate(priv->be, dmxCommonXSelect, priv);
|
||||
}
|
||||
XLIB_PROLOGUE (priv->be);
|
||||
XSelectInput(priv->display, priv->window, priv->eventMask);
|
||||
XLIB_EPILOGUE (priv->be);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
@ -597,7 +564,6 @@ int dmxCommonMouOn(DevicePtr pDev)
|
|||
void dmxCommonMouOff(DevicePtr pDev)
|
||||
{
|
||||
GETPRIVFROMPDEV;
|
||||
GETDMXINPUTFROMPRIV;
|
||||
|
||||
if (dmxLocal->device)
|
||||
{
|
||||
|
|
@ -609,12 +575,10 @@ void dmxCommonMouOff(DevicePtr pDev)
|
|||
else
|
||||
{
|
||||
priv->eventMask &= ~DMX_POINTER_EVENT_MASK;
|
||||
if (!priv->be) {
|
||||
XLIB_PROLOGUE (&dmxScreens[dmxInput->scrnIdx]);
|
||||
if (priv->be) {
|
||||
XLIB_PROLOGUE (priv->be);
|
||||
XSelectInput(priv->display, priv->window, priv->eventMask);
|
||||
XLIB_EPILOGUE (&dmxScreens[dmxInput->scrnIdx]);
|
||||
} else {
|
||||
dmxPropertyIterate(priv->be, dmxCommonXSelect, priv);
|
||||
XLIB_EPILOGUE (priv->be);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,14 +154,6 @@ static DMXLocalInputInfoRec DMXConsoleKbd = {
|
|||
dmxCommonKbdCtrl, dmxCommonKbdBell
|
||||
};
|
||||
|
||||
static DMXLocalInputInfoRec DMXCommonOth = {
|
||||
"common-oth", DMX_LOCAL_OTHER, DMX_LOCAL_TYPE_COMMON, 1,
|
||||
dmxCommonCopyPrivate, NULL,
|
||||
NULL, NULL, NULL, dmxCommonOthGetInfo,
|
||||
dmxCommonOthOn, dmxCommonOthOff
|
||||
};
|
||||
|
||||
|
||||
static DMXLocalInputInfoRec DMXLocalDevices[] = {
|
||||
/* Dummy drivers that can compile on any OS */
|
||||
#ifdef __linux__
|
||||
|
|
@ -805,38 +797,6 @@ static void dmxUpdateWindowInformation(DMXInputInfo *dmxInput,
|
|||
type, pWindow);
|
||||
}
|
||||
|
||||
static void dmxCollectAll(DMXInputInfo *dmxInput)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (dmxInput->detached)
|
||||
return;
|
||||
|
||||
for (i = 0; i < dmxInput->numDevs; i += dmxInput->devs[i]->binding)
|
||||
if (dmxInput->devs[i]->collect_events)
|
||||
dmxInput->devs[i]->collect_events(&dmxInput->devs[i]
|
||||
->pDevice->public,
|
||||
dmxMotion,
|
||||
dmxEnqueue,
|
||||
dmxCheckSpecialKeys, DMX_BLOCK);
|
||||
}
|
||||
|
||||
static void dmxSwitchReturn(pointer p)
|
||||
{
|
||||
DMXInputInfo *dmxInput = p;
|
||||
int i;
|
||||
|
||||
dmxLog(dmxInfo, "Returning from VT %d\n", dmxInput->vt_switched);
|
||||
|
||||
if (!dmxInput->vt_switched)
|
||||
dmxLog(dmxFatal, "dmxSwitchReturn called, but not switched\n");
|
||||
dmxSigioEnableInput();
|
||||
for (i = 0; i < dmxInput->numDevs; i++)
|
||||
if (dmxInput->devs[i]->vt_post_switch)
|
||||
dmxInput->devs[i]->vt_post_switch(dmxInput->devs[i]->private);
|
||||
dmxInput->vt_switched = 0;
|
||||
}
|
||||
|
||||
static char *dmxMakeUniqueDeviceName(DMXLocalInputInfoPtr dmxLocal)
|
||||
{
|
||||
DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
|
||||
|
|
@ -1213,26 +1173,14 @@ void dmxInputInit(DMXInputInfo *dmxInput)
|
|||
int found;
|
||||
|
||||
for (found = 0, i = 0; i < dmxNumScreens; i++) {
|
||||
if ((dmxInput->scrnIdx == -1 &&
|
||||
dmxPropertySameDisplay (&dmxScreens[i], dmxInput->name)) ||
|
||||
dmxInput->scrnIdx == i) {
|
||||
if (dmxScreens[i].shared)
|
||||
{
|
||||
dmxLog(dmxFatal,
|
||||
"Cannot take input from shared backend (%s)\n",
|
||||
name);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *pt;
|
||||
for (pt = (char *)dmxInput->name; pt && *pt; pt++)
|
||||
if (*pt == ',') *pt = '\0';
|
||||
dmxInputCopyLocal(dmxInput, &DMXBackendMou);
|
||||
dmxInputCopyLocal(dmxInput, &DMXBackendKbd);
|
||||
dmxInput->scrnIdx = i;
|
||||
dmxLogInput(dmxInput,
|
||||
"Using backend input from %s at %d\n", name, i);
|
||||
}
|
||||
if (dmxInput->scrnIdx == i) {
|
||||
char *pt;
|
||||
for (pt = (char *)dmxInput->name; pt && *pt; pt++)
|
||||
if (*pt == ',') *pt = '\0';
|
||||
dmxInputCopyLocal(dmxInput, &DMXBackendMou);
|
||||
dmxInputCopyLocal(dmxInput, &DMXBackendKbd);
|
||||
dmxLogInput(dmxInput,
|
||||
"Using backend input from %s at %d\n", name, i);
|
||||
++found;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue