diff options
-rw-r--r-- | src/client.h | 4 | ||||
-rw-r--r-- | src/driver.c | 29 | ||||
-rw-r--r-- | src/input.c | 57 | ||||
-rw-r--r-- | src/xlibclient.c | 7 |
4 files changed, 56 insertions, 41 deletions
diff --git a/src/client.h b/src/client.h index c4f171e..6a652f1 100644 --- a/src/client.h +++ b/src/client.h @@ -62,8 +62,10 @@ void NestedClientUpdateScreen(NestedClientPrivatePtr pPriv, void NestedClientHideCursor(NestedClientPrivatePtr pPriv); -void NestedClientTimerCallback(NestedClientPrivatePtr pPriv); +void NestedClientCheckEvents(NestedClientPrivatePtr pPriv); void NestedClientCloseScreen(NestedClientPrivatePtr pPriv); void NestedClientSetDevicePtr(NestedClientPrivatePtr pPriv, DeviceIntPtr dev); + +int NestedClientGetFileDescriptor(NestedClientPrivatePtr pPriv); diff --git a/src/driver.c b/src/driver.c index 90f09cb..eb4c208 100644 --- a/src/driver.c +++ b/src/driver.c @@ -84,7 +84,8 @@ static void *NestedShadowWindow(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, CARD32 *size, void *closure); static Bool NestedCloseScreen(int scrnIndex, ScreenPtr pScreen); -static CARD32 NestedTimerCallback(OsTimerPtr timer, CARD32 time, pointer arg); +static void NestedBlockHandler(pointer data, OSTimePtr wt, pointer LastSelectMask); +static void NestedWakeupHandler(pointer data, int i, pointer LastSelectMask); int NestedValidateModes(ScrnInfoPtr pScrn); Bool NestedAddMode(ScrnInfoPtr pScrn, int width, int height); @@ -166,7 +167,6 @@ typedef struct NestedPrivate { NestedClientPrivatePtr clientData; CreateScreenResourcesProcPtr CreateScreenResources; CloseScreenProcPtr CloseScreen; - OsTimerPtr timer; ShadowUpdateProc update; /*ShadowWindowProc window;*/ } NestedPrivate, *NestedPrivatePtr; @@ -531,6 +531,16 @@ NestedMouseTimer(OsTimerPtr timer, CARD32 time, pointer arg) { return 0; } +static void +NestedBlockHandler(pointer data, OSTimePtr wt, pointer LastSelectMask) { + NestedClientPrivatePtr pNestedClient = data; + NestedClientCheckEvents(pNestedClient); +} + +static void +NestedWakeupHandler(pointer data, int i, pointer LastSelectMask) { +} + /* Called at each server generation */ static Bool NestedScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { @@ -566,6 +576,8 @@ static Bool NestedScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, return FALSE; } + // Schedule the NestedInputLoadDriver function to load once the + // input core is initialized. TimerSet(NULL, 0, 1, NestedMouseTimer, pNested->clientData); miClearVisualTypes(); @@ -606,10 +618,7 @@ static Bool NestedScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, pNested->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = NestedCloseScreen; - // Schedule the NestedInputLoadDriver function to load once the - // input core is initialized. - pNested->timer = TimerSet(NULL, 0, TIMER_CALLBACK_INTERVAL, - NestedTimerCallback, (pointer)pScrn); + RegisterBlockAndWakeupHandlers(NestedBlockHandler, NestedWakeupHandler, pNested->clientData); return TRUE; } @@ -645,19 +654,13 @@ NestedCloseScreen(int scrnIndex, ScreenPtr pScreen) { shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen)); - TimerFree(PNESTED(pScrn)->timer); + RemoveBlockAndWakeupHandlers(NestedBlockHandler, NestedWakeupHandler, PNESTED(pScrn)->clientData); NestedClientCloseScreen(PCLIENTDATA(pScrn)); pScreen->CloseScreen = PNESTED(pScrn)->CloseScreen; return (*pScreen->CloseScreen)(scrnIndex, pScreen); } -static CARD32 NestedTimerCallback(OsTimerPtr timer, CARD32 time, pointer arg) { - ScrnInfoPtr pScrn = (ScrnInfoPtr) arg; - NestedClientTimerCallback(PCLIENTDATA(pScrn)); - return TIMER_CALLBACK_INTERVAL; -} - static void *NestedShadowWindow(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, CARD32 *size, void *closure) { xf86DrvMsg(pScreen->myNum, X_INFO, "NestedShadowWindow\n"); diff --git a/src/input.c b/src/input.c index cb5cd5d..1286d08 100644 --- a/src/input.c +++ b/src/input.c @@ -74,7 +74,7 @@ static int _nested_input_init_axes(DeviceIntPtr device); typedef struct _NestedInputDeviceRec { - char *device; + NestedClientPrivatePtr clientData; int version; } NestedInputDeviceRec, *NestedInputDevicePtr; @@ -113,27 +113,6 @@ NestedInputPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) { pInfo->switch_mode = NULL; // Toggle absolute/relative mode. pInfo->device_control = NestedInputControl; // Enable/disable device. - // Process driver specific options. - pNestedInput->device = xf86SetStrOption(pInfo->options, - "Device", - "/dev/null"); - - xf86Msg(X_INFO, "%s: Using device %s.\n", pInfo->name, pNestedInput->device); - - // Open sockets, init device files, etc. - SYSCALL(pInfo->fd = open(pNestedInput->device, O_RDWR | O_NONBLOCK)); - - if (pInfo->fd == -1) { - xf86Msg(X_ERROR, "%s: failed to open %s.", - pInfo->name, pNestedInput->device); - - pInfo->private = NULL; - - free(pNestedInput); - - return BadValue; - } - return Success; } @@ -202,6 +181,21 @@ _nested_input_init_axes(DeviceIntPtr device) { return Success; } +static CARD32 +nested_input_on(OsTimerPtr timer, CARD32 time, pointer arg) { + DeviceIntPtr device = arg; + InputInfoPtr pInfo = device->public.devicePrivate; + NestedInputDevicePtr pNestedInput = pInfo->private; + + if(device->public.on) + { + pInfo->fd = NestedClientGetFileDescriptor(pNestedInput->clientData); + xf86FlushInput(pInfo->fd); + xf86AddEnabledDevice(pInfo); + } + return 0; +} + static int NestedInputControl(DeviceIntPtr device, int what) { InputInfoPtr pInfo = device->public.devicePrivate; @@ -217,11 +211,9 @@ NestedInputControl(DeviceIntPtr device, int what) { if (device->public.on) break; - - xf86FlushInput(pInfo->fd); - xf86AddEnabledDevice(pInfo); - + device->public.on = TRUE; + TimerSet(NULL, 0, 1, nested_input_on, device); break; case DEVICE_OFF: xf86Msg(X_INFO, "%s: Off.\n", pInfo->name); @@ -241,8 +233,17 @@ NestedInputControl(DeviceIntPtr device, int what) { return Success; } +static CARD32 +nested_input_ready(OsTimerPtr timer, CARD32 time, pointer arg) { + NestedClientPrivatePtr clientData = arg; + NestedClientCheckEvents(clientData); + return 0; +} + static void NestedInputReadInput(InputInfoPtr pInfo) { + NestedInputDevicePtr pNestedInput = pInfo->private; + TimerSet(NULL, 0, 1, nested_input_ready, pNestedInput->clientData); } void @@ -272,6 +273,10 @@ NestedInputLoadDriver(NestedClientPrivatePtr clientData) { // Send the device to the client so that the client can send the // device back to the input driver when events are being posted. NestedClientSetDevicePtr(clientData, dev); + + InputInfoPtr pInfo = dev->public.devicePrivate; + NestedInputDevicePtr pNestedInput = pInfo->private; + pNestedInput->clientData = clientData; } void diff --git a/src/xlibclient.c b/src/xlibclient.c index a849253..d19d541 100644 --- a/src/xlibclient.c +++ b/src/xlibclient.c @@ -267,7 +267,7 @@ NestedClientUpdateScreen(NestedClientPrivatePtr pPriv, int16_t x1, } void -NestedClientTimerCallback(NestedClientPrivatePtr pPriv) { +NestedClientCheckEvents(NestedClientPrivatePtr pPriv) { XEvent ev; while(XCheckMaskEvent(pPriv->display, ~0, &ev)) { @@ -328,3 +328,8 @@ void NestedClientSetDevicePtr(NestedClientPrivatePtr pPriv, DeviceIntPtr dev) { pPriv->dev = dev; } + +int +NestedClientGetFileDescriptor(NestedClientPrivatePtr pPriv) { + return ConnectionNumber(pPriv->display); +} |