Hi,

Danilo Segan wrote:
> 
> PS. Did you make your mind on the "_XKB_{ALT|CONTROL}_FALLBACK_TO" issue?

  Yes.  Since there are not more opinions I can write a summary.
We have three suggestions: my one with environment variables, Vasilis's offer
with a trying all groups in turn and your one.
  Of course, my approach is worst.  I just chose a way that is simplest for me.
  The Vasilis's suggestion is better.  In this case an appropriate group search
is invisible for users but quite reliable.  Of course, I can imagine a situation
where such behavior can be considered as unexpected and unwanted one (I mean
a user would like Xlib fallback to the second or the third group but it gave him
the first one).  But I think it's rather an imaginary case and will never
happen.
  Your offer looks like an ideal.  Certanly, to have a separate map for
a fallback (actally it doesn't need to be a full xkb group but just a simple
one-level map) and allow a user to choose it by xkb options if he want, is
a best approach.  But what you describe is an external look only.  To make it
we need some serious changes in Xlib, xkbcomp, servers internal structures and
maybe in the protocol of an XKB extension.
  If there is a volunteer for this task I would be glad but it isn't me
at least now.

  I made a patch according to Vasilis's suggestion.  You can test it.
-- 
 Ivan U. Pascal         |   e-mail: [EMAIL PROTECTED]
   Administrator of     |   Tomsk State University
     University Network |       Tomsk, Russia
--- xc/lib/X11/XKBBind.c.orig   Wed Mar 19 19:37:38 2003
+++ xc/lib/X11/XKBBind.c        Sat Mar 22 20:25:28 2003
@@ -768,6 +768,37 @@
        return 0;
     new_mods= (event->state&(~new_mods));
 
+    /* find the group where a symbol can be converted to control one */
+    if (new_mods&ControlMask && *keysym > 0x7F &&
+       (dpy->xkb_info->xlib_ctrls & XkbLC_ControlFallback)) {
+       XKeyEvent tmp_ev = *event;
+       KeySym tmp_keysym;
+       unsigned int tmp_new_mods;
+        if (_XkbUnavailable(dpy)) {
+            tmp_ev.state= event->state ^ dpy->mode_switch;
+            if (XkbLookupKeySym(dpy, tmp_ev.keycode, tmp_ev.state,
+                                &tmp_new_mods, &tmp_keysym) &&
+                tmp_keysym != NoSymbol && tmp_keysym < 0x80 ) {
+                *keysym = tmp_keysym;
+            }
+        } else {
+            int n = XkbKeyNumGroups(dpy->xkb_info->desc, tmp_ev.keycode);
+            int i;
+            for (i = 0; i < n; i++) {
+               if (XkbGroupForCoreState(event->state) == i)
+                   continue;
+                tmp_ev.state= XkbBuildCoreState(tmp_ev.state, i);
+                if (XkbLookupKeySym(dpy, tmp_ev.keycode, tmp_ev.state,
+                                     &tmp_new_mods, &tmp_keysym) &&
+                    tmp_keysym != NoSymbol && tmp_keysym < 0x80 ) {
+                    *keysym = tmp_keysym;
+                    new_mods= (event->state&(~tmp_new_mods));
+                    break;
+                }
+           }
+        }
+    }
+
 #ifdef USE_OWN_COMPOSE
     if ( status ) {
        static int been_here= 0;
@@ -873,27 +904,7 @@
     if (rtrnLen>0)
        return rtrnLen;
 
-    rtrnLen = XkbTranslateKeySym(dpy,keysym,new_mods,buffer,nbytes,NULL);
-
-    if ((event->state&ControlMask)&&(nbytes>0)&&
-                       ((rtrnLen==0)||
-                        ((rtrnLen==1)&&((unsigned char) buffer[0]>=' ')))&&
-                       (dpy->xkb_info->xlib_ctrls&XkbLC_ControlFallback)) {
-       XKeyEvent       tmp_ev;
-       tmp_ev= *event;
-        if (_XkbUnavailable(dpy)) {
-            if (event->state & dpy->mode_switch) {
-                tmp_ev.state= event->state & ~dpy->mode_switch;
-               return XLookupString (&tmp_ev, buffer, nbytes, keysym, status);
-           }
-        } else {
-            if (XkbGroupForCoreState(event->state) != XkbGroup1Index) {
-                tmp_ev.state= XkbBuildCoreState(event->state,XkbGroup1Index);
-               return XLookupString (&tmp_ev, buffer, nbytes, keysym, status);
-           }
-        }
-    }
-    return rtrnLen;
+    return XkbTranslateKeySym(dpy,keysym,new_mods,buffer,nbytes,NULL);
 }
 
 

Reply via email to