Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 107886 Details for
Bug 62431
[Widgets] Need public API to control IME
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
IME API attempt #1
ime080710.diff (text/plain), 11.50 KB, created by
Lina Kemmel
on 2008-07-20 10:25:22 EDT
(
hide
)
Description:
IME API attempt #1
Filename:
MIME Type:
Creator:
Lina Kemmel
Created:
2008-07-20 10:25:22 EDT
Size:
11.50 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.swt >Index: Eclipse SWT PI/gtk/library/make_linux.mak >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak,v >retrieving revision 1.47 >diff -u -r1.47 make_linux.mak >--- Eclipse SWT PI/gtk/library/make_linux.mak 20 Jun 2007 16:01:22 -0000 1.47 >+++ Eclipse SWT PI/gtk/library/make_linux.mak 10 Jul 2008 22:31:27 -0000 >@@ -28,6 +28,7 @@ > XULRUNNER_PREFIX = swt-xulrunner > XPCOMINIT_PREFIX = swt-xpcominit > GLX_PREFIX = swt-glx >+IME_PREFIX = swt-ime > > SWT_LIB = lib$(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so > CDE_LIB = lib$(CDE_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so >@@ -40,6 +41,7 @@ > XULRUNNER_LIB = lib$(XULRUNNER_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so > XPCOMINIT_LIB = lib$(XPCOMINIT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so > GLX_LIB = lib$(GLX_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so >+IME_LIB = lib$(IME_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so > > CAIROCFLAGS = `pkg-config --cflags cairo` > CAIROLIBS = `pkg-config --libs-only-L cairo` -lcairo >@@ -61,6 +63,9 @@ > GLXCFLAGS = > GLXLIBS = -shared -fPIC -L/usr/X11R6/lib -lGL -lGLU -lm > >+IMECFLAGS = >+# -I/usr/include >+ > # Uncomment for Native Stats tool > #NATIVE_STATS = -DNATIVE_STATS > >@@ -91,6 +96,7 @@ > XULRUNNER_OBJECTS = swt.o xpcomxul.o xpcomxul_custom.o xpcomxul_structs.o xpcomxul_stats.o > XPCOMINIT_OBJECTS = swt.o xpcominit.o xpcominit_structs.o xpcominit_stats.o > GLX_OBJECTS = swt.o glx.o glx_structs.o glx_stats.o >+IME_OBJECTS = swt.o ime_custom.o > > CFLAGS = -O -Wall \ > -DSWT_VERSION=$(SWT_VERSION) \ >@@ -108,7 +114,7 @@ > LIBS := $(LIBS) -s > endif > >-all: make_swt make_atk make_gnome make_glx >+all: make_swt make_atk make_gnome make_glx make_ime > > # > # SWT libs >@@ -276,6 +282,19 @@ > $(CC) $(CFLAGS) $(GLXCFLAGS) -c glx_stats.c > > # >+# IME lib >+# >+make_ime: $(IME_LIB) >+ >+$(IME_LIB): $(IME_OBJECTS) >+ $(CC) $(LIBS) -o $(IME_LIB) $(IME_OBJECTS) >+# $(CXX) $(LIBS) -o $(IME_LIB) $(IME_OBJECTS) >+ >+ime.o: ime_custom.c >+ $(CC) $(CFLAGS) $(IMECFLAGS) -c ime_custom.c >+# $(CXX) $(CFLAGS) $(IMECFLAGS) -c ime.cpp >+ >+# > # Install > # > install: all >Index: Eclipse SWT/emulated/bidi/org/eclipse/swt/internal/BidiUtil.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/emulated/bidi/org/eclipse/swt/internal/BidiUtil.java,v >retrieving revision 1.27 >diff -u -r1.27 BidiUtil.java >--- Eclipse SWT/emulated/bidi/org/eclipse/swt/internal/BidiUtil.java 5 Jun 2008 17:31:46 -0000 1.27 >+++ Eclipse SWT/emulated/bidi/org/eclipse/swt/internal/BidiUtil.java 10 Jul 2008 22:31:27 -0000 >@@ -11,7 +11,10 @@ > package org.eclipse.swt.internal; > > import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.internal.gtk.IME; >+import org.eclipse.swt.internal.gtk.OS; > import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Widget; > > /* > * This class is supplied so that the StyledText code that supports bidi text (supported >@@ -39,6 +42,12 @@ > public static final int LIGATE = 0; > public static final int GLYPHSHAPE = 0; > >+ private static final int NONE = 0; >+ private static final int USE_XKB = 1; >+ private static final int USE_KXKB = 2; >+ private static final int USE_XMODMAP = 3; >+ private static int status = NONE; >+ > /* > * Not implemented. > */ >@@ -90,6 +99,40 @@ > public static int getKeyboardLanguage() { > return 0; > } >+public static String /*int*/ [] getKeyboardLanguageList(Widget widget) { >+ if (!OS.IsLinux) return null; >+ >+ int display = init(widget); >+ if (display == 0) return null; >+ >+ int[] languageArray = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; >+ int nLanguages = IME.GetKeyboardLanguages(display, languageArray); >+ if (nLanguages <= 0) return null; >+ >+ String languageList[] = new String[nLanguages]; >+ >+ for (int i = 0; i < nLanguages && languageArray[i] != 0; i++) { >+ int size = OS.strlen(languageArray[i]); >+ byte[] language = new byte[size]; >+ OS.memmove(language, languageArray[i], size); >+ OS.free(languageArray[i]); >+ languageList[i] = new String(language); >+ System.out.println(languageList[i]); >+ } >+ return languageList; >+} >+ >+private static /*long*/ int init(Widget widget) { >+ int /*long*/ display = widget == null ? OS.GDK_DISPLAY() >+ : OS.gdk_x11_drawable_get_xdisplay(OS.GTK_WIDGET_WINDOW(widget.handle)); >+ >+ if (display == 0 || status != NONE) >+ return display; >+ >+ // TODO: Init status >+ >+ return display; >+} > /* > * Not implemented. > */ >Index: Eclipse SWT PI/gtk/library/ime_custom.c >=================================================================== >RCS file: Eclipse SWT PI/gtk/library/ime_custom.c >diff -N Eclipse SWT PI/gtk/library/ime_custom.c >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse SWT PI/gtk/library/ime_custom.c 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,121 @@ >+/******************************************************************************* >+* Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved. >+* The contents of this file are made available under the terms >+* of the GNU Lesser General Public License (LGPL) Version 2.1 that >+* accompanies this distribution (lgpl-v21.txt). The LGPL is also >+* available at http://www.gnu.org/licenses/lgpl.html. If the version >+* of the LGPL at http://www.gnu.org is different to the version of >+* the LGPL accompanying this distribution and there is any conflict >+* between the two license versions, the terms of the LGPL accompanying >+* this distribution shall govern. >+* >+* Contributors: >+* IBM Corporation - initial API and implementation >+*******************************************************************************/ >+ >+#include "swt.h" >+#include "ime.h" >+ >+#define OS_NATIVE(func) Java_org_eclipse_swt_internal_gtk_IME_##func >+ >+#ifndef NO__1GetKeyboardLanguages >+JNIEXPORT jint JNICALL OS_NATIVE(_1GetKeyboardLanguages) >+ (JNIEnv *env, jclass that, jint arg0, jintArray arg1) >+{ >+ jint *lparg1 = NULL; >+ jint rc = -1; >+ OS_NATIVE_ENTER(env, that, _1GetKeyboardLanguages_FUNC); >+#ifndef NO_IME >+ if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail; >+ { >+ /* For now, execute series of commmands */ >+ int i = 0; >+ char* p = NULL; >+ char file_name[] = "/tmp/bidiXXX.tmp"; >+ char command[100] = "dcop kxkb kxkb getLayoutsList > "; >+ FILE* tmp_file = NULL; >+ mkstemp(file_name); >+ freopen("/dev/null", "w", stderr); >+ system(strcat(command, file_name)); >+ if ((tmp_file = fopen(file_name, "r+"))) { >+ do { >+ ++rc; >+ char* lang = (char*)malloc(20); >+ if (!fgets(lang, 19, tmp_file)) { >+ free(lang); >+ break; >+ } >+ if ((p = strchr(lang, '\n'))) >+ *p = '\0'; >+ lparg1[i++] = (int)lang; >+ } >+ while (rc < 10); >+ fclose(tmp_file); >+ } >+ remove(file_name); >+ } >+ if (rc <= 0) { >+ static int initialized = 0; >+ static void *handle = NULL; >+ typedef Status (*FPTR)(Display*, unsigned long, XkbDescPtr); >+ typedef void (*FPTR2)(XkbDescPtr, unsigned int, Bool); >+ typedef Status (*FPTR3)(Display*, Atom*, int, char**); >+ static FPTR fXkbGetControls = NULL; >+ static FPTR2 fXkbFreeControls = NULL; >+ static FPTR fXkbGetNames = NULL; >+ static FPTR2 fXkbFreeNames = NULL; >+ static FPTR3 fXGetAtomNames = NULL; >+ if (!initialized) { >+ /* TODO: Add XkbQueryExtension */ >+ if (!handle) handle = dlopen(XKB_LIB, RTLD_LAZY); >+ if (handle) { >+ fXkbGetControls = (FPTR)dlsym(handle, "XkbGetControls"); >+ fXkbFreeControls = (FPTR2)dlsym(handle, "XkbFreeControls"); >+ fXkbGetNames = (FPTR)dlsym(handle, "XkbGetNames"); >+ fXkbFreeNames = (FPTR2)dlsym(handle, "XkbFreeNames"); >+ fXGetAtomNames = (FPTR3)dlsym(handle, "XGetAtomNames"); >+ } >+ initialized = 1; >+ } >+ if (fXkbGetControls && fXkbFreeControls && fXkbGetNames && fXkbFreeNames && fXGetAtomNames) { >+ Display* dpy = (Display*)arg0; >+ XkbDescRec desc; >+ memset(&desc, 0, sizeof(desc)); >+ desc.device_spec = XkbUseCoreKbd; >+ desc.dpy = dpy; >+ if ((*fXkbGetControls)(dpy, XkbGroupsWrapMask, &desc) == Success) { >+ rc = desc.ctrls->num_groups; >+ (*fXkbGetNames)(dpy, XkbGroupNamesMask, &desc); >+ (*fXGetAtomNames)(dpy, desc.names->groups, rc, (char**)lparg1); >+ (*fXkbFreeNames)(&desc, XkbGroupNamesMask, 1); >+ } >+ (*fXkbFreeControls)(&desc, XkbGroupsWrapMask, 1); >+ } >+ } >+ fail: >+ if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); >+#endif /* ifndef NO_IME */ >+ OS_NATIVE_EXIT(env, that, _1GetKeyboardLanguages_FUNC); >+ return rc; >+} >+#endif /* ifndef NO__1GetKeyboardLanguages */ >+ >Index: Eclipse SWT PI/gtk/library/ime.h >=================================================================== >RCS file: Eclipse SWT PI/gtk/library/ime.h >diff -N Eclipse SWT PI/gtk/library/ime.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse SWT PI/gtk/library/ime.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,33 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved. >+ * The contents of this file are made available under the terms >+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that >+ * accompanies this distribution (lgpl-v21.txt). The LGPL is also >+ * available at http://www.gnu.org/licenses/lgpl.html. If the version >+ * of the LGPL at http://www.gnu.org is different to the version of >+ * the LGPL accompanying this distribution and there is any conflict >+ * between the two license versions, the terms of the LGPL accompanying >+ * this distribution shall govern. >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+#ifndef INC_ime_H >+#define INC_ime_H >+ >+#define NDEBUG >+ >+#ifndef NO_IME >+ >+#include <memory.h> >+#include <stdlib.h> >+#include <dlfcn.h> >+#include <X11/XKBlib.h> >+ >+/* Libraries for dynamic loaded functions */ >+#define XKB_LIB "libX11.so" >+ >+#endif >+ >+#endif /* INC_os_H */ >Index: Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/IME.java >=================================================================== >RCS file: Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/IME.java >diff -N Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/IME.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/IME.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,36 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.swt.internal.gtk; >+ >+import org.eclipse.swt.internal.*; >+ >+public class IME extends C { >+ static { >+ Library.loadLibrary ("swt-ime"); //$NON-NLS-1$ >+ } >+ >+ /** IME natives */ >+ public static final native int _GetKeyboardLanguages(int /*long*/ display, int /*long*/ [] languages); >+ public static final int GetKeyboardLanguages(int /*long*/ display, int /*long*/ [] languages) { >+ lock.lock(); >+ try { >+ return _GetKeyboardLanguages(display, languages); >+ } finally { >+ lock.unlock(); >+ } >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 62431
:
105828
|
105877
|
105878
| 107886