diff options
author | Felipe Heidrich <fheidric> | 2003-05-21 18:42:58 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2003-05-21 18:42:58 +0000 |
commit | 7904279d2c8789191bf10f5b948ddf21d6738f9e (patch) | |
tree | e6e715527abf8e7fcd5e830166d3c2649a82ec6a | |
parent | cdfc0ce09c6cfbd8f243c1f78aa3e6e4bc34d711 (diff) | |
download | eclipse.platform.swt-7904279d2c8789191bf10f5b948ddf21d6738f9e.tar.gz eclipse.platform.swt-7904279d2c8789191bf10f5b948ddf21d6738f9e.tar.xz eclipse.platform.swt-7904279d2c8789191bf10f5b948ddf21d6738f9e.zip |
30854 + 35319v2134c
5 files changed, 68 insertions, 67 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java index fe3e9a0dc1..d856e9e1f0 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java @@ -1066,7 +1066,7 @@ public void select (int index) { ignoreSelect = false; } } -byte [] sendIMKeyEvent (int type, XKeyEvent xEvent) { +void sendIMKeyEvent (int type, XKeyEvent xEvent, byte [] mbcs, char [] chars) { /* * Bug in Motif. On Solaris and Linux, XmImMbLookupString() clears * the characters from the IME. This causes the characters to be @@ -1074,28 +1074,31 @@ byte [] sendIMKeyEvent (int type, XKeyEvent xEvent) { * has been cleared and use XmTextInsert() to insert the stolen * characters. This problem does not happen on AIX. */ - byte [] mbcs = super.sendIMKeyEvent (type, xEvent); - if (mbcs == null || xEvent.keycode != 0) return null; + super.sendIMKeyEvent (type, xEvent, mbcs, chars); + if (mbcs == null || xEvent.keycode != 0) return; int [] argList = {OS.XmNtextField, 0}; OS.XtGetValues (handle, argList, argList.length / 2); - int textHandle = argList[1]; int [] unused = new int [1]; byte [] buffer = new byte [2]; - int length = OS.XmImMbLookupString (textHandle, xEvent, buffer, buffer.length, unused, unused); - if (length != 0) return null; + int length = OS.XmImMbLookupString (argList [1], xEvent, buffer, buffer.length, unused, unused); + if (length != 0) return; int [] start = new int [1], end = new int [1]; - OS.XmTextGetSelectionPosition (textHandle, start, end); + OS.XmTextGetSelectionPosition (argList [1], start, end); if (start [0] == end [0]) { - start [0] = end [0] = OS.XmTextGetInsertionPosition (textHandle); + start [0] = end [0] = OS.XmTextGetInsertionPosition (argList [1]); } - Display display = getDisplay (); + Display display = getDisplay(); boolean warnings = display.getWarnings (); display.setWarnings (false); - OS.XmTextReplace (textHandle, start [0], end [0], mbcs); - int position = start [0] + mbcs.length - 1; - OS.XmTextSetInsertionPosition (textHandle, position); + OS.XmTextReplace (argList [1], start [0], end [0], mbcs); + int index = 0; + while (index < chars.length) { + if (chars [index] == 0) break; + index++; + } + int position = start [0] + index; + OS.XmTextSetInsertionPosition (argList [1], position); display.setWarnings (warnings); - return mbcs; } void setBackgroundPixel (int pixel) { super.setBackgroundPixel (pixel); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java index 4ee02be8e7..01cad3fbe6 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java @@ -1605,7 +1605,7 @@ void sendHelpEvent (int callData) { control = control.parent; } } -byte [] sendIMKeyEvent (int type, XKeyEvent xEvent) { +void sendIMKeyEvent (int type, XKeyEvent xEvent) { /* * Bug in Motif. On Linux only, XmImMbLookupString () does not return * XBufferOverflow as the status if the buffer is too small. The fix @@ -1619,22 +1619,24 @@ byte [] sendIMKeyEvent (int type, XKeyEvent xEvent) { buffer = new byte [length]; length = OS.XmImMbLookupString (focusHandle, xEvent, buffer, length, unused, status); } - if (length == 0) return null; + if (length == 0) return; /* Convert from MBCS to UNICODE and send the event */ /* Use the character encoding for the default locale */ char [] result = Converter.mbcsToWcs (null, buffer); + sendIMKeyEvent (type, xEvent, buffer, result); +} +void sendIMKeyEvent (int type, XKeyEvent xEvent, byte [] mbcs, char [] chars) { int index = 0; - while (index < result.length) { - if (result [index] == 0) break; + while (index < chars.length) { + if (chars [index] == 0) break; Event event = new Event (); event.time = xEvent.time; - event.character = result [index]; + event.character = chars [index]; setInputState (event, xEvent); postEvent (type, event); index++; } - return buffer; } void sendKeyEvent (int type, XKeyEvent xEvent) { Event event = new Event (); @@ -2783,48 +2785,42 @@ int XFocusChange (int w, int client_data, int call_data, int continue_to_dispatc return 0; } int xFocusIn () { + if (!hasIMSupport()) { + short [] point = getIMCaretPos (); + int ptr = OS.XtMalloc (4); + OS.memmove (ptr, point, 4); + /* + * Bug in Motif. On Linux Japanese only, XmImSetFocusValues() causes + * a GP when the XmNfontList resources does not containt a FontSet. + * The fix is to call XmImSetValues() to set the values and then call + * XmImSetFocusValues() with no parameters to set the IME focus. + */ + int[] argList = { +// OS.XmNforeground, getForegroundPixel(), +// OS.XmNbackground, getBackgroundPixel(), + OS.XmNspotLocation, ptr, + OS.XmNfontList, font.handle, + }; + int focusHandle = focusHandle (); + OS.XmImSetValues (focusHandle, argList, argList.length / 2); + OS.XmImSetFocusValues (focusHandle, null, 0); + if (ptr != 0) OS.XtFree (ptr); + } sendEvent (SWT.FocusIn); // widget could be disposed at this point - if (handle == 0) return 0; - if (!hasIMSupport()) { - if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) { - short [] point = getIMCaretPos (); - int ptr = OS.XtMalloc (4); - OS.memmove (ptr, point, 4); - /* - * Bug in Motif. On Linux Japanese only, XmImSetFocusValues() causes - * a GP when the XmNfontList resources does not containt a FontSet. - * The fix is to call XmImSetValues() to set the values and then call - * XmImSetFocusValues() with no parameters to set the IME focus. - */ - int[] argList = { -// OS.XmNforeground, getForegroundPixel(), -// OS.XmNbackground, getBackgroundPixel(), - OS.XmNspotLocation, ptr, - OS.XmNfontList, font.handle, - }; - int focusHandle = focusHandle (); - OS.XmImSetValues (focusHandle, argList, argList.length / 2); - OS.XmImSetFocusValues (focusHandle, null, 0); - if (ptr != 0) OS.XtFree (ptr); - } - } return 0; } int xFocusOut () { - Display display = getDisplay (); + if (!hasIMSupport()) { + int focusHandle = focusHandle (); + OS.XmImUnsetFocus (focusHandle); + } + Display display = getDisplay(); if (display.postFocusOut) { postEvent (SWT.FocusOut); } else { sendEvent (SWT.FocusOut); // widget could be disposed at this point - if (handle == 0) return 0; - } - if (!hasIMSupport()) { - if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) { - int focusHandle = focusHandle (); - OS.XmImUnsetFocus (focusHandle); - } } return 0; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java index a2dae0b53e..ace977f36f 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java @@ -997,7 +997,7 @@ public void removeVerifyListener (VerifyListener listener) { if (eventTable == null) return; eventTable.unhook (SWT.Verify, listener); } -byte [] sendIMKeyEvent (int type, XKeyEvent xEvent) { +void sendIMKeyEvent (int type, XKeyEvent xEvent, byte [] mbcs, char [] chars) { /* * Bug in Motif. On Solaris and Linux, XmImMbLookupString() clears * the characters from the IME. This causes the characters to be @@ -1005,25 +1005,29 @@ byte [] sendIMKeyEvent (int type, XKeyEvent xEvent) { * has been cleared and use XmTextInsert() to insert the stolen * characters. This problem does not happen on AIX. */ - byte [] mbcs = super.sendIMKeyEvent (type, xEvent); - if (mbcs == null || xEvent.keycode != 0) return null; + super.sendIMKeyEvent (type, xEvent, mbcs, chars); + if (mbcs == null || xEvent.keycode != 0) return; int [] unused = new int [1]; byte [] buffer = new byte [2]; int length = OS.XmImMbLookupString (handle, xEvent, buffer, buffer.length, unused, unused); - if (length != 0) return null; + if (length != 0) return; int [] start = new int [1], end = new int [1]; OS.XmTextGetSelectionPosition (handle, start, end); if (start [0] == end [0]) { start [0] = end [0] = OS.XmTextGetInsertionPosition (handle); } - Display display = getDisplay (); + Display display = getDisplay(); boolean warnings = display.getWarnings (); display.setWarnings (false); OS.XmTextReplace (handle, start [0], end [0], mbcs); - int position = start [0] + mbcs.length - 1; + int index = 0; + while (index < chars.length) { + if (chars [index] == 0) break; + index++; + } + int position = start [0] + index; OS.XmTextSetInsertionPosition (handle, position); display.setWarnings (warnings); - return mbcs; } /** * Selects all the text in the receiver. diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java index f6b96efede..f62d718a0e 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java @@ -937,13 +937,10 @@ int XFocusChange (int w, int client_data, int call_data, int continue_to_dispatc XFocusChangeEvent xEvent = new XFocusChangeEvent (); OS.memmove (xEvent, call_data, XFocusChangeEvent.sizeof); xEvent.window = OS.XtWindow (parent.handle); -// TEMPORARY CODE - need to fix the window field in xEvent -// OS.memmove (callData, xEvent, XFocusChangeEvent.sizeof); - - /* - * This code is intentionally commented. - */ -// parent.processSetFocus (callData); +// OS.memmove (call_data, xEvent, XFocusChangeEvent.sizeof); + if (OS.IsDBLocale) { + parent.XFocusChange (w, client_data, call_data, continue_to_dispatch); + } return 0; } int XKeyPress (int w, int client_data, int call_data, int continue_to_dispatch) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java index 5b23b9ffd3..6e15708811 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java @@ -702,7 +702,7 @@ void setInputState (Event event, XInputEvent xEvent) { } void setKeyState (Event event, XKeyEvent xEvent) { if (xEvent.keycode != 0) { - byte [] buffer = new byte [1]; + byte [] buffer = new byte [5]; int [] keysym = new int [1]; OS.XLookupString (xEvent, buffer, buffer.length, keysym, null); @@ -798,7 +798,8 @@ void setKeyState (Event event, XKeyEvent xEvent) { event.keyCode = Display.translateKey (keysym [0]); } if (buffer [0] != 0) { - event.character = mbcsToWcs (buffer [0] & 0xFF); + char [] result = Converter.mbcsToWcs (null, buffer); + if (result.length != 0) event.character = result [0]; } } setInputState (event, xEvent); |