diff options
author | Paul Sokolovsky <pmiscml@gmail.com> | 2007-06-11 13:36:25 +0000 |
---|---|---|
committer | Paul Sokolovsky <pmiscml@gmail.com> | 2007-06-11 13:36:25 +0000 |
commit | 4ce057ac6e3ec54c9e32faca581d98956a42768e (patch) | |
tree | 945cd41372795d759528b115258081e2f3d13b8d /packages/matchbox-keyboard/files | |
parent | 1e705365335cdaac70e4dad67b938646c527289f (diff) |
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.
Diffstat (limited to 'packages/matchbox-keyboard/files')
5 files changed, 558 insertions, 0 deletions
diff --git a/packages/matchbox-keyboard/files/2-Add-new-modifier--layout--Used-to-cycle-thru-all-available-layouts.patch b/packages/matchbox-keyboard/files/2-Add-new-modifier--layout--Used-to-cycle-thru-all-available-layouts.patch new file mode 100644 index 0000000000..2d05e5d652 --- /dev/null +++ b/packages/matchbox-keyboard/files/2-Add-new-modifier--layout--Used-to-cycle-thru-all-available-layouts.patch @@ -0,0 +1,91 @@ +# HG changeset patch +# User pfalcon@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); + diff --git a/packages/matchbox-keyboard/files/3-Changes-to-improve-layout-rendering--especially-after-adding-support-for.patch b/packages/matchbox-keyboard/files/3-Changes-to-improve-layout-rendering--especially-after-adding-support-for.patch new file mode 100644 index 0000000000..8513b6ed86 --- /dev/null +++ b/packages/matchbox-keyboard/files/3-Changes-to-improve-layout-rendering--especially-after-adding-support-for.patch @@ -0,0 +1,94 @@ +# HG changeset patch +# User pfalcon@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; + diff --git a/packages/matchbox-keyboard/files/4-Add-rendering-debug-logging.patch b/packages/matchbox-keyboard/files/4-Add-rendering-debug-logging.patch new file mode 100644 index 0000000000..7ce61e469c --- /dev/null +++ b/packages/matchbox-keyboard/files/4-Add-rendering-debug-logging.patch @@ -0,0 +1,65 @@ +# HG changeset patch +# User pfalcon@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) diff --git a/packages/matchbox-keyboard/files/5-Add-support-for-loading-multiple-independent-layouts.patch b/packages/matchbox-keyboard/files/5-Add-support-for-loading-multiple-independent-layouts.patch new file mode 100644 index 0000000000..1480591930 --- /dev/null +++ b/packages/matchbox-keyboard/files/5-Add-support-for-loading-multiple-independent-layouts.patch @@ -0,0 +1,197 @@ +# HG changeset patch +# User pfalcon@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); + + state = util_malloc0(sizeof(MBKeyboardConfigState)); + +@@ -607,6 +650,9 @@ mb_kbd_config_load(MBKeyboard *kbd, char + util_fatal_error("XML Parse failed.\n"); + } + ++ free(state); ++ XML_ParserFree(p); ++ + return 1; + } + diff --git a/packages/matchbox-keyboard/files/6-Add-layout-switch-key-to-all-layouts.patch b/packages/matchbox-keyboard/files/6-Add-layout-switch-key-to-all-layouts.patch new file mode 100644 index 0000000000..c2cf4d62dd --- /dev/null +++ b/packages/matchbox-keyboard/files/6-Add-layout-switch-key-to-all-layouts.patch @@ -0,0 +1,111 @@ +# HG changeset patch +# User pfalcon@localhost +# Date 1181568553 0 +# Node ID edc3fd8303a394bccadde2f427ab25ebda4fcbc8 +# Parent 869314ae90f46a8c2d34080005d4079cb0d0fcf4 +Add layout switch key to all layouts. + +diff -r 869314ae90f4 -r edc3fd8303a3 layouts/keyboard-dvorak.xml +--- a/layouts/keyboard-dvorak.xml Mon Jun 11 13:07:08 2007 +0000 ++++ b/layouts/keyboard-dvorak.xml Mon Jun 11 13:29:13 2007 +0000 +@@ -271,6 +271,10 @@ Contributed by Leon Matthews http://www. + <!-- Bottom Row --> + <row> + <space width="500" extended="true"/> ++ <key> ++ <default display="[->]" action="modifier:layout"/> ++ </key> ++ + <key> + <default display="äëö" action="modifier:mod1"/> + </key> +diff -r 869314ae90f4 -r edc3fd8303a3 layouts/keyboard-extended.xml +--- a/layouts/keyboard-extended.xml Mon Jun 11 13:07:08 2007 +0000 ++++ b/layouts/keyboard-extended.xml Mon Jun 11 13:29:13 2007 +0000 +@@ -304,6 +304,10 @@ + </row> + <row> + <key> ++ <default display="[->]" action="modifier:layout"/> ++ </key> ++ ++ <key> + <default display="aeo" action="modifier:mod1"/> + </key> + +diff -r 869314ae90f4 -r edc3fd8303a3 layouts/keyboard-fi.xml +--- a/layouts/keyboard-fi.xml Mon Jun 11 13:07:08 2007 +0000 ++++ b/layouts/keyboard-fi.xml Mon Jun 11 13:29:13 2007 +0000 +@@ -329,6 +329,10 @@ + <space width="500" extended="true"/> + + ++ <key> ++ <default display="[->]" action="modifier:layout"/> ++ </key> ++ + <key fill="true"> + <default display="Ctrl" action="modifier:ctrl"/> + </key> +diff -r 869314ae90f4 -r edc3fd8303a3 layouts/keyboard-numpad.xml +--- a/layouts/keyboard-numpad.xml Mon Jun 11 13:07:08 2007 +0000 ++++ b/layouts/keyboard-numpad.xml Mon Jun 11 13:29:13 2007 +0000 +@@ -54,6 +54,13 @@ + </key> + </row> + ++ <row> ++ <key> ++ <default display="[->]" action="modifier:layout"/> ++ </key> ++ </row> ++ ++ + </layout> + + +diff -r 869314ae90f4 -r edc3fd8303a3 layouts/keyboard-ru.xml +--- a/layouts/keyboard-ru.xml Mon Jun 11 13:07:08 2007 +0000 ++++ b/layouts/keyboard-ru.xml Mon Jun 11 13:29:13 2007 +0000 +@@ -302,10 +302,10 @@ + <space width="500" extended="true"/> + + <key> ++ <default display="[->]" action="modifier:layout"/> ++ </key> ++ <key> + <default display="äëö" action="modifier:mod1"/> +- </key> +- <key> +- <default display="EN" action="modifier:mod2"/> + </key> + + <key fill="true"> +diff -r 869314ae90f4 -r edc3fd8303a3 layouts/keyboard-us.xml +--- a/layouts/keyboard-us.xml Mon Jun 11 13:07:08 2007 +0000 ++++ b/layouts/keyboard-us.xml Mon Jun 11 13:29:13 2007 +0000 +@@ -326,6 +326,10 @@ + <space width="500" extended="true"/> + + <key> ++ <default display="[->]" action="modifier:layout"/> ++ </key> ++ ++ <key> + <default display="äëö" action="modifier:mod1"/> + </key> + +diff -r 869314ae90f4 -r edc3fd8303a3 layouts/keyboard.xml +--- a/layouts/keyboard.xml Mon Jun 11 13:07:08 2007 +0000 ++++ b/layouts/keyboard.xml Mon Jun 11 13:29:13 2007 +0000 +@@ -324,6 +324,10 @@ + <space width="500" extended="true"/> + + <key> ++ <default display="[->]" action="modifier:layout"/> ++ </key> ++ ++ <key> + <default display="äëö" action="modifier:mod1"/> + </key> + |