[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#348027: errors in Turkish keyboard setup



* Denis Barbier [2006-01-15 10:22:21+0100]
> On Sun, Jan 15, 2006 at 04:24:17AM +0200, Recai Oktaş wrote:
> > > I tested your code, and have one remark: you change tr_f -> f when
> > > debian-installer/keymap is known, but you may also perform this
> > > change after user selected a variant, he may get used to tr_f and
> > > not know about this name change.
> > 
> > You're right, the second patch is problematic.  But as far as I can see it,
> > the first one has not a flaw in this respect, since the TR handling code is
> > in the:
> > 
> >    if [ -n "$RECONFIGURE" ] || [ -n "$FIRSTINST" ]; then
> > 
> > body, before the db_inputs.  Have I understood it correctly?
> 
> The problem is precisely that it appears before db_inputs.  So if
> XMAP is UNKNOWN, or if previous value was different from tr but
> user selects tr this time, variant is not sanitized.  Maybe this
> sanitization could be performed at the end, just before writing
> xorg.conf, to make sure that tr_{f,alt} variants are not written
> into this file?

Ok, I understood it now.  I had thought that you meant we should not
silently overwrite the users' choice. :-)

How about the attached patch?  This one sanitizes the variant just after
the user's input.  It's also kludgy, but I couldn't find a better way.

-- 
roktas
--- xserver-xorg.config.in.orig	2006-01-12 03:11:03.000000000 +0200
+++ xserver-xorg.config.in	2006-01-15 12:37:40.000000000 +0200
@@ -960,7 +960,7 @@
     br-abnt2--ie*) XMAP="ie";;
     br-abnt2--*) XMAP="br"; OPTIONS="abnt2";;
     by--*) XMAP="by";;
-    cf--tr*) XMAP="tr"; OPTIONS="tr_f";;
+    cf--tr*) XMAP="tr"; VARIANT="f";;
     cf--ie*) XMAP="ie";;
     cf--lv*) XMAP="lv";;
     cf--it*) XMAP="it";;
@@ -1009,7 +1009,7 @@
     gr--ua*) XMAP="ua";;
     gr--by*) XMAP="by";;
     gr--tj*) XMAP="tj";;
-    gr--tr*) XMAP="tr_f";;
+    gr--tr*) XMAP="tr"; VARIANT="f";;
     gr--uz*) XMAP="uz";;
     hu--*) XMAP="hu";;
     is-latin1--*) XMAP="is";;
@@ -1029,7 +1029,7 @@
     lt--tj*) XMAP="tj";;
     lt--lv*) XMAP="lv";;
     lt--mt*) XMAP="mt_us";;
-    lt--tr*) XMAP="tr"; OPTIONS="tr_f";;
+    lt--tr*) XMAP="tr"; VARIANT="f";;
     lt--uz*) XMAP="uz";;
     lt--*) XMAP="lt";;
     mac-us-std--*) XMAP="us";;
@@ -1037,7 +1037,7 @@
     mac-fr2-ext--*) XMAP="fr";;
     mac-fr3--*) XMAP="fr";;
     mac-es--*) XMAP="es";;
-    mk--tr*) XMAP="tr"; OPTIONS="tr_f";;
+    mk--tr*) XMAP="tr"; VARIANT="f";;
     mk--sr*) XMAP="sr";;
     mk--hr*) XMAP="hr";;
     no-latin1--*) XMAP="no";;
@@ -1065,14 +1065,18 @@
     sg-latin1--fr*) XMAP="ch"; OPTIONS="fr";;
     sk-qwerty--cz*) XMAP="cz_querty";;
     sk-qwerty--*) XMAP="sk_querty";;
-    sr-cy--tr*) XMAP="tr"; OPTIONS="tr_f";;
+    sr-cy--tr*) XMAP="tr"; VARIANT="f";;
     sr-cy--yu*) XMAP="yu";;
     sr-cy--*) XMAP="sr";;
+    tralt--*) XMAP="tr"; VARIANT="alt";;
     trfu--hu*) XMAP="hu"; OPTIONS="qwerty";;
     trfu--yu*) XMAP="yu";;
-    trfu--*) XMAP="tr"; OPTIONS="tr_f";;
+    trf--*) XMAP="tr"; VARIANT="f";;
+    trfu--*) XMAP="tr"; VARIANT="f";;
+    trq--*) XMAP="tr";;
+    *trqalt*) XMAP="tr"; VARIANT="alt";;
     trqu--*) XMAP="tr";;
