Commit fbf087ea94cb5e7886ac928220112d6833269e3c

Ran Benita 2020-11-23T19:51:04

keymap-dump: follow xkbcomp in printing affect=both in pointer actions It is equivalent to nothing but good to match up. Signed-off-by: Ran Benita <ran@unusedvar.com>

diff --git a/src/xkbcomp/keymap-dump.c b/src/xkbcomp/keymap-dump.c
index e6b438a..b7828bf 100644
--- a/src/xkbcomp/keymap-dump.c
+++ b/src/xkbcomp/keymap-dump.c
@@ -277,9 +277,11 @@ write_led_map(struct xkb_keymap *keymap, struct buf *buf,
 }
 
 static const char *
-affect_lock_text(enum xkb_action_flags flags)
+affect_lock_text(enum xkb_action_flags flags, bool show_both)
 {
     switch (flags & (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK)) {
+    case 0:
+        return show_both ? ",affect=both" : "";
     case ACTION_LOCK_NO_UNLOCK:
         return ",affect=lock";
     case ACTION_LOCK_NO_LOCK:
@@ -317,7 +319,7 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
         write_buf(buf, "%s%s(modifiers=%s%s%s%s)%s", prefix, type, args,
                   (action->type != ACTION_TYPE_MOD_LOCK && (action->mods.flags & ACTION_LOCK_CLEAR)) ? ",clearLocks" : "",
                   (action->type != ACTION_TYPE_MOD_LOCK && (action->mods.flags & ACTION_LATCH_TO_LOCK)) ? ",latchToLock" : "",
-                  (action->type == ACTION_TYPE_MOD_LOCK) ? affect_lock_text(action->mods.flags) : "",
+                  (action->type == ACTION_TYPE_MOD_LOCK) ? affect_lock_text(action->mods.flags, false) : "",
                   suffix);
         break;
 
@@ -347,7 +349,7 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
         break;
 
     case ACTION_TYPE_PTR_LOCK:
-        args = affect_lock_text(action->btn.flags);
+        args = affect_lock_text(action->btn.flags, true);
         /* fallthrough */
     case ACTION_TYPE_PTR_BUTTON:
         write_buf(buf, "%s%s(button=", prefix, type);
@@ -382,7 +384,7 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
     case ACTION_TYPE_CTRL_LOCK:
         write_buf(buf, "%s%s(controls=%s%s)%s", prefix, type,
                   ControlMaskText(keymap->ctx, action->ctrls.ctrls),
-                  (action->type == ACTION_TYPE_CTRL_LOCK) ? affect_lock_text(action->ctrls.flags) : "",
+                  (action->type == ACTION_TYPE_CTRL_LOCK) ? affect_lock_text(action->ctrls.flags, false) : "",
                   suffix);
         break;
 
diff --git a/test/data/keymaps/host.xkb b/test/data/keymaps/host.xkb
index 99ecd5b..dcaa677 100644
--- a/test/data/keymaps/host.xkb
+++ b/test/data/keymaps/host.xkb
@@ -887,16 +887,16 @@ xkb_compatibility "complete" {
 		action= PtrBtn(button=3,count=2);
 	};
 	interpret Pointer_Drag_Dflt+AnyOfOrNone(all) {
-		action= LockPtrBtn(button=default);
+		action= LockPtrBtn(button=default,affect=both);
 	};
 	interpret Pointer_Drag1+AnyOfOrNone(all) {
-		action= LockPtrBtn(button=1);
+		action= LockPtrBtn(button=1,affect=both);
 	};
 	interpret Pointer_Drag2+AnyOfOrNone(all) {
-		action= LockPtrBtn(button=2);
+		action= LockPtrBtn(button=2,affect=both);
 	};
 	interpret Pointer_Drag3+AnyOfOrNone(all) {
-		action= LockPtrBtn(button=3);
+		action= LockPtrBtn(button=3,affect=both);
 	};
 	interpret Pointer_EnableKeys+AnyOfOrNone(all) {
 		action= LockControls(controls=MouseKeys);
diff --git a/test/data/keymaps/stringcomp.data b/test/data/keymaps/stringcomp.data
index 2fd27df..bc9b6ab 100644
--- a/test/data/keymaps/stringcomp.data
+++ b/test/data/keymaps/stringcomp.data
@@ -880,16 +880,16 @@ xkb_compatibility "complete_caps(caps_lock)_4_misc(assign_shift_left_action)_4_l
 		action= PtrBtn(button=3,count=2);
 	};
 	interpret Pointer_Drag_Dflt+AnyOfOrNone(all) {
-		action= LockPtrBtn(button=default);
+		action= LockPtrBtn(button=default,affect=both);
 	};
 	interpret Pointer_Drag1+AnyOfOrNone(all) {
-		action= LockPtrBtn(button=1);
+		action= LockPtrBtn(button=1,affect=both);
 	};
 	interpret Pointer_Drag2+AnyOfOrNone(all) {
-		action= LockPtrBtn(button=2);
+		action= LockPtrBtn(button=2,affect=both);
 	};
 	interpret Pointer_Drag3+AnyOfOrNone(all) {
-		action= LockPtrBtn(button=3);
+		action= LockPtrBtn(button=3,affect=both);
 	};
 	interpret Pointer_EnableKeys+AnyOfOrNone(all) {
 		action= LockControls(controls=MouseKeys);