[oe-commits] org.oe.dev matchbox-keyboard svn: Add patches to support multiple layouts.

pfalcon commit openembedded-commits at lists.openembedded.org
Mon Jun 11 15:37:09 UTC 2007


matchbox-keyboard svn: Add patches to support multiple layouts.
* Allows to load multiple layouts from independent files located in 
~/.matchbox/keyboard.d/ (is most cases those going to be symlinks to 
/usr/share) and switch among them (this requires corresponding button
present in layout).
* Config UI to setup active layouts to follow.

Author: pfalcon at openembedded.org
Branch: org.openembedded.dev
Revision: 68b057e66596482b70064cb9ef2cb090da819263
ViewMTN: http://monotone.openembedded.org/revision.psp?id=68b057e66596482b70064cb9ef2cb090da819263
Files:
1
packages/matchbox-keyboard/files/2-Add-new-modifier--layout--Used-to-cycle-thru-all-available-layouts.patch
packages/matchbox-keyboard/files/3-Changes-to-improve-layout-rendering--especially-after-adding-support-for.patch
packages/matchbox-keyboard/files/4-Add-rendering-debug-logging.patch
packages/matchbox-keyboard/files/5-Add-support-for-loading-multiple-independent-layouts.patch
packages/matchbox-keyboard/files/6-Add-layout-switch-key-to-all-layouts.patch
packages/matchbox-keyboard/matchbox-keyboard_svn.bb
Diffs:

#
# mt diff -rcaa0c450f832bf45bc76ce27137638501f3a4fd3 -r68b057e66596482b70064cb9ef2cb090da819263
#
# 
# 
# add_file "packages/matchbox-keyboard/files/2-Add-new-modifier--layout--Used-to-cycle-thru-all-available-layouts.patch"
#  content [d37f4c2f59e428172f8a70481172f2c8813790b4]
# 
# add_file "packages/matchbox-keyboard/files/3-Changes-to-improve-layout-rendering--especially-after-adding-support-for.patch"
#  content [f1007f312f166afc1af40a84f7d2cee5f1e5e9d2]
# 
# add_file "packages/matchbox-keyboard/files/4-Add-rendering-debug-logging.patch"
#  content [caf942b51b36963448104e736cae985e67435a8c]
# 
# add_file "packages/matchbox-keyboard/files/5-Add-support-for-loading-multiple-independent-layouts.patch"
#  content [1eca698bf5b220dad60ef3171419afa34db0cc38]
# 
# add_file "packages/matchbox-keyboard/files/6-Add-layout-switch-key-to-all-layouts.patch"
#  content [8bc441b6384a4d2645419027b3c9d5f99e6bf993]
# 
# patch "packages/matchbox-keyboard/matchbox-keyboard_svn.bb"
#  from [98ee6fe896b463c3fe5a82950f30d212e87a4bac]
#    to [a7289c30f50e306ac225353bc9414e7222dc8286]
# 
============================================================
--- packages/matchbox-keyboard/files/2-Add-new-modifier--layout--Used-to-cycle-thru-all-available-layouts.patch	d37f4c2f59e428172f8a70481172f2c8813790b4
+++ packages/matchbox-keyboard/files/2-Add-new-modifier--layout--Used-to-cycle-thru-all-available-layouts.patch	d37f4c2f59e428172f8a70481172f2c8813790b4
@@ -0,0 +1,91 @@
+# HG changeset patch
+# User pfalcon at localhost
+# Date 1176076569 0
+# Node ID ff9cf1fd8177dded04b9fc81ba630203848fc3ca
+# Parent  96305d94eb31f06f5618c99310192c47c68a1f21
+Add new modifier: layout. Used to cycle thru all available layouts.
+
+diff -r 96305d94eb31 -r ff9cf1fd8177 src/config-parser.c
+--- a/src/config-parser.c	Sun Apr 08 23:28:43 2007 +0000
++++ b/src/config-parser.c	Sun Apr 08 23:56:09 2007 +0000
+@@ -113,7 +113,8 @@ ModLookup[] =
+   { "mod1",    MBKeyboardKeyModMod1 },
+   { "mod2",    MBKeyboardKeyModMod2 },
+   { "mod3",    MBKeyboardKeyModMod3 },
+-  { "caps",    MBKeyboardKeyModCaps }
++  { "caps",    MBKeyboardKeyModCaps },
++  { "layout",  MBKeyboardKeyModLayout },
+ };
+ 
+ typedef struct MBKeyboardConfigState
+diff -r 96305d94eb31 -r ff9cf1fd8177 src/matchbox-keyboard-key.c
+--- a/src/matchbox-keyboard-key.c	Sun Apr 08 23:28:43 2007 +0000
++++ b/src/matchbox-keyboard-key.c	Sun Apr 08 23:56:09 2007 +0000
+@@ -493,6 +493,16 @@ mb_kbd_key_press(MBKeyboardKey *key)
+ 	  case MBKeyboardKeyModAlt:
+ 	    mb_kbd_toggle_state(key->kbd, MBKeyboardStateAlt);
+ 	    break;
++	  case MBKeyboardKeyModLayout:
++	    key->kbd->selected_layout_no++;
++	    if (key->kbd->selected_layout_no >= util_list_length(key->kbd->layouts))
++	      key->kbd->selected_layout_no = 0;
++	    key->kbd->selected_layout = 
++	      (MBKeyboardLayout *)util_list_get_nth_data(key->kbd->layouts, 
++							 key->kbd->selected_layout_no);
++	    mb_kbd_ui_recalc_ui_layout(key->kbd->ui);
++	    queue_full_kbd_redraw = True;
++	    break;
+ 	  default:
+ 	    DBG("unknown modifier action");
+ 	    break;
+diff -r 96305d94eb31 -r ff9cf1fd8177 src/matchbox-keyboard-ui.c
+--- a/src/matchbox-keyboard-ui.c	Sun Apr 08 23:28:43 2007 +0000
++++ b/src/matchbox-keyboard-ui.c	Sun Apr 08 23:56:09 2007 +0000
+@@ -505,6 +505,15 @@ mb_kbd_ui_allocate_ui_layout(MBKeyboardU
+     }
+   
+   *width = max_row_width;
++}
++
++void
++mb_kbd_ui_recalc_ui_layout(MBKeyboardUI *ui)
++{
++  mb_kbd_ui_allocate_ui_layout(ui,
++                               &ui->base_alloc_width, &ui->base_alloc_height);
++
++  mb_kbd_ui_resize(ui, ui->xwin_width, ui->xwin_height); 
+ }
+ 
+ void
+diff -r 96305d94eb31 -r ff9cf1fd8177 src/matchbox-keyboard.c
+--- a/src/matchbox-keyboard.c	Sun Apr 08 23:28:43 2007 +0000
++++ b/src/matchbox-keyboard.c	Sun Apr 08 23:56:09 2007 +0000
+@@ -85,6 +85,7 @@ mb_kbd_new (int argc, char **argv)
+ 
+   kb->selected_layout 
+     = (MBKeyboardLayout *)util_list_get_nth_data(kb->layouts, 0);
++  kb->selected_layout_no = 0;
+ 
+   if (want_embedding)
+     mb_kbd_ui_set_embeded( kb->ui, True );
+diff -r 96305d94eb31 -r ff9cf1fd8177 src/matchbox-keyboard.h
+--- a/src/matchbox-keyboard.h	Sun Apr 08 23:28:43 2007 +0000
++++ b/src/matchbox-keyboard.h	Sun Apr 08 23:56:09 2007 +0000
+@@ -148,6 +148,7 @@ struct MBKeyboard
+ 
+   List                  *layouts;
+   MBKeyboardLayout      *selected_layout;
++  int                    selected_layout_no;
+ 
+   int                    key_border, key_pad, key_margin;
+   int                    row_spacing, col_spacing;
+@@ -177,6 +178,9 @@ int
+ int
+ mb_kbd_ui_init(MBKeyboard *kbd);
+ 
++void
++mb_kbd_ui_recalc_ui_layout(MBKeyboardUI *ui);
++
+ int
+ mb_kbd_ui_realize(MBKeyboardUI  *ui);
+ 
============================================================
--- packages/matchbox-keyboard/files/3-Changes-to-improve-layout-rendering--especially-after-adding-support-for.patch	f1007f312f166afc1af40a84f7d2cee5f1e5e9d2
+++ packages/matchbox-keyboard/files/3-Changes-to-improve-layout-rendering--especially-after-adding-support-for.patch	f1007f312f166afc1af40a84f7d2cee5f1e5e9d2
@@ -0,0 +1,94 @@
+# HG changeset patch
+# User pfalcon at localhost
+# Date 1176077194 0
+# Node ID b010d54a6c5020a68855e60e5a423ee3c18ed700
+# Parent  ff9cf1fd8177dded04b9fc81ba630203848fc3ca
+Changes to improve layout rendering, especially after adding support for
+multiple layouts:
+1. Add --hfactor option which presets keyboard to the specified percentage
+of screen height. This is required for multiple layouts, as otherwise
+height is calculated on specific layout, but in such a way that it is
+affected by previous layout, which leads to rendering artifacts.
+2. Also st default font height to 6, after all.
+
+diff -r ff9cf1fd8177 -r b010d54a6c50 src/matchbox-keyboard-ui.c
+--- a/src/matchbox-keyboard-ui.c	Sun Apr 08 23:56:09 2007 +0000
++++ b/src/matchbox-keyboard-ui.c	Mon Apr 09 00:06:34 2007 +0000
+@@ -744,9 +744,15 @@ mb_kbd_ui_resources_create(MBKeyboardUI 
+ 	       */
+ 	      if (desk_width > ui->xwin_width)
+ 		{
++		  int win_height;
++		  if (ui->kbd->hfactor != 0)
++		    win_height = desk_height * ui->kbd->hfactor / 100;
++		  else
++		    win_height = ( desk_width * ui->xwin_height ) / ui->xwin_width;
++
+ 		  mb_kbd_ui_resize(ui, 
+ 				   desk_width, 
+-				   ( desk_width * ui->xwin_height ) / ui->xwin_width);
++				   win_height);
+ 		}
+ 	      
+ 	      wm_struct_vals[2]  = desk_y + desk_height - ui->xwin_height;
+@@ -818,8 +824,11 @@ mb_kbd_ui_resize(MBKeyboardUI *ui, int w
+   width_diff  = width  - ui->base_alloc_width; 
+   height_diff = height - ui->base_alloc_height; 
+ 
++/* It's better to have some "clipped" keys, than busted layout. */
++#if 0
+   if (width_diff < 0 || height_diff < 0)
+     return;  /* dont go smaller than our int request - get clipped */
++#endif
+ 
+   layout   = mb_kbd_get_selected_layout(ui->kbd);
+   row_item = mb_kbd_layout_rows(layout);
+diff -r ff9cf1fd8177 -r b010d54a6c50 src/matchbox-keyboard.c
+--- a/src/matchbox-keyboard.c	Sun Apr 08 23:56:09 2007 +0000
++++ b/src/matchbox-keyboard.c	Mon Apr 09 00:06:34 2007 +0000
+@@ -23,8 +23,9 @@ mb_kbd_usage (char *progname)
+ mb_kbd_usage (char *progname)
+ {
+   fprintf(stderr, "Usage:\n   %s [Options ] [ Layout Variant ]\n", progname);
+-  fprintf(stderr, "\nOptions are;\n"
+-	  "   -xid,--xid            Print window ID to stdout ( for embedding )\n");
++  fprintf(stderr, "\nOptions are:\n"
++	  "   -xid,--xid            Print window ID to stdout ( for embedding )\n"
++	  "   --hfactor <percent>   Fix keyboard window size in percentage of desktop height\n");
+   fprintf(stderr, "\nmatchbox-keyboard %s \nCopyright (C) 2005 Matthew Allum, OpenedHand Ltd.\n", VERSION);
+ 
+   exit(-1);
+@@ -58,6 +59,13 @@ mb_kbd_new (int argc, char **argv)
+ 	  want_embedding = True;
+ 	  continue;
+ 	}
++      if (streq ("-hfactor", argv[i]) || streq ("--hfactor", argv[i])) 
++	{
++	  if (i + 1 < argc) {
++	    kb->hfactor = atoi(argv[i + 1]);
++	  }
++	  continue;
++	}
+ 
+       if (i == (argc-1) && argv[i][0] != '-')
+ 	variant = argv[i];
+@@ -77,7 +85,7 @@ mb_kbd_new (int argc, char **argv)
+       kb->key_pad      = 0;
+       kb->col_spacing  = 0;
+       kb->row_spacing  = 0;
+-      kb->font_pt_size = 5;
++      kb->font_pt_size = 6;
+     }
+ 
+   if (!mb_kbd_config_load(kb, variant))
+diff -r ff9cf1fd8177 -r b010d54a6c50 src/matchbox-keyboard.h
+--- a/src/matchbox-keyboard.h	Sun Apr 08 23:56:09 2007 +0000
++++ b/src/matchbox-keyboard.h	Mon Apr 09 00:06:34 2007 +0000
+@@ -143,6 +143,7 @@ struct MBKeyboard
+   char                  *font_family;
+   int                    font_pt_size;
+   char                  *font_variant;
++  int                    hfactor;
+ 
+   char                  *config_file;
+ 
============================================================
--- packages/matchbox-keyboard/files/4-Add-rendering-debug-logging.patch	caf942b51b36963448104e736cae985e67435a8c
+++ packages/matchbox-keyboard/files/4-Add-rendering-debug-logging.patch	caf942b51b36963448104e736cae985e67435a8c
@@ -0,0 +1,65 @@
+# HG changeset patch
+# User pfalcon at localhost
+# Date 1176077287 0
+# Node ID 38c3459f2e1a1c8dc7aacb486f201bdda638c7f2
+# Parent  b010d54a6c5020a68855e60e5a423ee3c18ed700
+Add rendering debug logging.
+
+diff -r b010d54a6c50 -r 38c3459f2e1a src/matchbox-keyboard-ui.c
+--- a/src/matchbox-keyboard-ui.c	Mon Apr 09 00:06:34 2007 +0000
++++ b/src/matchbox-keyboard-ui.c	Mon Apr 09 00:08:07 2007 +0000
+@@ -357,6 +357,8 @@ mb_kbd_ui_allocate_ui_layout(MBKeyboardU
+   /* Do an initial run to figure out a 'base' size for single glyph keys */
+   mb_kdb_ui_unit_key_size(ui, &ui->key_uwidth, &ui->key_uheight);
+ 
++  DBG("unit_key_size: %dx%d", ui->key_uwidth, ui->key_uheight);
++
+   row_item = mb_kbd_layout_rows(layout);
+ 
+   row_y = mb_kbd_row_spacing(ui->kbd); 
+@@ -415,6 +417,8 @@ mb_kbd_ui_allocate_ui_layout(MBKeyboardU
+ 
+       if (key_x > max_row_width) /* key_x now represents row width */
+ 	max_row_width = key_x;
++
++      DBG("Row width: %d", key_x);
+ 
+       mb_kbd_row_set_y(row, row_y);
+ 
+@@ -617,6 +621,8 @@ mb_kbd_ui_resources_create(MBKeyboardUI 
+   boolean              have_matchbox_wm = False;             
+   boolean              have_ewmh_wm     = False;             
+ 
++  DBG("mb_kbd_ui_resources_create: %dx%d", ui->xwin_width, ui->xwin_height);
++  
+   /*
+   atom_wm_protocols = { 
+     XInternAtom(ui->xdpy, "WM_DELETE_WINDOW",False),
+@@ -821,6 +827,8 @@ mb_kbd_ui_resize(MBKeyboardUI *ui, int w
+ 
+   MARK();
+ 
++  DBG("mb_kbd_ui_resize: resize to %dx%d, base %dx%d", width, height, ui->base_alloc_width, ui->base_alloc_height);
++
+   width_diff  = width  - ui->base_alloc_width; 
+   height_diff = height - ui->base_alloc_height; 
+ 
+@@ -1125,6 +1133,7 @@ mb_kbd_ui_event_loop(MBKeyboardUI *ui)
+ 		  }
+ 		break;
+ 	      case ConfigureNotify:
++		DBG("ConfigureNotify %i,%i", xev.xconfigure.width, xev.xconfigure.height);
+ 		if (xev.xconfigure.width != ui->xwin_width
+ 		    || xev.xconfigure.height != ui->xwin_height)
+ 		  mb_kbd_ui_handle_configure(ui,
+diff -r b010d54a6c50 -r 38c3459f2e1a src/matchbox-keyboard.h
+--- a/src/matchbox-keyboard.h	Mon Apr 09 00:06:34 2007 +0000
++++ b/src/matchbox-keyboard.h	Mon Apr 09 00:08:07 2007 +0000
+@@ -48,6 +48,7 @@
+ #include "config.h"
+ #endif
+ 
++#define WANT_DEBUG 1
+ #if (WANT_DEBUG)
+ #define DBG(x, a...) \
+  fprintf (stderr,  __FILE__ ":%d,%s() " x "\n", __LINE__, __func__, ##a)
============================================================
--- packages/matchbox-keyboard/files/5-Add-support-for-loading-multiple-independent-layouts.patch	1eca698bf5b220dad60ef3171419afa34db0cc38
+++ packages/matchbox-keyboard/files/5-Add-support-for-loading-multiple-independent-layouts.patch	1eca698bf5b220dad60ef3171419afa34db0cc38
@@ -0,0 +1,197 @@
+# HG changeset patch
+# User pfalcon at localhost
+# Date 1181567228 0
+# Node ID 869314ae90f46a8c2d34080005d4079cb0d0fcf4
+# Parent  38c3459f2e1a1c8dc7aacb486f201bdda638c7f2
+Add support for loading multiple independent layouts.
+All layouts found in ~/.matchbox/keyboard.d/ are loaded, realistically
+these will be symlinks to system-wide store. This directory has the highest
+priority of all other layout selection mechanism (except for
+$MB_KBD_CONFIG).
+
+diff -r 38c3459f2e1a -r 869314ae90f4 src/config-parser.c
+--- a/src/config-parser.c	Mon Apr 09 00:08:07 2007 +0000
++++ b/src/config-parser.c	Mon Jun 11 13:07:08 2007 +0000
+@@ -17,6 +17,7 @@
+  *
+  */
+ 
++#include <dirent.h>
+ #include "matchbox-keyboard.h"
+ 
+ /* 
+@@ -57,6 +58,9 @@
+ 
+     </keyboard>
+ */
++
++int mb_kbd_config_parse_file(MBKeyboard *kbd, char *path);
++static int mb_kbd_config_parse_data(MBKeyboard *kbd, char *data);
+ 
+ struct _keysymlookup
+ {
+@@ -170,12 +174,9 @@ config_str_to_modtype(const char* str)
+ }
+ 
+ 
+-static char* 
+-config_load_file(MBKeyboard *kbd, char *variant_in)
+-{
+-  struct stat    stat_info;
+-  FILE*          fp;
+-  char          *result;
++int
++mb_kbd_config_load(MBKeyboard *kbd, char *variant_in)
++{
+   char          *country  = NULL;  
+   char          *variant  = NULL;
+   char          *lang     = NULL;
+@@ -195,7 +196,44 @@ config_load_file(MBKeyboard *kbd, char *
+       if (util_file_readable(path))
+ 	goto load;
+ 
+-      return NULL;
++      return 0;
++    }
++
++  if (getenv("HOME"))
++    {
++      snprintf(path, 1024, "%s/.matchbox/keyboard.d", getenv("HOME"));
++
++      DBG("checking %s\n", path);
++
++      if (util_file_readable(path))
++        {
++          DIR *dir = opendir(path);
++          struct dirent *dirent;
++          if (!dir)
++            {
++              perror("matchbox-keyboard");
++              util_fatal_error("Cannot read keyboard.d.\n");
++            }
++          errno = 0;
++          while ((dirent = readdir(dir)))
++            {
++              if (dirent->d_name[0] == '.')
++                continue;
++              snprintf(path, 1024, "%s/.matchbox/keyboard.d/%s", getenv("HOME"), dirent->d_name);
++              if (!mb_kbd_config_parse_file(kbd, path))
++                {
++                  util_fatal_error("Cannot read file in keyboard.d.\n");
++                }
++
++            }
++          if (errno)
++            {
++              perror("matchbox-keyboard");
++              util_fatal_error("Error reading keyboard.d.\n");
++            }
++          closedir(dir);
++          return 1;
++        }
+     }
+ 
+   lang = getenv("MB_KBD_LANG");
+@@ -268,29 +306,11 @@ config_load_file(MBKeyboard *kbd, char *
+   DBG("checking %s\n", path);
+ 
+   if (!util_file_readable(path))
+-    return NULL;
++    return 0;
+ 
+  load:
+ 
+-  if (stat(path, &stat_info)) 
+-    return NULL;
+-
+-  if ((fp = fopen(path, "rb")) == NULL) 
+-    return NULL;
+-
+-  DBG("loading %s\n", path);
+-
+-  kbd->config_file = strdup(path);
+-
+-  result = malloc(stat_info.st_size + 1);
+-
+-  n = fread(result, 1, stat_info.st_size, fp);
+-
+-  if (n >= 0) result[n] = '\0';
+-  
+-  fclose(fp);
+-
+-  return result;
++  return mb_kbd_config_parse_file(kbd, path);
+ }
+ 
+ static const char *
+@@ -567,25 +587,48 @@ config_xml_start_cb(void *data, const ch
+ 
+ 
+ int
+-mb_kbd_config_load(MBKeyboard *kbd, char *variant)
+-{
+-  char                  *data;
++mb_kbd_config_parse_file(MBKeyboard *kbd, char *path)
++{
++  char *buffer;
++  struct stat    stat_info;
++  FILE*          fp;
++  int n;
++
++  if (stat(path, &stat_info)) 
++    return 0;
++
++  if ((fp = fopen(path, "rb")) == NULL) 
++    return 0;
++
++  DBG("loading %s\n", path);
++
++  kbd->config_file = strdup(path);
++
++  buffer = malloc(stat_info.st_size + 1);
++
++  n = fread(buffer, 1, stat_info.st_size, fp);
++
++  if (n >= 0) buffer[n] = '\0';
++  
++  fclose(fp);
++
++  mb_kbd_config_parse_data(kbd, buffer);
++
++  free(buffer);
++
++  return 1;
++}
++
++static int
++mb_kbd_config_parse_data(MBKeyboard *kbd, char *data)
++{
+   XML_Parser             p;
+   MBKeyboardConfigState *state;
+ 
+-  if ((data = config_load_file(kbd, variant)) == NULL)
+-    util_fatal_error("Couldn't find a keyboard config file\n");
+-
+   p = XML_ParserCreate(NULL);
+ 
+   if (!p) 
+     util_fatal_error("Couldn't allocate memory for XML parser\n");
+-
+-  if (variant && !strstr(kbd->config_file, variant))
+-    fprintf(stderr, 
+-	    "matchbox-keyboard: *Warning* Unable to locate variant: %s\n"
+-	    "                   falling back to %s\n",
+-	    variant, kbd->config_file);%s
>>> DIFF TRUNCATED @ 16K






More information about the Openembedded-commits mailing list