solaris-kbd.patch revision 1112
1607N/A###############################################################################
1607N/A# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
1607N/A#
1607N/A# Permission is hereby granted, free of charge, to any person obtaining a
1607N/A# copy of this software and associated documentation files (the "Software"),
1607N/A# to deal in the Software without restriction, including without limitation
1607N/A# the rights to use, copy, modify, merge, publish, distribute, sublicense,
1607N/A# and/or sell copies of the Software, and to permit persons to whom the
1607N/A# Software is furnished to do so, subject to the following conditions:
1607N/A#
1607N/A# The above copyright notice and this permission notice (including the next
1607N/A# paragraph) shall be included in all copies or substantial portions of the
1607N/A# Software.
1607N/A#
1607N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1607N/A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1607N/A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1607N/A# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1607N/A# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1607N/A# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1607N/A# DEALINGS IN THE SOFTWARE.
1607N/A#
1607N/A
1607N/A
1607N/Adiff -Nurp -x '*~' -x '*.orig' src/KeyBind.c src/KeyBind.c
1607N/A--- src/KeyBind.c 2011-03-24 22:34:22.000000000 -0700
1607N/A+++ src/KeyBind.c 2011-04-06 13:52:16.519172102 -0700
1607N/A@@ -45,6 +45,7 @@ in this Software without prior written a
2457N/A #define XK_VIETNAMESE
2478N/A #define XK_XKB_KEYS
1607N/A #define XK_SINHALA
2284N/A+#define XK_CURRENCY
2284N/A #include <X11/keysymdef.h>
2375N/A #include <stdio.h>
1607N/A
1607N/A@@ -56,6 +57,20 @@ in this Software without prior written a
1607N/A #include "Xresource.h"
1607N/A #include "Key.h"
2375N/A
2375N/A+#ifdef SUNSOFT_KBD
1607N/A+/* Sun: compose sequence support
1607N/A+ * (state = chars_matched in XComposeStatus)
1607N/A+ */
1607N/A+#include "Suncompose.h"
1607N/A+#include <X11/Sunkeysym.h>
2375N/A+#define REJECTED -1
1607N/A+#define START 0
1607N/A+#define ACCEPTED1 1
2433N/A+#define ACCEPTED2 2
2284N/A+#define ACCEPTED3 3
1607N/A+#define COMPOSE_LED 2
2433N/A+#endif /* SUNSOFT_KBD */
2433N/A+
2433N/A #ifdef XKB
2433N/A #include "XKBlib.h"
2433N/A #include "XKBlibint.h"
1607N/A@@ -77,6 +92,11 @@ ComputeMaskFromKeytrans(
1607N/A Display *dpy,
1607N/A register struct _XKeytrans *p);
1607N/A
1607N/A+#ifdef SUNSOFT_KBD
1607N/A+static int DoCompose();
1607N/A+ void SetLed (Display *dpy, int num, int state);
1607N/A+#endif /* SUNSOFT_KBD */
2375N/A+
2375N/A struct _XKeytrans {
1607N/A struct _XKeytrans *next;/* next on list */
1607N/A char *string; /* string to return when the time comes */
1607N/A@@ -98,6 +118,10 @@ KeyCodetoKeySym(register Display *dpy, K
1607N/A ((int)keycode < dpy->min_keycode) || ((int)keycode > dpy->max_keycode))
2415N/A return NoSymbol;
1607N/A
1607N/A+/* Sun comment: We need not protect dpy->keysyms[], because,
1607N/A+ * this is * changed only in the initialize routine and
1607N/A+ * XOpenDisplay().
1607N/A+ */
1607N/A syms = &dpy->keysyms[(keycode - dpy->min_keycode) * per];
1607N/A if (col < 4) {
1607N/A if (col > 1) {
1607N/A@@ -766,6 +790,9 @@ _XTranslateKey( register Display *dpy,
1929N/A int per;
2415N/A register KeySym *syms;
2415N/A KeySym sym, lsym, usym;
1607N/A+#ifdef SUNSOFT_KBD
2415N/A+ int i, column, KeypadKey;
2415N/A+#endif /* SUNSOFT_KBD */
2433N/A
2433N/A if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
2433N/A return 0;
2433N/A@@ -780,17 +807,54 @@ _XTranslateKey( register Display *dpy,
2433N/A syms = &dpy->keysyms[(keycode - dpy->min_keycode) * per];
2433N/A while ((per > 2) && (syms[per - 1] == NoSymbol))
2433N/A per--;
2433N/A+
2433N/A+#ifdef SUNSOFT_KBD
2433N/A+ /* Sun: Japanese keypad support */
2433N/A+ KeypadKey = 0;
1607N/A+ if (per < 5)
2375N/A+ {
2375N/A+ /* in case of Hobo keyboards, the keypad would be
2433N/A+ * superimposed on the other (qwerty) keys. So by doing
2375N/A+ * this * check, we would not get the Japanese keysyms
2433N/A+ * on the * Hobo keypad superimposed keys.
2375N/A+ */
2457N/A+ for (i=0; i < per; i++)
2375N/A+ {
2457N/A+ if (IsKeypadKey(syms[i]))
2457N/A+ KeypadKey = 1;
2457N/A+ }
2457N/A+ }
2457N/A+#endif /* SUNSOFT_KBD */
2507N/A+
2457N/A if ((per > 2) && (modifiers & dpy->mode_switch)) {
2457N/A+#ifdef SUNSOFT_KBD
2457N/A+/* Sun: ModeSwitch does not apply to function keys (Japanese kbd) */
2457N/A+ if (!KeypadKey)
2457N/A+ {
2457N/A+#endif /* SUNSOFT_KBD */
2457N/A syms += 2;
2457N/A per -= 2;
2457N/A+#ifdef SUNSOFT_KBD
2478N/A+ }
2457N/A+#endif /* SUNSOFT_KBD */
2478N/A }
2478N/A+
2457N/A+#ifdef SUNSOFT_KBD
2457N/A+ if ((modifiers & dpy->num_lock) &&
2457N/A+ (per > 1 && (IsKeypadKey(syms[2]) ))) {
2457N/A+#else
2457N/A if ((modifiers & dpy->num_lock) &&
2457N/A (per > 1 && (IsKeypadKey(syms[1]) || IsPrivateKeypadKey(syms[1])))) {
2457N/A+#endif /* SUNSOFT_KBD */
2457N/A if ((modifiers & ShiftMask) ||
2457N/A ((modifiers & LockMask) && (dpy->lock_meaning == XK_Shift_Lock)))
2457N/A *keysym_return = syms[0];
2457N/A else
2457N/A+#ifdef SUNSOFT_KBD
2457N/A+ *keysym_return = syms[2];
2457N/A+#else
2457N/A *keysym_return = syms[1];
2457N/A+#endif /* SUNSOFT_KBD */
2457N/A } else if (!(modifiers & ShiftMask) &&
2457N/A (!(modifiers & LockMask) || (dpy->lock_meaning == NoSymbol))) {
2457N/A if ((per == 1) || (syms[1] == NoSymbol))
2457N/A@@ -818,19 +882,41 @@ _XTranslateKey( register Display *dpy,
2457N/A
2457N/A int
2375N/A _XTranslateKeySym(
1607N/A- Display *dpy,
2433N/A- register KeySym symbol,
2375N/A- unsigned int modifiers,
2433N/A- char *buffer,
2375N/A- int nbytes)
2457N/A+ Display * dpy,
2375N/A+#ifdef SUNSOFT_KBD
2457N/A+ register KeySym * keysym,
2457N/A+#else
2457N/A+ register KeySym keysym,
2457N/A+#endif
2457N/A+ unsigned int modifiers,
2507N/A+ char * buffer,
2457N/A+ int nbytes
2457N/A+#ifdef SUNSOFT_KBD
2457N/A+ ,
2457N/A+ XKeyEvent * event,
2457N/A+ XComposeStatus * status
2457N/A+#endif
2457N/A+ )
2457N/A {
2457N/A register struct _XKeytrans *p;
2478N/A int length;
2457N/A unsigned long hiBytes;
2478N/A register unsigned char c;
2478N/A-
2457N/A+ KeySym symbol;
2457N/A+#ifdef SUNSOFT_KBD
2457N/A+ int return_val;
2457N/A+#endif /* SUNSOFT_KBD */
2457N/A+
2457N/A+#ifdef SUNSOFT_KBD
2457N/A+ if (!keysym)
2457N/A+ return 0;
2457N/A+ else
2457N/A+ symbol = *keysym;
2457N/A+#else
2457N/A if (!symbol)
2457N/A return 0;
2457N/A+#endif /* SUNSOFT_KBD */
2457N/A+
2457N/A /* see if symbol rebound, if so, return that string. */
2457N/A for (p = dpy->key_bindings; p; p = p->next) {
2457N/A if (((modifiers & AllMods) == p->state) && (symbol == p->key)) {
2457N/A@@ -844,8 +930,29 @@ _XTranslateKeySym(
2457N/A hiBytes = symbol >> 8;
2457N/A if (!(nbytes &&
2457N/A ((hiBytes == 0) ||
2375N/A+#ifdef SUNSOFT_KBD
2375N/A+/* The check for 0x100500 <= hiBytes < 0x100600 is Sun-specific.
2375N/A+ * This represents Sun's registered range of vendor-specific
2375N/A+ * keysyms. We need the check so that Sun specific keysyms will
2375N/A+ * pass through this check and onto to be handled by
2375N/A+ * HandleComposeSequence.
2375N/A+ */
2375N/A+ ((0x100500 <= hiBytes) && (hiBytes < 0x100600)) ||
2375N/A+/*
2375N/A+ * The following hard-coded line is to support the euro sign for legacy apps
2375N/A+ * and single byte codeset locale apps with the euro sign at 0xa4.
2375N/A+ * For any other codeset locales with properly internationalized apps,
2375N/A+ * one must have an entry in the Compose file of the locale that will map
2375N/A+ * the XK_EuroSign keysym to the correct character code value of the locale's
2375N/A+ * codeset.
2375N/A+ */
2375N/A+ (symbol == XK_EuroSign) ||
2375N/A+#endif /* SUNSOFT_KBD */
2375N/A ((hiBytes == 0xFF) &&
2375N/A (((symbol >= XK_BackSpace) && (symbol <= XK_Clear)) ||
2375N/A+#ifdef SUNSOFT_KBD
2375N/A+ (symbol == XK_Multi_key) ||
2375N/A+#endif /* SUNSOFT_KBD */
2375N/A (symbol == XK_Return) ||
2375N/A (symbol == XK_Escape) ||
2375N/A (symbol == XK_KP_Space) ||
2375N/A@@ -856,15 +963,35 @@ _XTranslateKeySym(
2375N/A (symbol == XK_Delete))))))
2375N/A return 0;
2375N/A
2375N/A+#ifdef SUNSOFT_KBD
2375N/A+ /* if this is a compose sequence, then HandleComposeSequence
2375N/A+ * already deals w/ this. This is Sun-specific.
1607N/A+ */
1607N/A+ if (HandleComposeSequence(symbol, buffer, keysym, status, &return_val, event)) {
1607N/A+ return return_val;
1607N/A+ }
1607N/A+#endif /* SUNSOFT_KBD */
1607N/A+
1607N/A /* if X keysym, convert to ascii by grabbing low 7 bits */
1607N/A if (symbol == XK_KP_Space)
1607N/A c = XK_space & 0x7F; /* patch encoding botch */
1607N/A else if (hiBytes == 0xFF)
1607N/A c = symbol & 0x7F;
1607N/A+#ifdef SUNSOFT_KBD
2375N/A+ else if (symbol == XK_EuroSign)
2375N/A+ c = (unsigned char)0xa4; /* Latin-9 euro symbol code for legacy apps. */
1607N/A+#endif /* SUNSOFT_KBD */
1607N/A else
1607N/A c = symbol & 0xFF;
2375N/A /* only apply Control key if it makes sense, else ignore it */
2375N/A if (modifiers & ControlMask) {
2375N/A+
2375N/A+#ifdef SUNSOFT_KBD
2375N/A+ /* Sun: map control characters with high bit set */
1607N/A+ if ((c >= (unsigned char)'\300' && c <= (unsigned char)'\377')) c &= 0x9F;
1607N/A+#endif /* SUNSOFT_KBD */
1607N/A+
1607N/A+ /* MIT "standard" control character handling */
1607N/A if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
1607N/A else if (c == '2') c = '\000';
1607N/A else if (c >= '3' && c <= '7') c -= ('3' - '\033');
1607N/A@@ -958,11 +1085,22 @@ XLookupString (
1607N/A }
1607N/A #endif
2375N/A
2375N/A+#ifdef SUNSOFT_KBD
2375N/A+ if (keysym) {
2375N/A+ *keysym = symbol;
2375N/A+ return _XTranslateKeySym(event->display, keysym, event->state,
2375N/A+ buffer, nbytes, event, status);
2375N/A+ } else {
2375N/A+ return _XTranslateKeySym(event->display, &symbol, event->state,
1607N/A+ buffer, nbytes, event, status);
+ }
+#else
if (keysym)
*keysym = symbol;
/* arguable whether to use (event->state & ~modifiers) here */
return _XTranslateKeySym(event->display, symbol, event->state,
buffer, nbytes);
+#endif /* SUNSOFT_KBD */
}
static void
@@ -1076,3 +1214,287 @@ ComputeMaskFromKeytrans(
}
p->state &= AllMods;
}
+
+#ifdef SUNSOFT_KBD
+/* added 2 functions:
+ * HandleComposeSequence and DoCompose;
+ */
+
+/* Called from XTranslateKeySym & XkbTranslateKeySymExt
+ * Look at compose sequence and dead key sequence and try to get
+ * a Latin-1 character out of it. Return 1 if it is able to
+ * resolve the lookup based on the info it has, return 0 if it
+ * can't, then XTranslateKeySym needs to do further processing.
+ */
+
+Bool compose_led_is_on = False;
+int compose_state = START;
+
+int
+HandleComposeSequence(
+ KeySym symbol,
+ char *buffer,
+ KeySym *keysym,
+ XComposeStatus *status,
+ int *return_val,
+ XKeyEvent *event)
+{
+ static char compose_sequence[5]; /* initialized to NULL */
+ static KeyCode last_composed_keycode; /* initialized to NULL */
+ static KeySym last_composed_keysym; /* initialized to NULL */
+ static char watching_keypresses = 0;
+ static int initialized = 0;
+ int ret_val;
+
+ /*
+ * Even if the caller doesn't pass us a compose structure, we'll still
+ * support compose sequence processing. Note that the client won't be able
+ * to support multiple compose sequence clients within a single application.
+ */
+
+ /* must come first */
+ if (status != (XComposeStatus *) NULL) {
+ /*
+ * The caller provided a structure so we'll track his state * (if reasonable) and we'll point him at our private
+ * compose_sequence (at bottom). This allows him to implement
+ * multiple compose sequence clients within a single application.
+ */
+ if (! initialized) { /* start him out right */
+ compose_state = START;
+ initialized = 1;
+
+ /* bug 4247009, vivekp, set the compose LED off very first
+ time, initialization time */
+ if (compose_led_is_on)
+ SetLed (event->display,COMPOSE_LED, LedModeOff);
+
+ } else { /* then track him */
+ compose_state = status->chars_matched;
+ if (compose_state < START || compose_state > ACCEPTED3) compose_state = START;
+ }
+ }
+
+ /* must come second */
+ if (event->type == KeyPress) {
+ /* if we've ever seen a KeyPress, we're watching KeyPresses */
+ watching_keypresses = 1;
+ } else if (event->type == KeyRelease && watching_keypresses) {
+ /*
+ * don't let someone watching both KeyPresses and KeyReleases
+ * screw us unwittingly. Try to return the right thing.
+ */
+ *return_val = 0;
+ if (compose_state > START) {
+ if (compose_state == ACCEPTED3 && event->keycode == last_composed_keycode) {
+ buffer[0] = last_composed_keysym;
+ *keysym = last_composed_keysym;
+ *return_val = 1;
+ }
+ return(1);
+ }
+ if ((*keysym == XK_Multi_key) ||
+ (*keysym == SunXK_FA_Circum) ||
+ (*keysym == SunXK_FA_Tilde) ||
+ (*keysym == SunXK_FA_Grave) ||
+ (*keysym == SunXK_FA_Acute) ||
+ (*keysym == SunXK_FA_Cedilla) ||
+ (*keysym == SunXK_FA_Diaeresis))
+ return(1);
+ return(0);
+ }
+
+ /* XTranslateKeysym filters these out before we get here, but the
+ * XKB version doesn't so we need to punt these here to avoid breaking
+ * compose sequences when modifiers like the shift key are pressed.
+ */
+ if (IsModifierKey(*keysym)) {
+ return (0);
+ }
+
+ if (compose_state == ACCEPTED3)
+ compose_state = START;
+
+ /* now we're ready */
+ switch (compose_state) {
+ case START:
+ if (*keysym == XK_Multi_key) {
+ /* bug 4247009, vivekp, set the compose LED when the
+ compose key is pressed first time. */
+ SetLed (event->display,COMPOSE_LED, LedModeOn);
+ compose_state = ACCEPTED1;
+ compose_led_is_on = True;
+ }
+ else if (*keysym == SunXK_FA_Circum) {
+ compose_sequence[0] = '^';
+ compose_state = ACCEPTED2;
+ }
+ else if (*keysym == SunXK_FA_Tilde) {
+ compose_sequence[0] = '~';
+ compose_state = ACCEPTED2;
+ }
+ else if (*keysym == SunXK_FA_Grave) {
+ compose_sequence[0] = '`';
+ compose_state = ACCEPTED2;
+ }
+ else if (*keysym == SunXK_FA_Acute) {
+ compose_sequence[0] = '\'';
+ compose_state = ACCEPTED2;
+ }
+ else if (*keysym == SunXK_FA_Cedilla) {
+ compose_sequence[0] = ',';
+ compose_state = ACCEPTED2;
+ }
+ else if (*keysym == SunXK_FA_Diaeresis){
+ compose_sequence[0] = '"';
+ compose_state = ACCEPTED2;
+ }
+ /* else don't change state */
+ break;
+
+ case ACCEPTED1: /* Got Compose last time */
+ if (*keysym < ASCII_SET_SIZE) {
+ if (compose_map[*keysym] >= 0) {
+ compose_sequence[0] = *keysym;
+ compose_state = ACCEPTED2;
+ }
+ else
+ compose_state = REJECTED;
+ }
+ else
+ compose_state = REJECTED;
+ break;
+
+ case ACCEPTED2: /* Got Compose + composable char */
+
+ /* bug 4247009, vivekp, set the compose LED off after
+ compose+composable char is pressed. */
+ SetLed (event->display,COMPOSE_LED, LedModeOff);
+ compose_led_is_on = False;
+ if (*keysym < ASCII_SET_SIZE) {
+ if (compose_map[*keysym] >= 0) {
+ compose_sequence[1] = *keysym;
+/*
+ * If the second character is space, compose sequence should return * the first character. See TBITS/NCTTI-5, Section 2.1
+ * Note: <Compose>+<space>+<space> = non-breaking space
+ */
+ if (compose_sequence[1] == XK_space &&
+ compose_sequence[0] != XK_space) {
+ *keysym = compose_sequence[0];
+ compose_state = ACCEPTED3;
+ } else {
+ if (compose_sequence[0] <= compose_sequence[1])
+ ret_val = DoCompose(compose_sequence[0],
+ compose_sequence[1], keysym);
+ else
+ ret_val = DoCompose(compose_sequence[1],
+ compose_sequence[0], keysym);
+ if (ret_val == 1) {
+ compose_state = ACCEPTED3;
+ compose_sequence[2] = *keysym;
+ }
+ else
+ compose_state = REJECTED;
+ }
+ }
+ else
+ compose_state = REJECTED;
+ }
+ else
+ compose_state = REJECTED;
+ break;
+
+ default:
+ compose_state = START;
+ break;
+ }
+
+ if (compose_state == REJECTED)
+ {
+ /* bug 4247009, vivekp, set the compose LED off after the
+ compose key pressed second time or composable + 1st char +
+ 2nd char. */
+ SetLed (event->display,COMPOSE_LED, LedModeOff);
+ compose_led_is_on = False;
+ compose_state = START;
+ }
+ if (status != (XComposeStatus *) NULL) {
+ /*
+ * Ok, since the caller provided a compose structure,
+ * we need to point him at our private compose_sequence
+ * and copy the new state back to him.
+ */
+ status->compose_ptr = compose_sequence;
+ status->chars_matched = compose_state;
+ }
+
+ if (compose_state == START) {
+ compose_sequence[0] = '\0';
+ last_composed_keycode = 0;
+ last_composed_keysym = 0;
+ if ((*keysym == XK_Multi_key) ||
+ (*keysym == SunXK_FA_Circum) ||
+ (*keysym == SunXK_FA_Tilde) ||
+ (*keysym == SunXK_FA_Grave) ||
+ (*keysym == SunXK_FA_Acute) ||
+ (*keysym == SunXK_FA_Cedilla) ||
+ (*keysym == SunXK_FA_Diaeresis)) {
+ *return_val = 0;
+ return(1);
+ }
+ return(0);
+ }
+
+ compose_sequence[compose_state-1] = '\0';
+ last_composed_keycode = event->keycode;
+ last_composed_keysym = *keysym;
+
+ if (compose_state == ACCEPTED3) {
+ buffer[0] = *keysym;
+ *return_val = 1;
+ }
+ else {
+ *return_val = 0;
+ }
+
+ return(1);
+}
+
+/*
+ * DoCompose - put result in keysym
+ */
+static int
+DoCompose(KeySym first_keysym, KeySym second_keysym, KeySym *result_keysym)
+{
+ ComposeTableEntry *ptr;
+
+ /* Note: this code presumes first_keysym rangecheck has
+ * been done in invoking routine.
+ */
+ ptr = &compose_table[compose_map[first_keysym]];
+ while (ptr->first == first_keysym) {
+ if (ptr->second == second_keysym) {
+ *result_keysym = ptr->result;
+ return (1);
+ }
+ ptr++;
+ }
+ return (0);
+}
+
+_X_HIDDEN void
+SetLed (Display *dpy, int num, int state)
+{
+ XKeyboardControl led_control;
+
+#ifdef XKB
+ if ((dpy->xkb_info == NULL) || (num != COMPOSE_LED) ||
+ XkbSetNamedIndicator(dpy,dpy->xkb_info->composeLED,
+ True,state,False,NULL) == False)
+#endif
+ {
+ led_control.led_mode = state;
+ led_control.led = num;
+ XChangeKeyboardControl (dpy, KBLed | KBLedMode, &led_control);
+ }
+}
+#endif /* SUNSOFT_KBD */
diff -Nurp -x '*~' -x '*.orig' src/xkb/XKBBind.c src/xkb/XKBBind.c
--- src/xkb/XKBBind.c 2011-01-29 10:09:13.000000000 -0800
+++ src/xkb/XKBBind.c 2011-04-06 13:52:16.519538005 -0700
@@ -577,6 +577,20 @@ XkbTranslateKeySym( register Display * d
int nbytes,
int * extra_rtrn)
{
+ /* Call the new extended function but put in NULL for the extra params */
+ return XkbTranslateKeySymExt(dpy, sym_rtrn, mods, buffer, nbytes, extra_rtrn, NULL, NULL);
+}
+
+static int
+XkbTranslateKeySymExt( register Display * dpy,
+ register KeySym * sym_rtrn,
+ unsigned int mods,
+ char * buffer,
+ int nbytes,
+ int * extra_rtrn,
+ XKeyEvent * event,
+ XComposeStatus * status)
+{
register XkbInfoPtr xkb;
XkbKSToMBFunc cvtr;
XPointer priv;
@@ -618,6 +632,17 @@ XkbTranslateKeySym( register Display * d
n = (*cvtr)(priv,*sym_rtrn,buffer,nbytes,extra_rtrn);
+ /* Add Suns specific compose key handler here. Be sure the special
+ * globals are set before calling this function.
+ */
+ {
+ int return_val;
+
+ if (event && HandleComposeSequence(*sym_rtrn, buffer, sym_rtrn,
+ status, &return_val, event))
+ return return_val;
+ }
+
if ((!xkb->cvt.KSToUpper)&&( mods&LockMask )) {
register int i;
int change;
@@ -744,9 +769,9 @@ XLookupString ( register XKeyEvent * eve
#endif
for (n=len=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
if ( nbytes-len > 0 ) {
- len+= XkbTranslateKeySym(dpy,&rtrn.sym[n],new_mods,
+ len+= XkbTranslateKeySymExt(dpy,&rtrn.sym[n],new_mods,
buffer+len,nbytes-len,
- NULL);
+ NULL, event, status);
}
}
if ( keysym!=NULL ) {
@@ -772,16 +797,16 @@ XLookupString ( register XKeyEvent * eve
len = (int)strlen(buffer);
}
else {
- len = XkbTranslateKeySym(dpy,keysym,new_mods,
+ len = XkbTranslateKeySymExt(dpy,keysym,new_mods,
buffer,nbytes,
- NULL);
+ NULL, event, status);
}
for (n=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
if ( nbytes-len > 0 ) {
- len+= XkbTranslateKeySym(dpy,&rtrn.sym[n],
+ len+= XkbTranslateKeySymExt(dpy,&rtrn.sym[n],
event->state,
buffer+len,nbytes-len,
- NULL);
+ NULL, event, status);
}
}
return len;
@@ -802,7 +827,8 @@ XLookupString ( register XKeyEvent * eve
if (rtrnLen>0)
return rtrnLen;
- return XkbTranslateKeySym(dpy,keysym,new_mods,buffer,nbytes,NULL);
+ return XkbTranslateKeySymExt(dpy,keysym,new_mods,buffer,nbytes,NULL,
+ event,status);
}
diff -Nurp -x '*~' -x '*.orig' src/xkb/XKBlibint.h src/xkb/XKBlibint.h
--- src/xkb/XKBlibint.h 2010-09-03 22:52:39.000000000 -0700
+++ src/xkb/XKBlibint.h 2011-04-06 13:52:16.519753992 -0700
@@ -175,10 +175,19 @@ extern int _XTranslateKey(
extern int _XTranslateKeySym(
Display * /* dpy */,
+#ifdef SUNSOFT_KBD
+ register KeySym * /* symbol */,
+#else
register KeySym /* symbol */,
+#endif
unsigned int /* modifiers */,
char * /* buffer */,
int /* nbytes */
+#ifdef SUNSOFT_KBD
+ ,
+ XKeyEvent * /* event */,
+ XComposeStatus * /* status */
+#endif
);
extern int _XLookupString(
@@ -338,6 +347,17 @@ extern Status _XkbReadGetGeometryReply(
#endif
+#ifdef SUNSOFT_KBD
+extern int HandleComposeSequence(
+ KeySym symbol,
+ char *buffer,
+ KeySym *keysym,
+ XComposeStatus *status,
+ int *return_val,
+ XKeyEvent *event);
+#endif /* SUNSOFT_KBD */
+
+
_XFUNCPROTOEND
#endif /* _XKBLIBINT_H_ */
diff -Nurp -x '*~' -x '*.orig' src/xlibi18n/ICWrap.c src/xlibi18n/ICWrap.c
--- src/xlibi18n/ICWrap.c 2011-01-29 10:09:13.000000000 -0800
+++ src/xlibi18n/ICWrap.c 2011-04-06 13:52:16.520026528 -0700
@@ -67,6 +67,12 @@ from The Open Group.
#include "Xlibint.h"
#include "Xlcint.h"
+#ifdef SUNSOFT_KBD
+#define COMPOSE_LED 2
+extern void SetLed (Display *dpy, int num, int state);
+extern int compose_state, compose_led_is_on;
+#endif
+
static int
_XIMNestedListToNestedList(
XIMArg *nlist, /* This is the new list */
@@ -397,9 +403,23 @@ int
XmbLookupString(XIC ic, XKeyEvent *ev, char *buffer, int nbytes,
KeySym *keysym, Status *status)
{
- if (ic->core.im)
- return (*ic->methods->mb_lookup_string) (ic, ev, buffer, nbytes,
- keysym, status);
+ if (ic->core.im) {
+ int ret;
+ KeySym keysym_temp = NoSymbol;
+
+ ret = (*ic->methods->mb_lookup_string) (ic, ev, buffer, nbytes,
+ &keysym_temp, status);
+#ifdef SUNSOFT_KBD
+ if (ev->display->im_filters && !IsModifierKey(keysym_temp) &&
+ compose_led_is_on && compose_state != 0) {
+ SetLed (ev->display, COMPOSE_LED, LedModeOff);
+ compose_led_is_on = False;
+ }
+#endif
+ if (keysym)
+ *keysym = keysym_temp;
+ return ret;
+ }
return XLookupNone;
}
@@ -407,9 +427,23 @@ int
XwcLookupString(XIC ic, XKeyEvent *ev, wchar_t *buffer, int nchars,
KeySym *keysym, Status *status)
{
- if (ic->core.im)
- return (*ic->methods->wc_lookup_string) (ic, ev, buffer, nchars,
- keysym, status);
+ if (ic->core.im) {
+ int ret;
+ KeySym keysym_temp = NoSymbol;
+
+ ret = (*ic->methods->wc_lookup_string) (ic, ev, buffer, nchars,
+ &keysym_temp, status);
+#ifdef SUNSOFT_KBD
+ if (ev->display->im_filters && !IsModifierKey(keysym_temp) &&
+ compose_led_is_on && compose_state != 0) {
+ SetLed (ev->display, COMPOSE_LED, LedModeOff);
+ compose_led_is_on = False;
+ }
+#endif
+ if (keysym)
+ *keysym = keysym_temp;
+ return ret;
+ }
return XLookupNone;
}
@@ -418,12 +452,25 @@ Xutf8LookupString(XIC ic, XKeyEvent *ev,
KeySym *keysym, Status *status)
{
if (ic->core.im) {
+ int ret;
+ KeySym keysym_temp = NoSymbol;
+
if (ic->methods->utf8_lookup_string)
- return (*ic->methods->utf8_lookup_string) (ic, ev, buffer, nbytes,
- keysym, status);
+ ret = (*ic->methods->utf8_lookup_string) (ic, ev, buffer, nbytes,
+ &keysym_temp, status);
else if (ic->methods->mb_lookup_string)
- return (*ic->methods->mb_lookup_string) (ic, ev, buffer, nbytes,
- keysym, status);
+ ret = (*ic->methods->mb_lookup_string) (ic, ev, buffer, nbytes,
+ &keysym_temp, status);
+#ifdef SUNSOFT_KBD
+ if (ev->display->im_filters && !IsModifierKey(keysym_temp) &&
+ compose_led_is_on && compose_state != 0){
+ SetLed (ev->display, COMPOSE_LED, LedModeOff);
+ compose_led_is_on = False;
+ }
+#endif
+ if (keysym)
+ *keysym = keysym_temp;
+ return ret;
}
return XLookupNone;
}