Advertisement
Guest User

Untitled

a guest
Aug 5th, 2013
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- xkbActions.orig.c   2013-08-04 11:55:33.388301598 -0500
  2. +++ xkbActions.c    2013-08-04 09:31:59.067134417 -0500
  3. @@ -340,23 +340,89 @@
  4.      return 1;
  5.  }
  6.  
  7. +static int xkbSwitchGroupOnRelease(void)
  8. +{
  9. +    /* TODO: user configuring */
  10. +    return TRUE;
  11. +}
  12. +
  13. +static void xkbUpdateLockedGroup(XkbSrvInfoPtr xkbi, XkbAction* pAction)
  14. +{
  15. +    XkbGroupAction ga = pAction->group;
  16. +    if (ga.flags&XkbSA_GroupAbsolute)
  17. +   xkbi->state.locked_group= XkbSAGroup(&ga);
  18. +    else xkbi->state.locked_group+= XkbSAGroup(&ga);
  19. +}
  20. +
  21. +static XkbFilterPtr _XkbNextFreeFilter(XkbSrvInfoPtr xkbi);
  22. +
  23. +
  24.  static int
  25. -_XkbFilterLockState(XkbSrvInfoPtr xkbi,
  26. +_XkbFilterLockGroup(XkbSrvInfoPtr xkbi,
  27.                      XkbFilterPtr filter, unsigned keycode, XkbAction *pAction)
  28.  {
  29. -    if (pAction && (pAction->type == XkbSA_LockGroup)) {
  30. -        if (pAction->group.flags & XkbSA_GroupAbsolute)
  31. -            xkbi->state.locked_group = XkbSAGroup(&pAction->group);
  32. -        else
  33. -            xkbi->state.locked_group += XkbSAGroup(&pAction->group);
  34. -        return 1;
  35. +    /* if (pAction && (pAction->type == XkbSA_LockGroup)) { */
  36. +    /*     if (pAction->group.flags & XkbSA_GroupAbsolute) */
  37. +    /*         xkbi->state.locked_group = XkbSAGroup(&pAction->group); */
  38. +    /*     else */
  39. +    /*         xkbi->state.locked_group += XkbSAGroup(&pAction->group); */
  40. +    /*     return 1; */
  41. +    int sendEvent = 1;
  42. +
  43. +    if (!xkbSwitchGroupOnRelease()) {
  44. +   xkbUpdateLockedGroup(xkbi, pAction);
  45. +   return sendEvent;
  46. +    }
  47. +    
  48. +    /* Delay switch till button release */
  49. +    if (filter->keycode==0) {      /* initial press */
  50. +   filter->keycode = keycode;
  51. +   filter->active = 1;
  52. +   filter->filterOthers = 0; /* for what? */
  53. +   filter->filter = _XkbFilterLockGroup;
  54. +
  55. +   /* filter->priv = 0; */
  56. +   filter->upAction = *pAction;
  57. +
  58. +   /* Ok, now we need to simulate the action which would go if this action didn't block it.
  59. +      XkbSA_SetMods is the one: it is to set modifier' flag up. */
  60. +   {
  61. +       XkbStateRec fake_state = xkbi->state;
  62. +       XkbAction act;
  63. +
  64. +       fake_state.mods = 0;
  65. +       act = XkbGetKeyAction(xkbi, &fake_state, keycode);
  66. +
  67. +       /* KLUDGE: XkbSA_SetMods only? */
  68. +       if (act.type == XkbSA_SetMods) {
  69. +       XkbFilterPtr filter = _XkbNextFreeFilter(xkbi);
  70. +       sendEvent = _XkbFilterSetState(xkbi,filter,keycode,&act);
  71. +       }
  72. +   }
  73.      }
  74. +    else {
  75. +   /* do nothing if some button else is pressed */
  76. +   if (!pAction)
  77. +       xkbUpdateLockedGroup(xkbi, &filter->upAction);
  78. +   filter->active = 0;
  79. +    }
  80. +
  81. +    return sendEvent;
  82. +}
  83. +
  84. +static int
  85. +_XkbFilterLockMods(    XkbSrvInfoPtr   xkbi,
  86. +           XkbFilterPtr    filter,
  87. +           unsigned    keycode,
  88. +           XkbAction * pAction)
  89. +{
  90. +
  91.      if (filter->keycode == 0) { /* initial press */
  92.          filter->keycode = keycode;
  93.          filter->active = 1;
  94.          filter->filterOthers = 0;
  95.          filter->priv = xkbi->state.locked_mods & pAction->mods.mask;
  96. -        filter->filter = _XkbFilterLockState;
  97. +        filter->filter = _XkbFilterLockMods;
  98.          filter->upAction = *pAction;
  99.          if (!(filter->upAction.mods.flags & XkbSA_LockNoLock))
  100.              xkbi->state.locked_mods |= pAction->mods.mask;
  101. @@ -1142,9 +1208,12 @@
  102.                  sendEvent = _XkbFilterLatchState(xkbi, filter, key, &act);
  103.                  break;
  104.              case XkbSA_LockMods:
  105. +           filter = _XkbNextFreeFilter(xkbi);
  106. +       sendEvent=_XkbFilterLockMods(xkbi,filter,key,&act);
  107. +       break;
  108.              case XkbSA_LockGroup:
  109.                  filter = _XkbNextFreeFilter(xkbi);
  110. -                sendEvent = _XkbFilterLockState(xkbi, filter, key, &act);
  111. +                sendEvent = _XkbFilterLockGroup(xkbi, filter, key, &act);
  112.                  break;
  113.              case XkbSA_ISOLock:
  114.                  filter = _XkbNextFreeFilter(xkbi);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement