summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-09-29 19:44:32 +0200
committerLennart Poettering <lennart@poettering.net>2011-09-29 19:44:34 +0200
commita0ccd2acab443f5fa33e464a7e2f756dff2a5e35 (patch)
tree30e69cb2a05ffed09d0e27d713646c24e2ee1a9c /src
parentf176b5c296ad36119aa2464f9fd738e6da59eeee (diff)
localed: handle multiple X11 kbd layouts
https://bugs.freedesktop.org/show_bug.cgi?id=41341
Diffstat (limited to 'src')
-rw-r--r--src/localed.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/src/localed.c b/src/localed.c
index 16557b6f2b..e627c3a716 100644
--- a/src/localed.c
+++ b/src/localed.c
@@ -860,18 +860,46 @@ static int convert_x11_to_vconsole(DBusConnection *connection) {
break;
/* Determine how well matching this entry is */
- if (streq_ptr(x11_layout, a[1])) {
- matching ++;
+ if (streq_ptr(x11_layout, a[1]))
+ /* If we got an exact match, this is best */
+ matching = 10;
+ else {
+ size_t x;
+
+ x = strcspn(x11_layout, ",");
+
+ /* We have multiple X layouts, look
+ * for an entry that matches our key
+ * with the everything but the first
+ * layout stripped off. */
+ if (x > 0 &&
+ strlen(a[1]) == x &&
+ strncmp(x11_layout, a[1], x) == 0)
+ matching = 5;
+ else {
+ size_t w;
+
+ /* If that didn't work, strip
+ * off the other layouts from
+ * the entry, too */
+
+ w = strcspn(a[1], ",");
+
+ if (x > 0 && x == w &&
+ memcmp(x11_layout, a[1], x) == 0)
+ matching = 1;
+ }
+ }
+
+ if (matching > 0 &&
+ streq_ptr(x11_model, a[2])) {
+ matching++;
- if (streq_ptr(x11_model, a[2])) {
+ if (streq_ptr(x11_variant, a[3])) {
matching++;
- if (streq_ptr(x11_variant, a[3])) {
+ if (streq_ptr(x11_options, a[4]))
matching++;
-
- if (streq_ptr(x11_options, a[4]))
- matching++;
- }
}
}