/* Send the appropriate number of button clicks to emulate scroll wheel */ void DarwinSendScrollEvents(double scroll_x, double scroll_y) { ScreenPtr screen; ValuatorMask valuators; if (!darwinEvents) { DEBUG_LOG( "DarwinSendScrollEvents called before darwinEvents was initialized\n"); return; } screen = miPointerGetScreen(darwinPointer); if (!screen) { DEBUG_LOG( "DarwinSendScrollEvents called before screen was initialized\n"); return; } valuator_mask_zero(&valuators); valuator_mask_set_double(&valuators, 4, scroll_y); valuator_mask_set_double(&valuators, 5, scroll_x); darwinEvents_lock(); { QueuePointerEvents(darwinPointer, MotionNotify, 0, POINTER_RELATIVE, &valuators); DarwinPokeEQ(); } darwinEvents_unlock(); }
/* * 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(); }
void DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev) { darwinEvents_lock(); { int i; if (pDev->button) { for (i = 0; i < pDev->button->numButtons; i++) { if (BitIsOn(pDev->button->down, i)) { QueuePointerEvents(pDev, ButtonRelease, i, POINTER_ABSOLUTE, NULL); } } } if (pDev->key) { for (i = 0; i < NUM_KEYCODES; i++) { if (BitIsOn(pDev->key->down, i + MIN_KEYCODE)) { QueueKeyboardEvents(pDev, KeyRelease, i + MIN_KEYCODE); } } } DarwinPokeEQ(); } darwinEvents_unlock(); }
void DarwinSendTabletEvents(DeviceIntPtr pDev, int ev_type, int ev_button, double pointer_x, double pointer_y, double pressure, double tilt_x, double tilt_y) { ScreenPtr screen; ValuatorMask valuators; if (!darwinEvents) { DEBUG_LOG("%s called before darwinEvents was initialized\n", __FUNCTION__); return; } screen = miPointerGetScreen(pDev); if (!screen) { DEBUG_LOG("%s called before screen was initialized\n", __FUNCTION__); return; } /* Fix offset between darwin and X screens */ pointer_x -= darwinMainScreenX + screen->x; pointer_y -= darwinMainScreenY + screen->y; /* Adjust our pointer location to the [0,1] range */ pointer_x = pointer_x / (double)screenInfo.width; pointer_y = pointer_y / (double)screenInfo.height; valuator_mask_zero(&valuators); valuator_mask_set_double(&valuators, 0, XQUARTZ_VALUATOR_LIMIT * pointer_x); valuator_mask_set_double(&valuators, 1, XQUARTZ_VALUATOR_LIMIT * pointer_y); valuator_mask_set_double(&valuators, 2, XQUARTZ_VALUATOR_LIMIT * pressure); valuator_mask_set_double(&valuators, 3, XQUARTZ_VALUATOR_LIMIT * tilt_x); valuator_mask_set_double(&valuators, 4, XQUARTZ_VALUATOR_LIMIT * tilt_y); darwinEvents_lock(); { if (ev_type == ProximityIn || ev_type == ProximityOut) { QueueProximityEvents(pDev, ev_type, &valuators); } else { QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE, &valuators); } DarwinPokeEQ(); } darwinEvents_unlock(); }
void DarwinSendKeyboardEvents(int ev_type, int keycode) { if (!darwinEvents) { DEBUG_LOG( "DarwinSendKeyboardEvents called before darwinEvents was initialized\n"); return; } darwinEvents_lock(); { QueueKeyboardEvents(darwinKeyboard, ev_type, keycode + MIN_KEYCODE); DarwinPokeEQ(); } darwinEvents_unlock(); }
/** * 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(); }
Bool DarwinEQInit(void) { int *p; for (p = darwin_x11_modifier_mask_list; *p; p++) { darwin_x11_modifier_mask |= *p; } darwin_all_modifier_mask = darwin_x11_modifier_mask; for (p = darwin_all_modifier_mask_additions; *p; p++) { darwin_all_modifier_mask |= *p; } mieqInit(); mieqSetHandler(ET_XQuartz, DarwinEventHandler); /* Note that this *could* cause a potential async issue, since we're checking * darwinEvents without holding the lock, but darwinEvents is only ever set * here, so I don't bother. */ if (!darwinEvents) { darwinEvents = InitEventList(GetMaximumEventsNum()); if (!darwinEvents) FatalError("Couldn't allocate event buffer\n"); darwinEvents_lock(); pthread_cond_broadcast(&mieq_ready_cond); darwinEvents_unlock(); } if (!fd_add_tid) fd_add_tid = create_thread(DarwinProcessFDAdditionQueue_thread, NULL); return TRUE; }
void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, double pointer_x, double pointer_y, double pointer_dx, double pointer_dy) { static int darwinFakeMouseButtonDown = 0; ScreenPtr screen; ValuatorMask valuators; if (!darwinEvents) { DEBUG_LOG("%s called before darwinEvents was initialized\n", __FUNCTION__); return; } screen = miPointerGetScreen(pDev); if (!screen) { DEBUG_LOG("%s called before screen was initialized\n", __FUNCTION__); return; } /* Handle fake click */ if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) { if (darwinFakeMouseButtonDown != 0) { /* We're currently "down" with another button, so release it first */ DarwinSendPointerEvents(pDev, ButtonRelease, darwinFakeMouseButtonDown, pointer_x, pointer_y, 0.0, 0.0); darwinFakeMouseButtonDown = 0; } if (darwin_all_modifier_flags & darwinFakeMouse2Mask) { ev_button = 2; darwinFakeMouseButtonDown = 2; DarwinUpdateModKeys( darwin_all_modifier_flags & ~darwinFakeMouse2Mask); } else if (darwin_all_modifier_flags & darwinFakeMouse3Mask) { ev_button = 3; darwinFakeMouseButtonDown = 3; DarwinUpdateModKeys( darwin_all_modifier_flags & ~darwinFakeMouse3Mask); } } if (ev_type == ButtonRelease && ev_button == 1) { if (darwinFakeMouseButtonDown) { ev_button = darwinFakeMouseButtonDown; } if (darwinFakeMouseButtonDown == 2) { DarwinUpdateModKeys( darwin_all_modifier_flags & ~darwinFakeMouse2Mask); } else if (darwinFakeMouseButtonDown == 3) { DarwinUpdateModKeys( darwin_all_modifier_flags & ~darwinFakeMouse3Mask); } darwinFakeMouseButtonDown = 0; } /* Fix offset between darwin and X screens */ pointer_x -= darwinMainScreenX + screen->x; pointer_y -= darwinMainScreenY + screen->y; valuator_mask_zero(&valuators); valuator_mask_set_double(&valuators, 0, pointer_x); valuator_mask_set_double(&valuators, 1, pointer_y); if (ev_type == MotionNotify) { if (pointer_dx != 0.0) valuator_mask_set_double(&valuators, 2, pointer_dx); if (pointer_dy != 0.0) valuator_mask_set_double(&valuators, 3, pointer_dy); } darwinEvents_lock(); { QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE, &valuators); DarwinPokeEQ(); } darwinEvents_unlock(); }