[yocto] [matchbox-keyboard][PATCH v2 1/1] Support of "caps" tag

Herve Jourdain herve.jourdain at neuf.fr
Wed May 18 01:34:59 PDT 2016


This patch allows the support of a "caps" tag, that defines the value of the key when the CAPS action modifier is in effect.
This feature is needed for the french keyboard - at least - in order to handle the uppercase accented letters, that are the ones accessible when caps is on, for some keys.
There is no impact when the tag is not used in the xml description of the layout, therefore there should be no impact on keyboards not using this tag.
Tests have been done using sato.

Signed-off-by: Herve Jourdain <herve.jourdain at neuf.fr>
---
 src/config-parser.c                      |  5 +++++
 src/matchbox-keyboard-key.c              | 11 ++++++++---
 src/matchbox-keyboard-ui-cairo-backend.c | 10 +++++++---
 src/matchbox-keyboard-ui-xft-backend.c   | 10 +++++++---
 src/matchbox-keyboard.c                  |  3 +++
 src/matchbox-keyboard.h                  |  1 +
 6 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/src/config-parser.c b/src/config-parser.c
index 15a973e..13ee6d6 100644
--- a/src/config-parser.c
+++ b/src/config-parser.c
@@ -326,6 +326,10 @@ config_handle_key_subtag(MBKeyboardConfigState *state,
     {
       keystate = MBKeyboardKeyStateShifted;
     }
+  else if (streq(tag, "caps"))
+    {
+      keystate = MBKeyboardKeyStateCaps;
+    }
   else if (streq(tag, "mod1"))
     {
       keystate = MBKeyboardKeyStateMod1;
@@ -548,6 +552,7 @@ config_xml_start_cb(void *data, const char *tag, const char **attr)
   else if (streq(tag, "normal") 
 	   || streq(tag, "default")
 	   || streq(tag, "shifted")
+	   || streq(tag, "caps")
 	   || streq(tag, "mod1")
 	   || streq(tag, "mod2")
 	   || streq(tag, "mod3"))
diff --git a/src/matchbox-keyboard-key.c b/src/matchbox-keyboard-key.c
index 0555c9c..c086fbe 100644
--- a/src/matchbox-keyboard-key.c
+++ b/src/matchbox-keyboard-key.c
@@ -413,9 +413,13 @@ mb_kbd_key_press(MBKeyboardKey *key)
 
   state = mb_kbd_keys_current_state(key->kbd);
 
-  if (mb_kbd_has_state(key->kbd, MBKeyboardStateCaps)
-      && mb_kbd_key_get_obey_caps(key))
-    state = MBKeyboardKeyStateShifted;
+  if (mb_kbd_has_state(key->kbd, MBKeyboardStateCaps))
+  {
+    if (mb_kdb_key_has_state (key, MBKeyboardKeyStateCaps))
+      state = MBKeyboardKeyStateCaps;
+    else if (mb_kbd_key_get_obey_caps(key))
+      state = MBKeyboardKeyStateShifted;
+  }
 
   /* XXX below fakekey mods probably better in ui */
 
@@ -616,6 +620,7 @@ mb_kbd_key_dump_key(MBKeyboardKey *key)
     {
       /* MBKeyboardKeyStateNormal  */ "Normal",
       /* MBKeyboardKeyStateShifted */ "Shifted" ,
+      /* MBKeyboardKeyStateCaps    */ "Caps" ,
       /* MBKeyboardKeyStateMod1,    */ "Mod1" ,
       /* MBKeyboardKeyStateMod2,    */ "Mod2" ,
       /* MBKeyboardKeyStateMod3,    */ "Mod3" 
diff --git a/src/matchbox-keyboard-ui-cairo-backend.c b/src/matchbox-keyboard-ui-cairo-backend.c
index 3b7a401..3f15ac8 100644
--- a/src/matchbox-keyboard-ui-cairo-backend.c
+++ b/src/matchbox-keyboard-ui-cairo-backend.c
@@ -174,9 +174,13 @@ mb_kbd_ui_cairo_redraw_key(MBKeyboardUI  *ui, MBKeyboardKey *key)
 
   state = mb_kbd_keys_current_state(kbd); 
 
-  if (mb_kbd_has_state(kbd, MBKeyboardStateCaps)
-      && mb_kbd_key_get_obey_caps(key))
-    state = MBKeyboardKeyStateShifted;
+  if (mb_kbd_has_state(kbd, MBKeyboardStateCaps))
+    {
+      if (mb_kdb_key_has_state (key, MBKeyboardKeyStateCaps))
+        state = MBKeyboardKeyStateCaps;
+      else if (mb_kbd_key_get_obey_caps(key))
+        state = MBKeyboardKeyStateShifted;
+    }
 
   if (!mb_kdb_key_has_state(key, state))
     {
diff --git a/src/matchbox-keyboard-ui-xft-backend.c b/src/matchbox-keyboard-ui-xft-backend.c
index 9a3c6d2..2790591 100644
--- a/src/matchbox-keyboard-ui-xft-backend.c
+++ b/src/matchbox-keyboard-ui-xft-backend.c
@@ -212,9 +212,13 @@ mb_kbd_ui_xft_redraw_key(MBKeyboardUI  *ui, MBKeyboardKey *key)
 
   state = mb_kbd_keys_current_state(kbd); 
 
-  if (mb_kbd_has_state(kbd, MBKeyboardStateCaps)
-      && mb_kbd_key_get_obey_caps(key))
-    state = MBKeyboardKeyStateShifted;
+  if (mb_kbd_has_state(kbd, MBKeyboardStateCaps))
+    {
+      if (mb_kdb_key_has_state (key, MBKeyboardKeyStateCaps))
+        state = MBKeyboardKeyStateCaps;
+      else if (mb_kbd_key_get_obey_caps(key))
+        state = MBKeyboardKeyStateShifted;
+    }
 
   if (!mb_kdb_key_has_state(key, state))
     {
diff --git a/src/matchbox-keyboard.c b/src/matchbox-keyboard.c
index 9f9bb7d..3ed98c0 100644
--- a/src/matchbox-keyboard.c
+++ b/src/matchbox-keyboard.c
@@ -200,6 +200,9 @@ mb_kbd_keys_current_state(MBKeyboard *kbd)
   if (mb_kbd_has_state(kbd, MBKeyboardStateShifted))
     return MBKeyboardKeyStateShifted;
 
+  if (mb_kbd_has_state(kbd, MBKeyboardStateCaps))
+    return MBKeyboardKeyStateCaps;
+
   if (mb_kbd_has_state(kbd, MBKeyboardStateMod1))
     return MBKeyboardKeyStateMod1;
 
diff --git a/src/matchbox-keyboard.h b/src/matchbox-keyboard.h
index 4dd258f..430b08b 100644
--- a/src/matchbox-keyboard.h
+++ b/src/matchbox-keyboard.h
@@ -116,6 +116,7 @@ typedef enum
 {
   MBKeyboardKeyStateNormal = 0,
   MBKeyboardKeyStateShifted,
+  MBKeyboardKeyStateCaps,
   MBKeyboardKeyStateMod1,
   MBKeyboardKeyStateMod2,
   MBKeyboardKeyStateMod3,
-- 
2.7.4




More information about the yocto mailing list