-    ua--tr*) XMAP="tr"; OPTIONS="tr_f";;
+    ua--tr*) XMAP="tr"; VARIANT="f";;
     ua--by*) XMAP="by";;
     ua--*) XMAP="ua";;
     uk--mt*) XMAP="mt";;
@@ -1167,6 +1171,15 @@
     PRIORITY=high
   else
     PRIORITY=low
+
+    # for Turkish, ensure to add "caps:shift" to make Caps Lock behave correctly
+    if [ "$XMAP" = "tr" ]; then
+      case "$OPTIONS" in
+        *caps:shift*) ;; # do nothing if it's already defined
+        "") OPTIONS="caps:shift" ;;
+         *) OPTIONS="$OPTIONS,caps:shift" ;;
+      esac
+    fi
   fi
 
   # we can't do non-Latin usernames, so people with Latin layouts need a US
@@ -1190,6 +1203,7 @@
 
   XKBLAYOUT="$XMAP"
   XKBOPTIONS="$OPTIONS"
+  XKBVARIANT="$VARIANT"
 else
   db_get xserver-xorg/config/inputdevice/keyboard/layout || debug_report_status "db_get xserver-xorg/config/inputdevice/keyboard/layout"
   XKBLAYOUT="$RET"
@@ -1234,10 +1248,64 @@
 if [ "$RET" = "us" ]; then
   PRIORITY=low
 elif [ "$RET" = "br" ]; then
-  db_set xserver-xorg/config/inputdevice/keyboard/variant "abnt2"
+    # add "abnt2" option
+    case "$XKBVARIANT" in
+      *abnt2*) ;; # do nothing if it's already defined
+      "") XKBVARIANT="abnt2" ;;
+       *) XKBVARIANT="$XKBVARIANT,abnt2" ;;
+    esac
 fi
+
+db_set xserver-xorg/config/inputdevice/keyboard/variant "$XKBVARIANT"
 MAY_BE_NULL=yes validate_string_db_input "$(priority_ceil $PRIORITY)" xserver-xorg/config/inputdevice/keyboard/variant
 
+# handle Turkish keyboard setup specially due to its oddities
+db_get xserver-xorg/config/inputdevice/keyboard/layout
+if [ "$RET" = "tr" ]; then
+  TR_KEYMAP="$CONFIG_DIR/xkb/symbols/pc/tr"
+
+  db_get xserver-xorg/config/inputdevice/keyboard/variant
+  TR_VARIANT="$RET"
+
+  case "$TR_VARIANT" in
+    f|*,f|f,*|*,f,*|*tr_f*)
+      # X.Org version < 6.9 uses "tr_f", while >= 6.9 uses only "f"
+      if [ -e "$TR_KEYMAP" ] &&
+        grep -q "^[[:space:]]*xkb_symbols[[:space:]]*\"tr_f\"" $TR_KEYMAP; then
+        SANITIZED_TR_VARIANT="tr_f"
+      else
+        SANITIZED_TR_VARIANT="f"
+      fi
+      ;;
+    alt|*,alt|alt,*|*,alt,*|*tr_alt*)
+      # X.Org version < 6.9 uses "tr_alt", while >= 6.9 uses only "alt"
+      if [ -e "$TR_KEYMAP" ] &&
+        grep -q "^[[:space:]]*xkb_symbols[[:space:]]*\"tr_alt\"" $TR_KEYMAP; then
+        SANITIZED_TR_VARIANT="tr_alt"
+      else
+        SANITIZED_TR_VARIANT="alt"
+      fi
+      ;;
+  esac
+
+  if [ -n "$SANITIZED_TR_VARIANT" ]; then
+    # remove the unsanitized variant
+    TR_VARIANT=$(echo $TR_VARIANT | \
+                 sed -e "s/\<\(tr_\)*\(f\|alt\)[[:space:]]*,//g" \
+                     -e "s/\(^\|,\)[[:space:]]*\(tr_\)*\(f\|alt\)[[:space:]]*$//g")
+
+    # add the sanitized variant
+    if [ -n "$TR_VARIANT" ]; then
+      TR_VARIANT="$SANITIZED_TR_VARIANT"
+    else
+      TR_VARIANT="$TR_VARIANT,$SANITIZED_TR_VARIANT"
+    fi
+    
+    # now, re-commit the variant to debconf
+    db_set xserver-xorg/config/inputdevice/keyboard/variant "$TR_VARIANT"
+  fi
+fi
+
 # ugly kludge, I know; map Apple->AltGr for most European Macs
 db_get xserver-xorg/config/inputdevice/keyboard/model
 if [ "$ARCH" = "powerpc" ] && [ "$RET" = "pc105" ]; then

Reply to: