/** * Create and init 2 master devices (VCP + VCK) and two slave devices, one * default mouse, one default keyboard. */ struct devices init_devices(void) { ClientRec client; struct devices devices; client = init_client(0, NULL); AllocDevicePair(&client, "Virtual core", &devices.vcp, &devices.vck, CorePointerProc, CoreKeyboardProc, TRUE); inputInfo.pointer = devices.vcp; inputInfo.keyboard = devices.vck; ActivateDevice(devices.vcp, FALSE); ActivateDevice(devices.vck, FALSE); EnableDevice(devices.vcp, FALSE); EnableDevice(devices.vck, FALSE); AllocDevicePair(&client, "", &devices.mouse, &devices.kbd, CorePointerProc, CoreKeyboardProc, FALSE); ActivateDevice(devices.mouse, FALSE); ActivateDevice(devices.kbd, FALSE); EnableDevice(devices.mouse, FALSE); EnableDevice(devices.kbd, FALSE); devices.num_devices = 4; devices.num_master_devices = 2; fake_init_sprite(devices.mouse); fake_init_sprite(devices.vcp); return devices; }
/** * Create and init 2 master devices (VCP + VCK) and two slave devices, one * default mouse, one default keyboard. */ struct devices init_devices(void) { ClientRec client; struct devices local_devices; int ret; /* * Put a unique name in display pointer so that when tests are run in * parallel, their xkbcomp outputs to /tmp/server-<display>.xkm don't * stomp on each other. */ #ifdef HAVE_GETPROGNAME display = getprogname(); #elif HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME display = program_invocation_short_name; #endif client = init_client(0, NULL); AllocDevicePair(&client, "Virtual core", &local_devices.vcp, &local_devices.vck, CorePointerProc, CoreKeyboardProc, TRUE); inputInfo.pointer = local_devices.vcp; inputInfo.keyboard = local_devices.vck; ret = ActivateDevice(local_devices.vcp, FALSE); assert(ret == Success); /* This may fail if xkbcomp fails or xkb-config is not found. */ ret = ActivateDevice(local_devices.vck, FALSE); assert(ret == Success); EnableDevice(local_devices.vcp, FALSE); EnableDevice(local_devices.vck, FALSE); AllocDevicePair(&client, "", &local_devices.mouse, &local_devices.kbd, TestPointerProc, CoreKeyboardProc, FALSE); ret = ActivateDevice(local_devices.mouse, FALSE); assert(ret == Success); ret = ActivateDevice(local_devices.kbd, FALSE); assert(ret == Success); EnableDevice(local_devices.mouse, FALSE); EnableDevice(local_devices.kbd, FALSE); local_devices.num_devices = 4; local_devices.num_master_devices = 2; fake_init_sprite(local_devices.mouse); fake_init_sprite(local_devices.vcp); return local_devices; }
/** * Allocate a device pair that is initialised as a slave * device with properties that identify the devices as belonging * to XTest subsystem. * This only creates the pair, Activate/Enable Device * still need to be called. */ int AllocXTestDevice (ClientPtr client, char* name, DeviceIntPtr* ptr, DeviceIntPtr* keybd, DeviceIntPtr master_ptr, DeviceIntPtr master_keybd) { int retval; int len = strlen(name); char *xtestname = calloc(len + 7, 1 ); char dummy = 1; strncpy( xtestname, name, len); strncat( xtestname, " XTEST", 6 ); retval = AllocDevicePair( client, xtestname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE); if ( retval == Success ){ (*ptr)->xtest_master_id = master_ptr->id; (*keybd)->xtest_master_id = master_keybd->id; XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), XA_INTEGER, 8, PropModeReplace, 1, &dummy, FALSE); XISetDevicePropertyDeletable(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE); XIRegisterPropertyHandler(*ptr, DeviceSetXTestProperty, NULL, NULL); XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), XA_INTEGER, 8, PropModeReplace, 1, &dummy, FALSE); XISetDevicePropertyDeletable(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE); XIRegisterPropertyHandler(*keybd, DeviceSetXTestProperty, NULL, NULL); } free( xtestname ); return retval; }
/* See Porting Layer Definition - p. 17 */ void InitInput(int argc, char *argv[]) { #if CYGDEBUG winDebug("InitInput\n"); #endif #ifdef XWIN_CLIPBOARD /* * Wrap some functions at every generation of the server. */ if (InitialVector[2] != winProcEstablishConnection) { winProcEstablishConnectionOrig = InitialVector[2]; InitialVector[2] = winProcEstablishConnection; } #endif if (AllocDevicePair(serverClient, "Windows", &g_pwinPointer, &g_pwinKeyboard, winMouseProc, winKeybdProc, FALSE) != Success) FatalError("InitInput - Failed to allocate slave devices.\n"); mieqInit(); /* Initialize the mode key states */ winInitializeModeKeyStates(); #ifdef HAS_DEVWINDOWS /* Only open the windows message queue device once */ if (g_fdMessageQueue == WIN_FD_INVALID) { /* Open a file descriptor for the Windows message queue */ g_fdMessageQueue = open(WIN_MSG_QUEUE_FNAME, O_RDONLY); if (g_fdMessageQueue == -1) { FatalError("InitInput - Failed opening %s\n", WIN_MSG_QUEUE_FNAME); } /* Add the message queue as a device to wait for in WaitForSomething */ SetNotifyFd(g_fdMessageQueue, xwinDevWindowsHandlerNotify, X_NOTIFY_READ, NULL); } #endif #if CYGDEBUG winDebug("InitInput - returning\n"); #endif }
void InitInput(int argc, char *argv[]) { int rc; rc = AllocDevicePair(serverClient, "Xnest", &xnestPointerDevice, &xnestKeyboardDevice, xnestPointerProc, xnestKeyboardProc, FALSE); if (rc != Success) FatalError("Failed to init Xnest default devices.\n"); mieqInit(); AddEnabledDevice(XConnectionNumber(xnestDisplay)); RegisterBlockAndWakeupHandlers(xnestBlockHandler, xnestWakeupHandler, NULL); }
/** * Allocate a device pair that is initialised as a slave * device with properties that identify the devices as belonging * to XTest subsystem. * This only creates the pair, Activate/Enable Device * still need to be called. */ int AllocXTestDevice(ClientPtr client, const char *name, DeviceIntPtr *ptr, DeviceIntPtr *keybd, DeviceIntPtr master_ptr, DeviceIntPtr master_keybd) { int retval; char *xtestname; char dummy = 1; if (asprintf(&xtestname, "%s XTEST", name) == -1) return BadAlloc; retval = AllocDevicePair(client, xtestname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE); if (retval == Success) { (*ptr)->xtest_master_id = master_ptr->id; (*keybd)->xtest_master_id = master_keybd->id; XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), XA_INTEGER, 8, PropModeReplace, 1, &dummy, FALSE); XISetDevicePropertyDeletable(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE); XIRegisterPropertyHandler(*ptr, DeviceSetXTestProperty, NULL, NULL); XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), XA_INTEGER, 8, PropModeReplace, 1, &dummy, FALSE); XISetDevicePropertyDeletable(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE); XIRegisterPropertyHandler(*keybd, DeviceSetXTestProperty, NULL, NULL); } free(xtestname); return retval; }
static int add_master(ClientPtr client, xXIAddMasterInfo *c, int flags[MAXDEVICES]) { DeviceIntPtr ptr, keybd, XTestptr, XTestkeybd; char* name; int rc; name = calloc(c->name_len + 1, sizeof(char)); strncpy(name, (char*)&c[1], c->name_len); rc = AllocDevicePair(client, name, &ptr, &keybd, CorePointerProc, CoreKeyboardProc, TRUE); if (rc != Success) goto unwind; if (!c->send_core) ptr->coreEvents = keybd->coreEvents = FALSE; /* Allocate virtual slave devices for xtest events */ rc = AllocXTestDevice(client, name, &XTestptr, &XTestkeybd, ptr, keybd); if (rc != Success) { DeleteInputDeviceRequest(ptr); DeleteInputDeviceRequest(keybd); goto unwind; } ActivateDevice(ptr, FALSE); ActivateDevice(keybd, FALSE); flags[ptr->id] |= XIMasterAdded; flags[keybd->id] |= XIMasterAdded; ActivateDevice(XTestptr, FALSE); ActivateDevice(XTestkeybd, FALSE); flags[XTestptr->id] |= XISlaveAdded; flags[XTestkeybd->id] |= XISlaveAdded; if (c->enable) { EnableDevice(ptr, FALSE); EnableDevice(keybd, FALSE); flags[ptr->id] |= XIDeviceEnabled; flags[keybd->id] |= XIDeviceEnabled; EnableDevice(XTestptr, FALSE); EnableDevice(XTestkeybd, FALSE); flags[XTestptr->id] |= XIDeviceEnabled; flags[XTestkeybd->id] |= XIDeviceEnabled; } /* Attach the XTest virtual devices to the newly created master device */ AttachDevice(NULL, XTestptr, ptr); AttachDevice(NULL, XTestkeybd, keybd); flags[XTestptr->id] |= XISlaveAttached; flags[XTestkeybd->id] |= XISlaveAttached; unwind: free(name); return rc; }