/* * DarwinSendDDXEvent * Send the X server thread a message by placing it on the event queue. */ void DarwinSendDDXEvent(int type, int argc, ...) { XQuartzEvent e; int i; va_list args; memset(&e, 0, sizeof(e)); e.header = ET_Internal; e.type = ET_XQuartz; e.length = sizeof(e); e.time = GetTimeInMillis(); e.subtype = type; if (argc > 0 && argc < XQUARTZ_EVENT_MAXARGS) { va_start(args, argc); for (i = 0; i < argc; i++) e.data[i] = (uint32_t)va_arg(args, uint32_t); va_end(args); } darwinEvents_lock(); { mieqEnqueue(NULL, (InternalEvent *)&e); DarwinPokeEQ(); } darwinEvents_unlock(); }
static void xf86ReleaseKeys(DeviceIntPtr pDev) { KeyClassPtr keyc; int i, j, nevents, sigstate; if (!pDev || !pDev->key) return; keyc = pDev->key; /* * Hmm... here is the biggest hack of every time ! * It may be possible that a switch-vt procedure has finished BEFORE * you released all keys neccessary to do this. That peculiar behavior * can fool the X-server pretty much, cause it assumes that some keys * were not released. TWM may stuck alsmost completly.... * OK, what we are doing here is after returning from the vt-switch * exeplicitely unrelease all keyboard keys before the input-devices * are reenabled. */ for (i = keyc->xkbInfo->desc->min_key_code; i < keyc->xkbInfo->desc->max_key_code; i++) { if (KeyPressed(i)) { sigstate = xf86BlockSIGIO (); nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i); for (j = 0; j < nevents; j++) mieqEnqueue(pDev, (InternalEvent*)(xf86Events + j)->event); xf86UnblockSIGIO(sigstate); } } }
void winMouseButtonsSendEvent (int iEventType, int iButton) { xEvent xCurrentEvent; /* Load an xEvent and enqueue the event */ xCurrentEvent.u.u.type = iEventType; xCurrentEvent.u.u.detail = iButton; xCurrentEvent.u.keyButtonPointer.time = g_c32LastInputEventTime = GetTickCount (); mieqEnqueue (&xCurrentEvent); }
void rdpEnqueueKey(int type, int scancode) { int i; int n; EventListPtr rdp_events; xEvent *pev; i = GetEventList(&rdp_events); n = GetKeyboardEvents(rdp_events, g_keyboard, type, scancode); for (i = 0; i < n; i++) { pev = (rdp_events + i)->event; mieqEnqueue(g_keyboard, (InternalEvent *)pev); } }
void winMouseButtonsSendEvent (int iEventType, int iButton) { xEvent xCurrentEvent; /* Load an xEvent and enqueue the event */ xCurrentEvent.u.u.type = iEventType; #if defined(XFree86Server) if (g_winMouseButtonMap) xCurrentEvent.u.u.detail = g_winMouseButtonMap[iButton]; else #endif xCurrentEvent.u.u.detail = iButton; xCurrentEvent.u.keyButtonPointer.time = g_c32LastInputEventTime = GetTickCount (); mieqEnqueue (&xCurrentEvent); }
/** * Enqueue a motion event. * * XXX: miPointerMove does exactly this, but is static :-( (and uses a static buffer) * */ void winEnqueueMotion(int x, int y) { int i, nevents; int valuators[2]; EventListPtr events; miPointerSetPosition(g_pwinPointer, &x, &y); valuators[0] = x; valuators[1] = y; GetEventList(&events); nevents = GetPointerEvents(events, g_pwinPointer, MotionNotify, 0, POINTER_ABSOLUTE | POINTER_SCREEN, 0, 2, valuators); for (i = 0; i < nevents; i++) mieqEnqueue(g_pwinPointer, events[i].event); }
/** * Move the device's pointer to the x/y coordinates on the given screen. * This function generates and enqueues pointer events. * * @param pDev The device to move * @param pScreen The screen the device is on * @param x The x coordinate in per-screen coordinates * @param y The y coordinate in per-screen coordinates */ void miPointerMove (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) { int i, nevents; int valuators[2]; ValuatorMask mask; miPointerMoveNoEvent(pDev, pScreen, x, y); /* generate motion notify */ valuators[0] = x; valuators[1] = y; if (!events) { events = InitEventList(GetMaximumEventsNum()); if (!events) { FatalError("Could not allocate event store.\n"); return; } } valuator_mask_set_range(&mask, 0, 2, valuators); nevents = GetPointerEvents(events, pDev, MotionNotify, 0, POINTER_SCREEN | POINTER_ABSOLUTE | POINTER_NORAW, &mask); OsBlockSignals(); #ifdef XQUARTZ darwinEvents_lock(); #endif for (i = 0; i < nevents; i++) mieqEnqueue(pDev, &events[i]); #ifdef XQUARTZ darwinEvents_unlock(); #endif OsReleaseSignals(); }
void winSendKeyEvent (DWORD dwKey, Bool fDown) { xEvent xCurrentEvent; /* * When alt-tabing between screens we can get phantom key up messages * Here we only pass them through it we think we should! */ if (g_winKeyState[dwKey] == FALSE && fDown == FALSE) return; /* Update the keyState map */ g_winKeyState[dwKey] = fDown; ZeroMemory (&xCurrentEvent, sizeof (xCurrentEvent)); xCurrentEvent.u.u.type = fDown ? KeyPress : KeyRelease; xCurrentEvent.u.keyButtonPointer.time = g_c32LastInputEventTime = GetTickCount (); xCurrentEvent.u.u.detail = dwKey + MIN_KEYCODE; mieqEnqueue (&xCurrentEvent); }
void winMouseButtonsSendEvent (int iEventType, int iButton) { EventListPtr events; int i, nevents; #if defined(XFree86Server) if (g_winMouseButtonMap) iButton = g_winMouseButtonMap[iButton]; #endif GetEventList(&events); nevents = GetPointerEvents(events, g_pwinPointer, iEventType, iButton, POINTER_RELATIVE, 0, 0, NULL); for (i = 0; i < nevents; i++) mieqEnqueue(g_pwinPointer, events[i].event); #if CYGDEBUG ErrorF("winMouseButtonsSendEvent: iEventType: %d, iButton: %d, nEvents %d\n", iEventType, iButton, nevents); #endif }
/* Handle the mouse wheel */ int winMouseWheel (ScreenPtr pScreen, int iDeltaZ) { winScreenPriv(pScreen); xEvent xCurrentEvent; /* Button4 = WheelUp */ /* Button5 = WheelDown */ /* Do we have any previous delta stored? */ if ((pScreenPriv->iDeltaZ > 0 && iDeltaZ > 0) || (pScreenPriv->iDeltaZ < 0 && iDeltaZ < 0)) { /* Previous delta and of same sign as current delta */ iDeltaZ += pScreenPriv->iDeltaZ; pScreenPriv->iDeltaZ = 0; } else { /* * Previous delta of different sign, or zero. * We will set it to zero for either case, * as blindly setting takes just as much time * as checking, then setting if necessary :) */ pScreenPriv->iDeltaZ = 0; } /* * Only process this message if the wheel has moved further than * WHEEL_DELTA */ if (iDeltaZ >= WHEEL_DELTA || (-1 * iDeltaZ) >= WHEEL_DELTA) { pScreenPriv->iDeltaZ = 0; /* Figure out how many whole deltas of the wheel we have */ iDeltaZ /= WHEEL_DELTA; } else { /* * Wheel has not moved past WHEEL_DELTA threshold; * we will store the wheel delta until the threshold * has been reached. */ pScreenPriv->iDeltaZ = iDeltaZ; return 0; } /* Set the button to indicate up or down wheel delta */ if (iDeltaZ > 0) { xCurrentEvent.u.u.detail = Button4; } else { xCurrentEvent.u.u.detail = Button5; } /* * Flip iDeltaZ to positive, if negative, * because always need to generate a *positive* number of * button clicks for the Z axis. */ if (iDeltaZ < 0) { iDeltaZ *= -1; } /* Generate X input messages for each wheel delta we have seen */ while (iDeltaZ--) { /* Push the wheel button */ xCurrentEvent.u.u.type = ButtonPress; xCurrentEvent.u.keyButtonPointer.time = g_c32LastInputEventTime = GetTickCount (); mieqEnqueue (&xCurrentEvent); /* Release the wheel button */ xCurrentEvent.u.u.type = ButtonRelease; xCurrentEvent.u.keyButtonPointer.time = g_c32LastInputEventTime = GetTickCount (); mieqEnqueue (&xCurrentEvent); } return 0; }