Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 379827 | Differences between
and this patch

Collapse All | Expand All

(-)a/xkb/xkbActions.c (-9 / +73 lines)
Lines 352-376 _XkbFilterLatchState(XkbSrvInfoPtr xkbi, Link Here
352
}
352
}
353
353
354
static int
354
static int
355
_XkbFilterLockState(XkbSrvInfoPtr xkbi,
355
xkbSwitchGroupOnRelease(void)
356
{
357
    /* TODO: user configuring */
358
    return TRUE;
359
}
360
361
static void
362
xkbUpdateLockedGroup(XkbSrvInfoPtr xkbi, XkbAction *pAction)
363
{
364
    XkbGroupAction ga = pAction->group;
365
366
    if (ga.flags & XkbSA_GroupAbsolute)
367
        xkbi->state.locked_group = XkbSAGroup(&ga);
368
    else
369
        xkbi->state.locked_group += XkbSAGroup(&ga);
370
}
371
372
static XkbFilterPtr _XkbNextFreeFilter(XkbSrvInfoPtr xkbi);
373
374
static int
375
_XkbFilterLockGroup(XkbSrvInfoPtr xkbi,
356
                    XkbFilterPtr filter, unsigned keycode, XkbAction *pAction)
376
                    XkbFilterPtr filter, unsigned keycode, XkbAction *pAction)
357
{
377
{
358
    if (filter->keycode == 0) /* initial press */
378
    if (filter->keycode == 0) /* initial press */
359
        AccessXCancelRepeatKey(xkbi, keycode);
379
        AccessXCancelRepeatKey(xkbi, keycode);
360
380
361
    if (pAction && (pAction->type == XkbSA_LockGroup)) {
381
    int sendEvent = 1;
362
        if (pAction->group.flags & XkbSA_GroupAbsolute)
382
363
            xkbi->state.locked_group = XkbSAGroup(&pAction->group);
383
    if (!xkbSwitchGroupOnRelease()) {
364
        else
384
        xkbUpdateLockedGroup(xkbi, pAction);
365
            xkbi->state.locked_group += XkbSAGroup(&pAction->group);
385
        return sendEvent;
366
        return 1;
367
    }
386
    }
387
388
    /* Delay switch till button release */
389
    if (filter->keycode == 0) { /* initial press */
390
        filter->keycode = keycode;
391
        filter->active = 1;
392
        filter->filterOthers = 0;       /* for what? */
393
        filter->filter = _XkbFilterLockGroup;
394
395
        /* filter->priv = 0; */
396
        filter->upAction = *pAction;
397
398
        /* Ok, now we need to simulate the action which would go if this action didn't block it.
399
           XkbSA_SetMods is the one: it is to set modifier' flag up. */
400
        {
401
            XkbStateRec fake_state = xkbi->state;
402
            XkbAction act;
403
404
            fake_state.mods = 0;
405
            act = XkbGetKeyAction(xkbi, &fake_state, keycode);
406
407
            /* KLUDGE: XkbSA_SetMods only? */
408
            if (act.type == XkbSA_SetMods) {
409
                XkbFilterPtr filter = _XkbNextFreeFilter(xkbi);
410
411
                sendEvent = _XkbFilterSetState(xkbi, filter, keycode, &act);
412
            }
413
        }
414
    }
415
    else {
416
        /* do nothing if some button else is pressed */
417
        if (!pAction)
418
            xkbUpdateLockedGroup(xkbi, &filter->upAction);
419
        filter->active = 0;
420
    }
421
422
    return sendEvent;
423
}
424
425
static int
426
_XkbFilterLockMods(XkbSrvInfoPtr xkbi,
427
                   XkbFilterPtr filter, unsigned keycode, XkbAction *pAction)
428
{
368
    if (filter->keycode == 0) { /* initial press */
429
    if (filter->keycode == 0) { /* initial press */
369
        filter->keycode = keycode;
430
        filter->keycode = keycode;
370
        filter->active = 1;
431
        filter->active = 1;
371
        filter->filterOthers = 0;
432
        filter->filterOthers = 0;
372
        filter->priv = xkbi->state.locked_mods & pAction->mods.mask;
433
        filter->priv = xkbi->state.locked_mods & pAction->mods.mask;
373
        filter->filter = _XkbFilterLockState;
434
        filter->filter = _XkbFilterLockMods;
374
        filter->upAction = *pAction;
435
        filter->upAction = *pAction;
375
        if (!(filter->upAction.mods.flags & XkbSA_LockNoLock))
436
        if (!(filter->upAction.mods.flags & XkbSA_LockNoLock))
376
            xkbi->state.locked_mods |= pAction->mods.mask;
437
            xkbi->state.locked_mods |= pAction->mods.mask;
Lines 1250-1258 XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event) Link Here
1250
                sendEvent = _XkbFilterLatchState(xkbi, filter, key, &act);
1311
                sendEvent = _XkbFilterLatchState(xkbi, filter, key, &act);
1251
                break;
1312
                break;
1252
            case XkbSA_LockMods:
1313
            case XkbSA_LockMods:
1314
                filter = _XkbNextFreeFilter(xkbi);
1315
                sendEvent = _XkbFilterLockMods(xkbi, filter, key, &act);
1316
                break;
1253
            case XkbSA_LockGroup:
1317
            case XkbSA_LockGroup:
1254
                filter = _XkbNextFreeFilter(xkbi);
1318
                filter = _XkbNextFreeFilter(xkbi);
1255
                sendEvent = _XkbFilterLockState(xkbi, filter, key, &act);
1319
                sendEvent = _XkbFilterLockGroup(xkbi, filter, key, &act);
1256
                break;
1320
                break;
1257
            case XkbSA_ISOLock:
1321
            case XkbSA_ISOLock:
1258
                filter = _XkbNextFreeFilter(xkbi);
1322
                filter = _XkbNextFreeFilter(xkbi);

Return to bug 379827