Esempio n. 1
0
void
XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
{
    EventListPtr        events;
    int                 nevents, i;
    DeviceIntPtr        ptr;

    /* If dev is a slave device, and the SD is attached, do nothing. If we'd
     * post through the attached master pointer we'd get duplicate events.
     *
     * if dev is a master keyboard, post through the XTEST device
     *
     * if dev is a floating slave, post through the device itself.
     */

    if (IsMaster(dev))
        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
    else if (!dev->u.master)
        ptr = dev;
    else
        return;

    events = InitEventList(GetMaximumEventsNum());
    OsBlockSignals();
    nevents = GetPointerEvents(events, ptr,
                               press ? ButtonPress : ButtonRelease, button,
                               0 /* flags */, 0 /* first */,
                               0 /* num_val */, NULL);
    OsReleaseSignals();

    for (i = 0; i < nevents; i++)
        mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);

    FreeEventList(events, GetMaximumEventsNum());
}
Esempio n. 2
0
static void sighandler(int signal)
{
    assert(expect_signal);
    expect_signal = 0;
    if (!last_signal)
        raise(signal);
    OsBlockSignals();
    OsReleaseSignals();
    last_signal = 1;
    expect_signal = 1;
}
Esempio n. 3
0
static void
remove_device(DeviceIntPtr dev)
{
    DebugF("[config/hal] removing device %s\n", dev->name);

    /* Call PIE here so we don't try to dereference a device that's
     * already been removed. */
    OsBlockSignals();
    ProcessInputEvents();
    DeleteInputDeviceRequest(dev);
    OsReleaseSignals();
}
Esempio n. 4
0
static void
remove_device(DeviceIntPtr dev)
{
    /* this only gets called for devices that have already been added */
    LogMessage(X_INFO, "config/hal: removing device %s\n", dev->name);

    /* Call PIE here so we don't try to dereference a device that's
     * already been removed. */
    OsBlockSignals();
    ProcessInputEvents();
    DeleteInputDeviceRequest(dev);
    OsReleaseSignals();
}
Esempio n. 5
0
static int
remove_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
{
    int deviceid, ret, err;
    DeviceIntPtr dev;
    DBusMessageIter iter, reply_iter;

    dbus_message_iter_init_append(reply, &reply_iter);

    if (!dbus_message_iter_init(message, &iter)) {
        ErrorF("[config/dbus] failed to init iterator\n");
        MALFORMED_MESSAGE();
    }

    if (!dbus_message_get_args(message, error, DBUS_TYPE_UINT32,
                               &deviceid, DBUS_TYPE_INVALID)) {
        MALFORMED_MESSAGE_ERROR();
    }

    dev = LookupDeviceIntRec(deviceid);
    if (!dev) {
        DebugF("[config/dbus] bogus device id %d given\n", deviceid);
        ret = BadMatch;
        goto unwind;
    }

    DebugF("[config/dbus] removing device %s (id %d)\n", dev->name, deviceid);

    /* Call PIE here so we don't try to dereference a device that's
     * already been removed. */
    OsBlockSignals();
    ProcessInputEvents();
    DeleteInputDeviceRequest(dev);
    OsReleaseSignals();

    ret = Success;

unwind:
    err = (ret == Success) ? ret : -ret;
    dbus_message_iter_append_basic(&reply_iter, DBUS_TYPE_INT32, &err);

    return ret;
}
Esempio n. 6
0
/**
 *  Uninit scheme
 */
void
AccelerationDefaultCleanup(DeviceIntPtr dev)
{
    DeviceVelocityPtr vel = GetDevicePredictableAccelData(dev);
    if (vel) {
        /* the proper guarantee would be that we're not inside of
         * AccelSchemeProc(), but that seems impossible. Schemes don't get
         * switched often anyway.
         */
        OsBlockSignals();
        dev->valuator->accelScheme.AccelSchemeProc = NULL;
        FreeVelocityData(vel);
        free(vel);
        DeletePredictableAccelerationProperties(dev,
            (PredictableAccelSchemePtr) dev->valuator->accelScheme.accelData);
        free(dev->valuator->accelScheme.accelData);
        dev->valuator->accelScheme.accelData = NULL;
        OsReleaseSignals();
    }
}
Esempio n. 7
0
/**
 * 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();
}
Esempio n. 8
0
/**
Initialize a filter chain.
Expected result is a series of filters, each progressively more integrating.

This allows for two strategies: Either you have one filter which is reasonable
and is being coupled to account for fast-changing input, or you have 'one for
every situation'. You might want to have tighter coupling then, e.g. 0.1.
In the filter stats, you can see if a reasonable filter useage emerges.
*/
void
InitFilterChain(DeviceVelocityPtr s, float rdecay, float progression, int stages, int lutsize)
{
    int fn;
    if((stages > 1 && progression < 1.0f) || 0 == progression){
	ErrorF("(dix ptracc) invalid filter chain progression specified\n");
	return;
    }
    /* Block here to support runtime filter adjustment */
    OsBlockSignals();
    for(fn = 0; fn < MAX_VELOCITY_FILTERS; fn++){
	if(fn < stages){
	    InitFilterStage(&s->filters[fn], rdecay, lutsize);
	}else{
	    InitFilterStage(&s->filters[fn], 0, 0);
	}
	rdecay /= progression;
    }
    /* release again. Should the input loop be threaded, we also need
     * memory release here (in principle).
     */
    OsReleaseSignals();
}
Esempio n. 9
0
/**
 * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC1 are
 * unset.  EDID information blocks are interpreted and the results returned in
 * an xf86MonPtr.
 *
 * This function does not affect the list of modes used by drivers -- it is up
 * to the driver to decide policy on what to do with EDID information.
 *
 * @return pointer to a new xf86MonPtr containing the EDID information.
 * @return NULL if no monitor attached or failure to interpret the EDID.
 */
