Lines 325-348
_XkbFilterLatchState( XkbSrvInfoPtr xkbi,
Link Here
|
325 |
return 1; |
325 |
return 1; |
326 |
} |
326 |
} |
327 |
|
327 |
|
|
|
328 |
static int xkbSwitchGroupOnRelease(void) |
329 |
{ |
330 |
/* TODO: user configuring */ |
331 |
return TRUE; |
332 |
} |
333 |
|
334 |
static void xkbUpdateLockedGroup(XkbSrvInfoPtr xkbi, XkbAction* pAction) |
335 |
{ |
336 |
XkbGroupAction ga = pAction->group; |
337 |
if (ga.flags&XkbSA_GroupAbsolute) |
338 |
xkbi->state.locked_group= XkbSAGroup(&ga); |
339 |
else xkbi->state.locked_group+= XkbSAGroup(&ga); |
340 |
} |
341 |
|
342 |
static XkbFilterPtr _XkbNextFreeFilter(XkbSrvInfoPtr xkbi); |
343 |
|
328 |
static int |
344 |
static int |
329 |
_XkbFilterLockState( XkbSrvInfoPtr xkbi, |
345 |
_XkbFilterLockGroup( XkbSrvInfoPtr xkbi, |
330 |
XkbFilterPtr filter, |
346 |
XkbFilterPtr filter, |
331 |
unsigned keycode, |
347 |
unsigned keycode, |
332 |
XkbAction * pAction) |
348 |
XkbAction * pAction) |
333 |
{ |
349 |
{ |
334 |
if (pAction&&(pAction->type==XkbSA_LockGroup)) { |
350 |
int sendEvent = 1; |
335 |
if (pAction->group.flags&XkbSA_GroupAbsolute) |
351 |
|
336 |
xkbi->state.locked_group= XkbSAGroup(&pAction->group); |
352 |
if (!xkbSwitchGroupOnRelease()) { |
337 |
else xkbi->state.locked_group+= XkbSAGroup(&pAction->group); |
353 |
xkbUpdateLockedGroup(xkbi, pAction); |
338 |
return 1; |
354 |
return sendEvent; |
|
|
355 |
} |
356 |
|
357 |
/* Delay switch till button release */ |
358 |
if (filter->keycode==0) { /* initial press */ |
359 |
filter->keycode = keycode; |
360 |
filter->active = 1; |
361 |
filter->filterOthers = 0; /* for what? */ |
362 |
filter->filter = _XkbFilterLockGroup; |
363 |
|
364 |
/* filter->priv = 0; */ |
365 |
filter->upAction = *pAction; |
366 |
|
367 |
/* Ok, now we need to simulate the action which would go if this action didn't block it. |
368 |
XkbSA_SetMods is the one: it is to set modifier' flag up. */ |
369 |
{ |
370 |
XkbStateRec fake_state = xkbi->state; |
371 |
XkbAction act; |
372 |
|
373 |
fake_state.mods = 0; |
374 |
act = XkbGetKeyAction(xkbi, &fake_state, keycode); |
375 |
|
376 |
/* KLUDGE: XkbSA_SetMods only? */ |
377 |
if (act.type == XkbSA_SetMods) { |
378 |
XkbFilterPtr filter = _XkbNextFreeFilter(xkbi); |
379 |
sendEvent = _XkbFilterSetState(xkbi,filter,keycode,&act); |
380 |
} |
381 |
} |
339 |
} |
382 |
} |
|
|
383 |
else { |
384 |
/* do nothing if some button else is pressed */ |
385 |
if (!pAction) |
386 |
xkbUpdateLockedGroup(xkbi, &filter->upAction); |
387 |
filter->active = 0; |
388 |
} |
389 |
|
390 |
return sendEvent; |
391 |
} |
392 |
|
393 |
static int |
394 |
_XkbFilterLockMods( XkbSrvInfoPtr xkbi, |
395 |
XkbFilterPtr filter, |
396 |
unsigned keycode, |
397 |
XkbAction * pAction) |
398 |
{ |
340 |
if (filter->keycode==0) { /* initial press */ |
399 |
if (filter->keycode==0) { /* initial press */ |
341 |
filter->keycode = keycode; |
400 |
filter->keycode = keycode; |
342 |
filter->active = 1; |
401 |
filter->active = 1; |
343 |
filter->filterOthers = 0; |
402 |
filter->filterOthers = 0; |
344 |
filter->priv = 0; |
403 |
filter->priv = 0; |
345 |
filter->filter = _XkbFilterLockState; |
404 |
filter->filter = _XkbFilterLockMods; |
346 |
filter->upAction = *pAction; |
405 |
filter->upAction = *pAction; |
347 |
xkbi->state.locked_mods^= pAction->mods.mask; |
406 |
xkbi->state.locked_mods^= pAction->mods.mask; |
348 |
xkbi->setMods = pAction->mods.mask; |
407 |
xkbi->setMods = pAction->mods.mask; |
Lines 1104-1112
xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
Link Here
|
1104 |
sendEvent=_XkbFilterLatchState(xkbi,filter,key,&act); |
1163 |
sendEvent=_XkbFilterLatchState(xkbi,filter,key,&act); |
1105 |
break; |
1164 |
break; |
1106 |
case XkbSA_LockMods: |
1165 |
case XkbSA_LockMods: |
|
|
1166 |
filter = _XkbNextFreeFilter(xkbi); |
1167 |
sendEvent=_XkbFilterLockMods(xkbi,filter,key,&act); |
1168 |
break; |
1107 |
case XkbSA_LockGroup: |
1169 |
case XkbSA_LockGroup: |
1108 |
filter = _XkbNextFreeFilter(xkbi); |
1170 |
filter = _XkbNextFreeFilter(xkbi); |
1109 |
sendEvent=_XkbFilterLockState(xkbi,filter,key,&act); |
1171 |
sendEvent=_XkbFilterLockGroup(xkbi,filter,key,&act); |
1110 |
break; |
1172 |
break; |
1111 |
case XkbSA_ISOLock: |
1173 |
case XkbSA_ISOLock: |
1112 |
filter = _XkbNextFreeFilter(xkbi); |
1174 |
filter = _XkbNextFreeFilter(xkbi); |