libxkbfile: Add missing support for NoLock and NoUnlock flags

Submitted by Andreas Wettstein on Feb. 15, 2014, 4:35 p.m.

Details

Message ID 87zjls1ghu.fsf@solnet.ch
State Accepted
Commit 6223ec08213cb8cc546418690c27e0fdd4f0addd
Headers show

Not browsing as part of any series.

Commit Message

Andreas Wettstein Feb. 15, 2014, 4:35 p.m.
The LockMods, ISOLock and LockControls support an "affect" flag to selectively
enable and disable locking and unlocking for these actions.  This change adds
output of these flags.

Signed-off-by: Andreas Wettstein <wettstein509@solnet.ch>
---
 src/xkbtext.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 46 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/xkbtext.c b/src/xkbtext.c
index b5d4750..bf992e4 100644
--- a/src/xkbtext.c
+++ b/src/xkbtext.c
@@ -886,8 +886,22 @@  CopyModActionArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
     }
     else
         TryCopyStr(buf, "none", sz);
-    if (act->type == XkbSA_LockMods)
+    if (act->type == XkbSA_LockMods) {
+        switch (act->flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
+        case XkbSA_LockNoLock:
+            TryCopyStr(buf, ",affect=unlock", sz);
+            break;
+        case XkbSA_LockNoUnlock:
+            TryCopyStr(buf, ",affect=lock", sz);
+            break;
+        case XkbSA_LockNoUnlock|XkbSA_LockNoLock:
+            TryCopyStr(buf, ",affect=neither", sz);
+            break;
+        default:
+            break;
+        }
         return True;
+    }
     if (act->flags & XkbSA_ClearLocks)
         TryCopyStr(buf, ",clearLocks", sz);
     if (act->flags & XkbSA_LatchToLock)
@@ -1049,8 +1063,12 @@  CopyISOLockArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
             TryCopyStr(buf, "none", sz);
     }
     TryCopyStr(buf, ",affect=", sz);
-    if ((act->affect & XkbSA_ISOAffectMask) == 0)
+    if ((act->affect & XkbSA_ISOAffectMask) == 0) {
         TryCopyStr(buf, "all", sz);
+    }
+    else if ((act->affect & XkbSA_ISOAffectMask) == XkbSA_ISOAffectMask) {
+        TryCopyStr(buf, "none", sz);
+    }
     else {
         int nOut = 0;
 
@@ -1074,6 +1092,18 @@  CopyISOLockArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
             nOut++;
         }
     }
+    switch (act->flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
+    case XkbSA_LockNoLock:
+        TryCopyStr(buf, "+unlock", sz);
+        break;
+    case XkbSA_LockNoUnlock:
+        TryCopyStr(buf, "+lock", sz);
+        break;
+    case XkbSA_LockNoUnlock | XkbSA_LockNoLock:
+        TryCopyStr(buf, "+neither", sz);
+        break;
+    default: ;
+    }
     return True;
 }
 
@@ -1183,6 +1213,20 @@  CopySetLockControlsArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
             nOut++;
         }
     }
+    if (action->type == XkbSA_LockControls) {
+        switch (act->flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
+        case XkbSA_LockNoLock:
+            TryCopyStr(buf, ",affect=unlock", sz);
+            break;
+        case XkbSA_LockNoUnlock:
+            TryCopyStr(buf, ",affect=lock", sz);
+            break;
+        case XkbSA_LockNoUnlock | XkbSA_LockNoLock:
+            TryCopyStr(buf, ",affect=neither", sz);
+            break;
+        default: ;
+        }
+    }
     return True;
 }
 

Comments

On Sat, Feb 15, 2014 at 05:35:09PM +0100, Andreas Wettstein wrote:
> The LockMods, ISOLock and LockControls support an "affect" flag to selectively
> enable and disable locking and unlocking for these actions.  This change adds
> output of these flags.
> 
> Signed-off-by: Andreas Wettstein <wettstein509@solnet.ch>

Reviewed-By: Ran Benita <ran234@gmail.com>

> ---
>  src/xkbtext.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 46 insertions(+), 2 deletions(-)
> 
> diff --git a/src/xkbtext.c b/src/xkbtext.c
> index b5d4750..bf992e4 100644
> --- a/src/xkbtext.c
> +++ b/src/xkbtext.c
> @@ -886,8 +886,22 @@ CopyModActionArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
>      }
>      else
>          TryCopyStr(buf, "none", sz);
> -    if (act->type == XkbSA_LockMods)
> +    if (act->type == XkbSA_LockMods) {
> +        switch (act->flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
> +        case XkbSA_LockNoLock:
> +            TryCopyStr(buf, ",affect=unlock", sz);
> +            break;
> +        case XkbSA_LockNoUnlock:
> +            TryCopyStr(buf, ",affect=lock", sz);
> +            break;
> +        case XkbSA_LockNoUnlock|XkbSA_LockNoLock:
> +            TryCopyStr(buf, ",affect=neither", sz);
> +            break;
> +        default:
> +            break;
> +        }
>          return True;
> +    }
>      if (act->flags & XkbSA_ClearLocks)
>          TryCopyStr(buf, ",clearLocks", sz);
>      if (act->flags & XkbSA_LatchToLock)
> @@ -1049,8 +1063,12 @@ CopyISOLockArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
>              TryCopyStr(buf, "none", sz);
>      }
>      TryCopyStr(buf, ",affect=", sz);
> -    if ((act->affect & XkbSA_ISOAffectMask) == 0)
> +    if ((act->affect & XkbSA_ISOAffectMask) == 0) {
>          TryCopyStr(buf, "all", sz);
> +    }
> +    else if ((act->affect & XkbSA_ISOAffectMask) == XkbSA_ISOAffectMask) {
> +        TryCopyStr(buf, "none", sz);
> +    }

Hmm, so this just printed ",affect=" previously? Heh.

>      else {
>          int nOut = 0;
>  
> @@ -1074,6 +1092,18 @@ CopyISOLockArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
>              nOut++;
>          }
>      }
> +    switch (act->flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
> +    case XkbSA_LockNoLock:
> +        TryCopyStr(buf, "+unlock", sz);
> +        break;
> +    case XkbSA_LockNoUnlock:
> +        TryCopyStr(buf, "+lock", sz);
> +        break;
> +    case XkbSA_LockNoUnlock | XkbSA_LockNoLock:
> +        TryCopyStr(buf, "+neither", sz);
> +        break;
> +    default: ;
> +    }
>      return True;
>  }
>  
> @@ -1183,6 +1213,20 @@ CopySetLockControlsArgs(Display *dpy, XkbDescPtr xkb, XkbAction *action,
>              nOut++;
>          }
>      }
> +    if (action->type == XkbSA_LockControls) {
> +        switch (act->flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
> +        case XkbSA_LockNoLock:
> +            TryCopyStr(buf, ",affect=unlock", sz);
> +            break;
> +        case XkbSA_LockNoUnlock:
> +            TryCopyStr(buf, ",affect=lock", sz);
> +            break;
> +        case XkbSA_LockNoUnlock | XkbSA_LockNoLock:
> +            TryCopyStr(buf, ",affect=neither", sz);
> +            break;
> +        default: ;
> +        }
> +    }
>      return True;
>  }
>  
> -- 
> 1.8.3.1
>