xf86MonPtr
xf86DoEDID_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDC1SetSpeed,
                unsigned int (*DDC1Read) (ScrnInfoPtr))
{
    unsigned char *EDID_block = NULL;
    xf86MonPtr tmp = NULL;

    /* Default DDC and DDC1 to enabled. */
    Bool noddc = FALSE, noddc1 = FALSE;
    OptionInfoPtr options;

    options = xnfalloc(sizeof(DDCOptions));
    (void) memcpy(options, DDCOptions, sizeof(DDCOptions));
    xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);

    xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
    xf86GetOptValBool(options, DDCOPT_NODDC1, &noddc1);
    free(options);

    if (noddc || noddc1)
        return NULL;

    OsBlockSignals();
    EDID_block = EDIDRead_DDC1(pScrn, DDC1SetSpeed, DDC1Read);
    OsReleaseSignals();

    if (EDID_block) {
        tmp = xf86InterpretEDID(pScrn->scrnIndex, EDID_block);
    }
#ifdef DEBUG
    else
        ErrorF("No EDID block returned\n");
    if (!tmp)
        ErrorF("Cannot interpret EDID block\n");
#endif
    return tmp;
}
Esempio n. 10
0
static void block_sigio_test(void)
{
#ifdef SIG_BLOCK
    sigset_t current;

    sigemptyset(&current);
    assert(!sig_is_blocked(SIGIO));

    /* block once */
    OsBlockSIGIO();
    assert(sig_is_blocked(SIGIO));
    OsReleaseSIGIO();
    assert(!sig_is_blocked(SIGIO));

    /* block twice, nested */
    OsBlockSIGIO();
    assert(sig_is_blocked(SIGIO));
    OsBlockSIGIO();
    assert(sig_is_blocked(SIGIO));
    OsReleaseSIGIO();
    assert(sig_is_blocked(SIGIO));
    OsReleaseSIGIO();
    assert(!sig_is_blocked(SIGIO));

    /* block all */
    OsBlockSignals();
    assert(sig_is_blocked(SIGIO));
    OsReleaseSignals();
    assert(!sig_is_blocked(SIGIO));

    /* block all nested */
    OsBlockSignals();
    assert(sig_is_blocked(SIGIO));
    OsBlockSignals();
    assert(sig_is_blocked(SIGIO));
    OsReleaseSignals();
    assert(sig_is_blocked(SIGIO));
    OsReleaseSignals();
    assert(!sig_is_blocked(SIGIO));

    /* mix the two */
    /* ABBA */
    OsBlockSignals();
    assert(sig_is_blocked(SIGIO));
    OsBlockSIGIO();
    assert(sig_is_blocked(SIGIO));
    OsReleaseSIGIO();
    assert(sig_is_blocked(SIGIO));
    OsReleaseSignals();
    assert(!sig_is_blocked(SIGIO));

    /* ABAB */
    OsBlockSignals();
    assert(sig_is_blocked(SIGIO));
    OsBlockSIGIO();
    assert(sig_is_blocked(SIGIO));
    OsReleaseSignals();
    assert(sig_is_blocked(SIGIO));
    OsReleaseSIGIO();
    assert(!sig_is_blocked(SIGIO));

    /* BAAB */
    OsBlockSIGIO();
    assert(sig_is_blocked(SIGIO));
    OsBlockSignals();
    assert(sig_is_blocked(SIGIO));
    OsReleaseSignals();
    assert(sig_is_blocked(SIGIO));
    OsReleaseSIGIO();
    assert(!sig_is_blocked(SIGIO));

    /* BABA */
    OsBlockSIGIO();
    assert(sig_is_blocked(SIGIO));
    OsBlockSignals();
    assert(sig_is_blocked(SIGIO));
    OsReleaseSIGIO();
    assert(sig_is_blocked(SIGIO));
    OsReleaseSignals();
    assert(!sig_is_blocked(SIGIO));
#endif
}