From 825a3d837a33f226c879cd02ad15c3fba57e8b2c Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 23 Jan 2012 23:30:42 +1000 Subject: Update the EFL to what I'm actually using, coz I'm using some stuff not yet released. --- libraries/ecore/src/modules/Makefile.in | 14 +- libraries/ecore/src/modules/immodules/Makefile.am | 4 + libraries/ecore/src/modules/immodules/Makefile.in | 19 +- .../ecore/src/modules/immodules/scim/Makefile.am | 36 + .../ecore/src/modules/immodules/scim/Makefile.in | 849 ++++++ .../src/modules/immodules/scim/scim_imcontext.cpp | 2839 ++++++++++++++++++++ .../src/modules/immodules/scim/scim_imcontext.h | 40 + .../src/modules/immodules/scim/scim_module.cpp | 93 + .../ecore/src/modules/immodules/xim/Makefile.in | 14 +- .../src/modules/immodules/xim/ecore_imf_xim.c | 614 +++-- 10 files changed, 4298 insertions(+), 224 deletions(-) create mode 100644 libraries/ecore/src/modules/immodules/scim/Makefile.am create mode 100644 libraries/ecore/src/modules/immodules/scim/Makefile.in create mode 100644 libraries/ecore/src/modules/immodules/scim/scim_imcontext.cpp create mode 100644 libraries/ecore/src/modules/immodules/scim/scim_imcontext.h create mode 100644 libraries/ecore/src/modules/immodules/scim/scim_module.cpp (limited to 'libraries/ecore/src/modules') diff --git a/libraries/ecore/src/modules/Makefile.in b/libraries/ecore/src/modules/Makefile.in index 62cbce2..4bb9420 100644 --- a/libraries/ecore/src/modules/Makefile.in +++ b/libraries/ecore/src/modules/Makefile.in @@ -227,10 +227,10 @@ PATH_SEPARATOR = @PATH_SEPARATOR@ PIXMAN_CFLAGS = @PIXMAN_CFLAGS@ PIXMAN_LIBS = @PIXMAN_LIBS@ PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POSUB = @POSUB@ RANLIB = @RANLIB@ +SCIM_CFLAGS = @SCIM_CFLAGS@ +SCIM_LIBS = @SCIM_LIBS@ SDL_CFLAGS = @SDL_CFLAGS@ SDL_CONFIG = @SDL_CONFIG@ SDL_LIBS = @SDL_LIBS@ @@ -249,6 +249,10 @@ TSLIB_LIBS = @TSLIB_LIBS@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ VMAJ = @VMAJ@ +WAYLAND_CFLAGS = @WAYLAND_CFLAGS@ +WAYLAND_EGL_CFLAGS = @WAYLAND_EGL_CFLAGS@ +WAYLAND_EGL_LIBS = @WAYLAND_EGL_LIBS@ +WAYLAND_LIBS = @WAYLAND_LIBS@ WIN32_CFLAGS = @WIN32_CFLAGS@ WIN32_CPPFLAGS = @WIN32_CPPFLAGS@ WIN32_LIBS = @WIN32_LIBS@ @@ -362,6 +366,8 @@ ecore_imf_cflags = @ecore_imf_cflags@ ecore_imf_evas_cflags = @ecore_imf_evas_cflags@ ecore_imf_evas_libs = @ecore_imf_evas_libs@ ecore_imf_libs = @ecore_imf_libs@ +ecore_imf_scim_cflags = @ecore_imf_scim_cflags@ +ecore_imf_scim_libs = @ecore_imf_scim_libs@ ecore_imf_xim_cflags = @ecore_imf_xim_cflags@ ecore_imf_xim_libs = @ecore_imf_xim_libs@ ecore_input_cflags = @ecore_input_cflags@ @@ -374,6 +380,8 @@ ecore_psl1ght_cflags = @ecore_psl1ght_cflags@ ecore_psl1ght_libs = @ecore_psl1ght_libs@ ecore_sdl_cflags = @ecore_sdl_cflags@ ecore_sdl_libs = @ecore_sdl_libs@ +ecore_wayland_cflags = @ecore_wayland_cflags@ +ecore_wayland_libs = @ecore_wayland_libs@ ecore_win32_cflags = @ecore_win32_cflags@ ecore_win32_libs = @ecore_win32_libs@ ecore_wince_cflags = @ecore_wince_cflags@ @@ -418,12 +426,14 @@ requirements_ecore_fb = @requirements_ecore_fb@ requirements_ecore_file = @requirements_ecore_file@ requirements_ecore_imf = @requirements_ecore_imf@ requirements_ecore_imf_evas = @requirements_ecore_imf_evas@ +requirements_ecore_imf_scim = @requirements_ecore_imf_scim@ requirements_ecore_imf_xim = @requirements_ecore_imf_xim@ requirements_ecore_input = @requirements_ecore_input@ requirements_ecore_input_evas = @requirements_ecore_input_evas@ requirements_ecore_ipc = @requirements_ecore_ipc@ requirements_ecore_psl1ght = @requirements_ecore_psl1ght@ requirements_ecore_sdl = @requirements_ecore_sdl@ +requirements_ecore_wayland = @requirements_ecore_wayland@ requirements_ecore_win32 = @requirements_ecore_win32@ requirements_ecore_wince = @requirements_ecore_wince@ requirements_ecore_x = @requirements_ecore_x@ diff --git a/libraries/ecore/src/modules/immodules/Makefile.am b/libraries/ecore/src/modules/immodules/Makefile.am index 6978672..2f121ae 100644 --- a/libraries/ecore/src/modules/immodules/Makefile.am +++ b/libraries/ecore/src/modules/immodules/Makefile.am @@ -5,3 +5,7 @@ SUBDIRS = if BUILD_ECORE_IMF_XIM SUBDIRS += xim endif + +if BUILD_ECORE_IMF_SCIM +SUBDIRS += scim +endif diff --git a/libraries/ecore/src/modules/immodules/Makefile.in b/libraries/ecore/src/modules/immodules/Makefile.in index 2ebe9fe..e65881c 100644 --- a/libraries/ecore/src/modules/immodules/Makefile.in +++ b/libraries/ecore/src/modules/immodules/Makefile.in @@ -34,6 +34,7 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @BUILD_ECORE_IMF_XIM_TRUE@am__append_1 = xim +@BUILD_ECORE_IMF_SCIM_TRUE@am__append_2 = scim subdir = src/modules/immodules DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -83,7 +84,7 @@ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ distdir ETAGS = etags CTAGS = ctags -DIST_SUBDIRS = xim +DIST_SUBDIRS = xim scim DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ @@ -228,10 +229,10 @@ PATH_SEPARATOR = @PATH_SEPARATOR@ PIXMAN_CFLAGS = @PIXMAN_CFLAGS@ PIXMAN_LIBS = @PIXMAN_LIBS@ PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POSUB = @POSUB@ RANLIB = @RANLIB@ +SCIM_CFLAGS = @SCIM_CFLAGS@ +SCIM_LIBS = @SCIM_LIBS@ SDL_CFLAGS = @SDL_CFLAGS@ SDL_CONFIG = @SDL_CONFIG@ SDL_LIBS = @SDL_LIBS@ @@ -250,6 +251,10 @@ TSLIB_LIBS = @TSLIB_LIBS@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ VMAJ = @VMAJ@ +WAYLAND_CFLAGS = @WAYLAND_CFLAGS@ +WAYLAND_EGL_CFLAGS = @WAYLAND_EGL_CFLAGS@ +WAYLAND_EGL_LIBS = @WAYLAND_EGL_LIBS@ +WAYLAND_LIBS = @WAYLAND_LIBS@ WIN32_CFLAGS = @WIN32_CFLAGS@ WIN32_CPPFLAGS = @WIN32_CPPFLAGS@ WIN32_LIBS = @WIN32_LIBS@ @@ -363,6 +368,8 @@ ecore_imf_cflags = @ecore_imf_cflags@ ecore_imf_evas_cflags = @ecore_imf_evas_cflags@ ecore_imf_evas_libs = @ecore_imf_evas_libs@ ecore_imf_libs = @ecore_imf_libs@ +ecore_imf_scim_cflags = @ecore_imf_scim_cflags@ +ecore_imf_scim_libs = @ecore_imf_scim_libs@ ecore_imf_xim_cflags = @ecore_imf_xim_cflags@ ecore_imf_xim_libs = @ecore_imf_xim_libs@ ecore_input_cflags = @ecore_input_cflags@ @@ -375,6 +382,8 @@ ecore_psl1ght_cflags = @ecore_psl1ght_cflags@ ecore_psl1ght_libs = @ecore_psl1ght_libs@ ecore_sdl_cflags = @ecore_sdl_cflags@ ecore_sdl_libs = @ecore_sdl_libs@ +ecore_wayland_cflags = @ecore_wayland_cflags@ +ecore_wayland_libs = @ecore_wayland_libs@ ecore_win32_cflags = @ecore_win32_cflags@ ecore_win32_libs = @ecore_win32_libs@ ecore_wince_cflags = @ecore_wince_cflags@ @@ -419,12 +428,14 @@ requirements_ecore_fb = @requirements_ecore_fb@ requirements_ecore_file = @requirements_ecore_file@ requirements_ecore_imf = @requirements_ecore_imf@ requirements_ecore_imf_evas = @requirements_ecore_imf_evas@ +requirements_ecore_imf_scim = @requirements_ecore_imf_scim@ requirements_ecore_imf_xim = @requirements_ecore_imf_xim@ requirements_ecore_input = @requirements_ecore_input@ requirements_ecore_input_evas = @requirements_ecore_input_evas@ requirements_ecore_ipc = @requirements_ecore_ipc@ requirements_ecore_psl1ght = @requirements_ecore_psl1ght@ requirements_ecore_sdl = @requirements_ecore_sdl@ +requirements_ecore_wayland = @requirements_ecore_wayland@ requirements_ecore_win32 = @requirements_ecore_win32@ requirements_ecore_wince = @requirements_ecore_wince@ requirements_ecore_x = @requirements_ecore_x@ @@ -442,7 +453,7 @@ x_cflags = @x_cflags@ x_includes = @x_includes@ x_libs = @x_libs@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = $(am__append_1) +SUBDIRS = $(am__append_1) $(am__append_2) all: all-recursive .SUFFIXES: diff --git a/libraries/ecore/src/modules/immodules/scim/Makefile.am b/libraries/ecore/src/modules/immodules/scim/Makefile.am new file mode 100644 index 0000000..40579ca --- /dev/null +++ b/libraries/ecore/src/modules/immodules/scim/Makefile.am @@ -0,0 +1,36 @@ +MAINTAINERCLEANFILES = Makefile.in + +AM_CPPFLAGS = \ +-I$(top_srcdir) \ +-I$(top_srcdir)/src/lib/ecore \ +-I$(top_srcdir)/src/lib/ecore_input \ +-I$(top_srcdir)/src/lib/ecore_x \ +-I$(top_srcdir)/src/lib/ecore_imf \ +-I$(top_srcdir)/src/lib/ecore_evas \ +-I$(top_builddir)/src/lib/ecore \ +-I$(top_builddir)/src/lib/ecore_input \ +-I$(top_builddir)/src/lib/ecore_x \ +-I$(top_builddir)/src/lib/ecore_imf \ +-I$(top_builddir)/src/lib/ecore_evas \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ +@SCIM_CFLAGS@ \ +@EVAS_CFLAGS@ \ +@EINA_CFLAGS@ + +pkgdir = $(libdir)/ecore/immodules + +pkg_LTLIBRARIES = scim.la +scim_la_SOURCES = \ +scim_imcontext.cpp \ +scim_module.cpp \ +scim_imcontext.h + +scim_la_LIBADD = \ + $(top_builddir)/src/lib/ecore_imf/libecore_imf.la \ + $(top_builddir)/src/lib/ecore_x/libecore_x.la \ + @SCIM_LIBS@ \ + @EVAS_LIBS@ \ + @EINA_LIBS@ +scim_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version +scim_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/libraries/ecore/src/modules/immodules/scim/Makefile.in b/libraries/ecore/src/modules/immodules/scim/Makefile.in new file mode 100644 index 0000000..9fc3283 --- /dev/null +++ b/libraries/ecore/src/modules/immodules/scim/Makefile.in @@ -0,0 +1,849 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src/modules/immodules/scim +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \ + $(top_srcdir)/m4/ac_path_generic.m4 \ + $(top_srcdir)/m4/check_x_extension.m4 \ + $(top_srcdir)/m4/ecore_check_module.m4 \ + $(top_srcdir)/m4/ecore_check_options.m4 \ + $(top_srcdir)/m4/efl_compiler_flag.m4 \ + $(top_srcdir)/m4/efl_doxygen.m4 \ + $(top_srcdir)/m4/efl_examples.m4 \ + $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \ + $(top_srcdir)/m4/efl_threads.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/isc-posix.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(pkgdir)" +LTLIBRARIES = $(pkg_LTLIBRARIES) +scim_la_DEPENDENCIES = \ + $(top_builddir)/src/lib/ecore_imf/libecore_imf.la \ + $(top_builddir)/src/lib/ecore_x/libecore_x.la +am_scim_la_OBJECTS = scim_la-scim_imcontext.lo scim_la-scim_module.lo +scim_la_OBJECTS = $(am_scim_la_OBJECTS) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +scim_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(scim_la_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(scim_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_$(V)) +am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) +am__v_CXX_0 = @echo " CXX " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CXXLD = $(am__v_CXXLD_$(V)) +am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CXXLD_0 = @echo " CXXLD " $@; +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(scim_la_SOURCES) +DIST_SOURCES = $(scim_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CARES_CFLAGS = @CARES_CFLAGS@ +CARES_LIBS = @CARES_LIBS@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CHECK_CFLAGS = @CHECK_CFLAGS@ +CHECK_LIBS = @CHECK_LIBS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CURL_CFLAGS = @CURL_CFLAGS@ +CURL_LIBS = @CURL_LIBS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DIRECTFB_CFLAGS = @DIRECTFB_CFLAGS@ +DIRECTFB_LIBS = @DIRECTFB_LIBS@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +ECORE_XCB_CFLAGS = @ECORE_XCB_CFLAGS@ +ECORE_XCB_LIBS = @ECORE_XCB_LIBS@ +EFL_ECORE_BUILD = @EFL_ECORE_BUILD@ +EFL_ECORE_CON_BUILD = @EFL_ECORE_CON_BUILD@ +EFL_ECORE_EVAS_BUILD = @EFL_ECORE_EVAS_BUILD@ +EFL_ECORE_FILE_BUILD = @EFL_ECORE_FILE_BUILD@ +EFL_ECORE_IMF_BUILD = @EFL_ECORE_IMF_BUILD@ +EFL_ECORE_IMF_EVAS_BUILD = @EFL_ECORE_IMF_EVAS_BUILD@ +EFL_ECORE_INPUT_BUILD = @EFL_ECORE_INPUT_BUILD@ +EFL_ECORE_INPUT_EVAS_BUILD = @EFL_ECORE_INPUT_EVAS_BUILD@ +EFL_ECORE_IPC_BUILD = @EFL_ECORE_IPC_BUILD@ +EFL_ECORE_PSL1GHT_BUILD = @EFL_ECORE_PSL1GHT_BUILD@ +EFL_ECORE_SDL_BUILD = @EFL_ECORE_SDL_BUILD@ +EFL_ECORE_WIN32_BUILD = @EFL_ECORE_WIN32_BUILD@ +EFL_ECORE_WINCE_BUILD = @EFL_ECORE_WINCE_BUILD@ +EFL_PTHREAD_CFLAGS = @EFL_PTHREAD_CFLAGS@ +EFL_PTHREAD_LIBS = @EFL_PTHREAD_LIBS@ +EGREP = @EGREP@ +EINA_CFLAGS = @EINA_CFLAGS@ +EINA_LIBS = @EINA_LIBS@ +ESCAPE_CFLAGS = @ESCAPE_CFLAGS@ +ESCAPE_LIBS = @ESCAPE_LIBS@ +EVAS_CFLAGS = @EVAS_CFLAGS@ +EVAS_LIBS = @EVAS_LIBS@ +EVIL_CFLAGS = @EVIL_CFLAGS@ +EVIL_LIBS = @EVIL_LIBS@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_LIBS = @GLIB_LIBS@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +KEYSYMDEFS = @KEYSYMDEFS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ +LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ +LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PIXMAN_CFLAGS = @PIXMAN_CFLAGS@ +PIXMAN_LIBS = @PIXMAN_LIBS@ +PKG_CONFIG = @PKG_CONFIG@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SCIM_CFLAGS = @SCIM_CFLAGS@ +SCIM_LIBS = @SCIM_LIBS@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SSL_CFLAGS = @SSL_CFLAGS@ +SSL_LIBS = @SSL_LIBS@ +STRIP = @STRIP@ +TLS2_CFLAGS = @TLS2_CFLAGS@ +TLS2_LIBS = @TLS2_LIBS@ +TLS_CFLAGS = @TLS_CFLAGS@ +TLS_LIBS = @TLS_LIBS@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +VMAJ = @VMAJ@ +WAYLAND_CFLAGS = @WAYLAND_CFLAGS@ +WAYLAND_EGL_CFLAGS = @WAYLAND_EGL_CFLAGS@ +WAYLAND_EGL_LIBS = @WAYLAND_EGL_LIBS@ +WAYLAND_LIBS = @WAYLAND_LIBS@ +WIN32_CFLAGS = @WIN32_CFLAGS@ +WIN32_CPPFLAGS = @WIN32_CPPFLAGS@ +WIN32_LIBS = @WIN32_LIBS@ +XCB_COMPOSITE_CFLAGS = @XCB_COMPOSITE_CFLAGS@ +XCB_COMPOSITE_LIBS = @XCB_COMPOSITE_LIBS@ +XCB_CURSOR_CFLAGS = @XCB_CURSOR_CFLAGS@ +XCB_CURSOR_LIBS = @XCB_CURSOR_LIBS@ +XCB_DAMAGE_CFLAGS = @XCB_DAMAGE_CFLAGS@ +XCB_DAMAGE_LIBS = @XCB_DAMAGE_LIBS@ +XCB_DPMS_CFLAGS = @XCB_DPMS_CFLAGS@ +XCB_DPMS_LIBS = @XCB_DPMS_LIBS@ +XCB_RANDR_CFLAGS = @XCB_RANDR_CFLAGS@ +XCB_RANDR_LIBS = @XCB_RANDR_LIBS@ +XCB_RENDER_CFLAGS = @XCB_RENDER_CFLAGS@ +XCB_RENDER_LIBS = @XCB_RENDER_LIBS@ +XCB_SCREENSAVER_CFLAGS = @XCB_SCREENSAVER_CFLAGS@ +XCB_SCREENSAVER_LIBS = @XCB_SCREENSAVER_LIBS@ +XCB_SHAPE_CFLAGS = @XCB_SHAPE_CFLAGS@ +XCB_SHAPE_LIBS = @XCB_SHAPE_LIBS@ +XCB_SYNC_CFLAGS = @XCB_SYNC_CFLAGS@ +XCB_SYNC_LIBS = @XCB_SYNC_LIBS@ +XCB_X11_CFLAGS = @XCB_X11_CFLAGS@ +XCB_X11_LIBS = @XCB_X11_LIBS@ +XCB_XFIXES_CFLAGS = @XCB_XFIXES_CFLAGS@ +XCB_XFIXES_LIBS = @XCB_XFIXES_LIBS@ +XCB_XGESTURE_CFLAGS = @XCB_XGESTURE_CFLAGS@ +XCB_XGESTURE_LIBS = @XCB_XGESTURE_LIBS@ +XCB_XINERAMA_CFLAGS = @XCB_XINERAMA_CFLAGS@ +XCB_XINERAMA_LIBS = @XCB_XINERAMA_LIBS@ +XCB_XINPUT_CFLAGS = @XCB_XINPUT_CFLAGS@ +XCB_XINPUT_LIBS = @XCB_XINPUT_LIBS@ +XCB_XPRINT_CFLAGS = @XCB_XPRINT_CFLAGS@ +XCB_XPRINT_LIBS = @XCB_XPRINT_LIBS@ +XCB_XTEST_CFLAGS = @XCB_XTEST_CFLAGS@ +XCB_XTEST_LIBS = @XCB_XTEST_LIBS@ +XCOMPOSITE_CFLAGS = @XCOMPOSITE_CFLAGS@ +XCOMPOSITE_LIBS = @XCOMPOSITE_LIBS@ +XDAMAGE_CFLAGS = @XDAMAGE_CFLAGS@ +XDAMAGE_LIBS = @XDAMAGE_LIBS@ +XDPMS_CFLAGS = @XDPMS_CFLAGS@ +XDPMS_LIBS = @XDPMS_LIBS@ +XFIXES_CFLAGS = @XFIXES_CFLAGS@ +XFIXES_LIBS = @XFIXES_LIBS@ +XGESTURE_CFLAGS = @XGESTURE_CFLAGS@ +XGESTURE_LIBS = @XGESTURE_LIBS@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +XI2_CFLAGS = @XI2_CFLAGS@ +XI2_LIBS = @XI2_LIBS@ +XINERAMA_CFLAGS = @XINERAMA_CFLAGS@ +XINERAMA_LIBS = @XINERAMA_LIBS@ +XKB_CFLAGS = @XKB_CFLAGS@ +XKB_LIBS = @XKB_LIBS@ +XMKMF = @XMKMF@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XRANDR_CFLAGS = @XRANDR_CFLAGS@ +XRANDR_LIBS = @XRANDR_LIBS@ +XRENDER_CFLAGS = @XRENDER_CFLAGS@ +XRENDER_LIBS = @XRENDER_LIBS@ +XSS_CFLAGS = @XSS_CFLAGS@ +XSS_LIBS = @XSS_LIBS@ +XTEST_CFLAGS = @XTEST_CFLAGS@ +XTEST_LIBS = @XTEST_LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +Xcursor_cflags = @Xcursor_cflags@ +Xcursor_libs = @Xcursor_libs@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +ac_ct_OBJC = @ac_ct_OBJC@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +cocoa_ldflags = @cocoa_ldflags@ +datadir = @datadir@ +datarootdir = @datarootdir@ +dlopen_libs = @dlopen_libs@ +docdir = @docdir@ +dvidir = @dvidir@ +ecore_cocoa_cflags = @ecore_cocoa_cflags@ +ecore_cocoa_libs = @ecore_cocoa_libs@ +ecore_con_cflags = @ecore_con_cflags@ +ecore_con_libs = @ecore_con_libs@ +ecore_directfb_cflags = @ecore_directfb_cflags@ +ecore_directfb_libs = @ecore_directfb_libs@ +ecore_evas_cflags = @ecore_evas_cflags@ +ecore_evas_libs = @ecore_evas_libs@ +ecore_fb_cflags = @ecore_fb_cflags@ +ecore_fb_libs = @ecore_fb_libs@ +ecore_file_cflags = @ecore_file_cflags@ +ecore_file_libs = @ecore_file_libs@ +ecore_imf_cflags = @ecore_imf_cflags@ +ecore_imf_evas_cflags = @ecore_imf_evas_cflags@ +ecore_imf_evas_libs = @ecore_imf_evas_libs@ +ecore_imf_libs = @ecore_imf_libs@ +ecore_imf_scim_cflags = @ecore_imf_scim_cflags@ +ecore_imf_scim_libs = @ecore_imf_scim_libs@ +ecore_imf_xim_cflags = @ecore_imf_xim_cflags@ +ecore_imf_xim_libs = @ecore_imf_xim_libs@ +ecore_input_cflags = @ecore_input_cflags@ +ecore_input_evas_cflags = @ecore_input_evas_cflags@ +ecore_input_evas_libs = @ecore_input_evas_libs@ +ecore_input_libs = @ecore_input_libs@ +ecore_ipc_cflags = @ecore_ipc_cflags@ +ecore_ipc_libs = @ecore_ipc_libs@ +ecore_psl1ght_cflags = @ecore_psl1ght_cflags@ +ecore_psl1ght_libs = @ecore_psl1ght_libs@ +ecore_sdl_cflags = @ecore_sdl_cflags@ +ecore_sdl_libs = @ecore_sdl_libs@ +ecore_wayland_cflags = @ecore_wayland_cflags@ +ecore_wayland_libs = @ecore_wayland_libs@ +ecore_win32_cflags = @ecore_win32_cflags@ +ecore_win32_libs = @ecore_win32_libs@ +ecore_wince_cflags = @ecore_wince_cflags@ +ecore_wince_libs = @ecore_wince_libs@ +ecore_x_cflags = @ecore_x_cflags@ +ecore_x_libs = @ecore_x_libs@ +ecore_x_libs_private = @ecore_x_libs_private@ +efl_doxygen = @efl_doxygen@ +efl_have_doxygen = @efl_have_doxygen@ +exec_prefix = @exec_prefix@ +have_ecore_x_xcb_define = @have_ecore_x_xcb_define@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +lt_enable_auto_import = @lt_enable_auto_import@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgconfig_requires_private = @pkgconfig_requires_private@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +release_info = @release_info@ +requirements_ecore = @requirements_ecore@ +requirements_ecore_cocoa = @requirements_ecore_cocoa@ +requirements_ecore_con = @requirements_ecore_con@ +requirements_ecore_directfb = @requirements_ecore_directfb@ +requirements_ecore_evas = @requirements_ecore_evas@ +requirements_ecore_fb = @requirements_ecore_fb@ +requirements_ecore_file = @requirements_ecore_file@ +requirements_ecore_imf = @requirements_ecore_imf@ +requirements_ecore_imf_evas = @requirements_ecore_imf_evas@ +requirements_ecore_imf_scim = @requirements_ecore_imf_scim@ +requirements_ecore_imf_xim = @requirements_ecore_imf_xim@ +requirements_ecore_input = @requirements_ecore_input@ +requirements_ecore_input_evas = @requirements_ecore_input_evas@ +requirements_ecore_ipc = @requirements_ecore_ipc@ +requirements_ecore_psl1ght = @requirements_ecore_psl1ght@ +requirements_ecore_sdl = @requirements_ecore_sdl@ +requirements_ecore_wayland = @requirements_ecore_wayland@ +requirements_ecore_win32 = @requirements_ecore_win32@ +requirements_ecore_wince = @requirements_ecore_wince@ +requirements_ecore_x = @requirements_ecore_x@ +rt_libs = @rt_libs@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +version_info = @version_info@ +x_cflags = @x_cflags@ +x_includes = @x_includes@ +x_libs = @x_libs@ +MAINTAINERCLEANFILES = Makefile.in +AM_CPPFLAGS = \ +-I$(top_srcdir) \ +-I$(top_srcdir)/src/lib/ecore \ +-I$(top_srcdir)/src/lib/ecore_input \ +-I$(top_srcdir)/src/lib/ecore_x \ +-I$(top_srcdir)/src/lib/ecore_imf \ +-I$(top_srcdir)/src/lib/ecore_evas \ +-I$(top_builddir)/src/lib/ecore \ +-I$(top_builddir)/src/lib/ecore_input \ +-I$(top_builddir)/src/lib/ecore_x \ +-I$(top_builddir)/src/lib/ecore_imf \ +-I$(top_builddir)/src/lib/ecore_evas \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ +@SCIM_CFLAGS@ \ +@EVAS_CFLAGS@ \ +@EINA_CFLAGS@ + +pkgdir = $(libdir)/ecore/immodules +pkg_LTLIBRARIES = scim.la +scim_la_SOURCES = \ +scim_imcontext.cpp \ +scim_module.cpp \ +scim_imcontext.h + +scim_la_LIBADD = \ + $(top_builddir)/src/lib/ecore_imf/libecore_imf.la \ + $(top_builddir)/src/lib/ecore_x/libecore_x.la \ + @SCIM_LIBS@ \ + @EVAS_LIBS@ \ + @EINA_LIBS@ + +scim_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version +scim_la_LIBTOOLFLAGS = --tag=disable-static +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/modules/immodules/scim/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/modules/immodules/scim/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-pkgLTLIBRARIES: $(pkg_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(pkgdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgdir)" + @list='$(pkg_LTLIBRARIES)'; test -n "$(pkgdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkgdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkgdir)"; \ + } + +uninstall-pkgLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(pkg_LTLIBRARIES)'; test -n "$(pkgdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkgdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkgdir)/$$f"; \ + done + +clean-pkgLTLIBRARIES: + -test -z "$(pkg_LTLIBRARIES)" || rm -f $(pkg_LTLIBRARIES) + @list='$(pkg_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +scim.la: $(scim_la_OBJECTS) $(scim_la_DEPENDENCIES) + $(AM_V_CXXLD)$(scim_la_LINK) -rpath $(pkgdir) $(scim_la_OBJECTS) $(scim_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scim_la-scim_imcontext.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scim_la-scim_module.Plo@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +scim_la-scim_imcontext.lo: scim_imcontext.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(scim_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT scim_la-scim_imcontext.lo -MD -MP -MF $(DEPDIR)/scim_la-scim_imcontext.Tpo -c -o scim_la-scim_imcontext.lo `test -f 'scim_imcontext.cpp' || echo '$(srcdir)/'`scim_imcontext.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/scim_la-scim_imcontext.Tpo $(DEPDIR)/scim_la-scim_imcontext.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='scim_imcontext.cpp' object='scim_la-scim_imcontext.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(scim_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o scim_la-scim_imcontext.lo `test -f 'scim_imcontext.cpp' || echo '$(srcdir)/'`scim_imcontext.cpp + +scim_la-scim_module.lo: scim_module.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(scim_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT scim_la-scim_module.lo -MD -MP -MF $(DEPDIR)/scim_la-scim_module.Tpo -c -o scim_la-scim_module.lo `test -f 'scim_module.cpp' || echo '$(srcdir)/'`scim_module.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/scim_la-scim_module.Tpo $(DEPDIR)/scim_la-scim_module.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='scim_module.cpp' object='scim_la-scim_module.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(scim_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o scim_la-scim_module.lo `test -f 'scim_module.cpp' || echo '$(srcdir)/'`scim_module.cpp + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: + for dir in "$(DESTDIR)$(pkgdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libtool clean-pkgLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-pkgLTLIBRARIES + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-pkgLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-pkgLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-pkgLTLIBRARIES install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-pkgLTLIBRARIES + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libraries/ecore/src/modules/immodules/scim/scim_imcontext.cpp b/libraries/ecore/src/modules/immodules/scim/scim_imcontext.cpp new file mode 100644 index 0000000..6cb72c2 --- /dev/null +++ b/libraries/ecore/src/modules/immodules/scim/scim_imcontext.cpp @@ -0,0 +1,2839 @@ +#ifdef HAVE_CONFIG_H +#include +#endif + +#define Uses_SCIM_DEBUG +#define Uses_SCIM_BACKEND +#define Uses_SCIM_IMENGINE_MODULE +#define Uses_SCIM_HOTKEY +#define Uses_SCIM_PANEL_CLIENT + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include "scim_imcontext.h" + +using namespace scim; + +struct _EcoreIMFContextISFImpl +{ + EcoreIMFContextISF *parent; + IMEngineInstancePointer si; + Ecore_X_Window client_window; + Evas *client_canvas; + Ecore_IMF_Input_Mode input_mode; + WideString preedit_string; + AttributeList preedit_attrlist; + Ecore_IMF_Autocapital_Type autocapital_type; + int preedit_caret; + int cursor_x; + int cursor_y; + int cursor_pos; + bool use_preedit; + bool is_on; + bool shared_si; + bool preedit_started; + bool preedit_updating; + bool need_commit_preedit; + bool uppercase; + bool prediction_allow; + + EcoreIMFContextISFImpl *next; +}; + +/* Input Context handling functions. */ +static EcoreIMFContextISFImpl *new_ic_impl (EcoreIMFContextISF *parent); +static void delete_ic_impl (EcoreIMFContextISFImpl *impl); +static void delete_all_ic_impl (void); + +static EcoreIMFContextISF *find_ic (int id); + + +/* private functions */ +static void panel_slot_reload_config (int context); +static void panel_slot_exit (int context); +static void panel_slot_update_lookup_table_page_size(int context, + int page_size); +static void panel_slot_lookup_table_page_up (int context); +static void panel_slot_lookup_table_page_down (int context); +static void panel_slot_trigger_property (int context, + const String &property); +static void panel_slot_process_helper_event (int context, + const String &target_uuid, + const String &helper_uuid, + const Transaction &trans); +static void panel_slot_move_preedit_caret (int context, + int caret_pos); +static void panel_slot_select_candidate (int context, + int cand_index); +static void panel_slot_process_key_event (int context, + const KeyEvent &key); +static void panel_slot_commit_string (int context, + const WideString &wstr); +static void panel_slot_forward_key_event (int context, + const KeyEvent &key); +static void panel_slot_request_help (int context); +static void panel_slot_request_factory_menu (int context); +static void panel_slot_change_factory (int context, + const String &uuid); + +static void panel_req_focus_in (EcoreIMFContextISF *ic); +static void panel_req_update_factory_info (EcoreIMFContextISF *ic); +static void panel_req_update_spot_location (EcoreIMFContextISF *ic); +static void panel_req_show_help (EcoreIMFContextISF *ic); +static void panel_req_show_factory_menu (EcoreIMFContextISF *ic); + +/* Panel iochannel handler*/ +static bool panel_initialize (void); +static void panel_finalize (void); +static Eina_Bool panel_iochannel_handler (void *data, + Ecore_Fd_Handler *fd_handler); + +/* utility functions */ +static bool filter_hotkeys (EcoreIMFContextISF *ic, + const KeyEvent &key); +static void turn_on_ic (EcoreIMFContextISF *ic); +static void turn_off_ic (EcoreIMFContextISF *ic); +static void set_ic_capabilities (EcoreIMFContextISF *ic); + +static void initialize (void); +static void finalize (void); + +static void open_next_factory (EcoreIMFContextISF *ic); +static void open_previous_factory (EcoreIMFContextISF *ic); +static void open_specific_factory (EcoreIMFContextISF *ic, + const String &uuid); +static void initialize_modifier_bits (Display *display); +static unsigned int scim_x11_keymask_scim_to_x11 (Display *display, uint16 scimkeymask); +static XKeyEvent createKeyEvent (Display *display, Window &win, + Window &winRoot, bool press, + int keycode, int modifiers); +static void _x_send_key_event (const KeyEvent &key); + +static void attach_instance (const IMEngineInstancePointer &si); + +/* slot functions */ +static void slot_show_preedit_string (IMEngineInstanceBase *si); +static void slot_show_aux_string (IMEngineInstanceBase *si); +static void slot_show_lookup_table (IMEngineInstanceBase *si); + +static void slot_hide_preedit_string (IMEngineInstanceBase *si); +static void slot_hide_aux_string (IMEngineInstanceBase *si); +static void slot_hide_lookup_table (IMEngineInstanceBase *si); + +static void slot_update_preedit_caret (IMEngineInstanceBase *si, + int caret); +static void slot_update_preedit_string (IMEngineInstanceBase *si, + const WideString &str, + const AttributeList &attrs); +static void slot_update_aux_string (IMEngineInstanceBase *si, + const WideString &str, + const AttributeList &attrs); +static void slot_commit_string (IMEngineInstanceBase *si, + const WideString &str); +static void slot_forward_key_event (IMEngineInstanceBase *si, + const KeyEvent &key); +static void slot_update_lookup_table (IMEngineInstanceBase *si, + const LookupTable &table); + +static void slot_register_properties (IMEngineInstanceBase *si, + const PropertyList &properties); +static void slot_update_property (IMEngineInstanceBase *si, + const Property &property); +static void slot_beep (IMEngineInstanceBase *si); +static void slot_start_helper (IMEngineInstanceBase *si, + const String &helper_uuid); +static void slot_stop_helper (IMEngineInstanceBase *si, + const String &helper_uuid); +static void slot_send_helper_event (IMEngineInstanceBase *si, + const String &helper_uuid, + const Transaction &trans); +static bool slot_get_surrounding_text (IMEngineInstanceBase *si, + WideString &text, + int &cursor, + int maxlen_before, + int maxlen_after); +static bool slot_delete_surrounding_text (IMEngineInstanceBase *si, + int offset, + int len); + +static void reload_config_callback (const ConfigPointer &config); + +static void fallback_commit_string_cb (IMEngineInstanceBase *si, + const WideString &str); + +static void caps_mode_check (Ecore_IMF_Context *ctx, Eina_Bool force); + +/* Local variables declaration */ +static String _language; +static EcoreIMFContextISFImpl *_used_ic_impl_list = 0; +static EcoreIMFContextISFImpl *_free_ic_impl_list = 0; +static EcoreIMFContextISF *_ic_list = 0; + +static KeyboardLayout _keyboard_layout = SCIM_KEYBOARD_Default; +static int _valid_key_mask = SCIM_KEY_AllMasks; + +static FrontEndHotkeyMatcher _frontend_hotkey_matcher; +static IMEngineHotkeyMatcher _imengine_hotkey_matcher; + +static IMEngineInstancePointer _default_instance; + +static ConfigModule *_config_module = 0; +static ConfigPointer _config; +static BackEndPointer _backend; + +static EcoreIMFContextISF *_focused_ic = 0; + +static bool _scim_initialized = false; + +static int _instance_count = 0; +static int _context_count = 0; + +static IMEngineFactoryPointer _fallback_factory; +static IMEngineInstancePointer _fallback_instance; +static PanelClient _panel_client; + +static Ecore_Fd_Handler *_panel_iochannel_read_handler = 0; +static Ecore_Fd_Handler *_panel_iochannel_err_handler = 0; + +static Ecore_X_Window _client_window = 0; + +static bool _on_the_spot = true; +static bool _shared_input_method = false; + +static Eina_Bool autocap_allow = EINA_FALSE; + +static Display *__current_display = 0; +static int __current_alt_mask = Mod1Mask; +static int __current_meta_mask = 0; +static int __current_super_mask = 0; +static int __current_hyper_mask = 0; +static int __current_numlock_mask = Mod2Mask; + +// A hack to shutdown the immodule cleanly even if im_module_exit () is not called when exiting. +class FinalizeHandler +{ +public: + FinalizeHandler () + { + SCIM_DEBUG_FRONTEND(1) << "FinalizeHandler::FinalizeHandler ()\n"; + } + ~FinalizeHandler () + { + SCIM_DEBUG_FRONTEND(1) << "FinalizeHandler::~FinalizeHandler ()\n"; + isf_imf_context_shutdown (); + } +}; + +static FinalizeHandler _finalize_handler; + +static unsigned int +utf8_offset_to_index(const char *str, int offset) +{ + int index = 0; + int i; + for (i = 0; i < offset; i++) + { + eina_unicode_utf8_get_next(str, &index); + } + + return index; +} + +static unsigned int +get_time (void) +{ + unsigned int tint; + struct timeval tv; + struct timezone tz; /* is not used since ages */ + gettimeofday (&tv, &tz); + tint = tv.tv_sec * 1000; + tint = tint / 1000 * 1000; + tint = tint + tv.tv_usec / 1000; + return tint; +} + +/* Function Implementations */ +static EcoreIMFContextISFImpl * +new_ic_impl (EcoreIMFContextISF *parent) +{ + EcoreIMFContextISFImpl *impl = NULL; + + if (_free_ic_impl_list != NULL) + { + impl = _free_ic_impl_list; + _free_ic_impl_list = _free_ic_impl_list->next; + } + else + { + impl = new EcoreIMFContextISFImpl; + if (impl == NULL) + return NULL; + } + + impl->uppercase = false; + impl->autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_NONE; + impl->next = _used_ic_impl_list; + _used_ic_impl_list = impl; + + impl->parent = parent; + + return impl; +} + +static void +delete_ic_impl (EcoreIMFContextISFImpl *impl) +{ + EcoreIMFContextISFImpl *rec = _used_ic_impl_list, *last = 0; + + for (; rec != 0; last = rec, rec = rec->next) + { + if (rec == impl) + { + if (last != 0) + last->next = rec->next; + else + _used_ic_impl_list = rec->next; + + rec->next = _free_ic_impl_list; + _free_ic_impl_list = rec; + + rec->parent = 0; + rec->si.reset (); + rec->client_window = 0; + rec->preedit_string = WideString (); + rec->preedit_attrlist.clear (); + + return; + } + } +} + +static void +delete_all_ic_impl (void) +{ + EcoreIMFContextISFImpl *it = _used_ic_impl_list; + + while (it != 0) + { + _used_ic_impl_list = it->next; + delete it; + it = _used_ic_impl_list; + } + + it = _free_ic_impl_list; + while (it != 0) + { + _free_ic_impl_list = it->next; + delete it; + it = _free_ic_impl_list; + } +} + +static EcoreIMFContextISF * +find_ic (int id) +{ + EcoreIMFContextISFImpl *rec = _used_ic_impl_list; + + while (rec != 0) + { + if (rec->parent && rec->parent->id == id) + return rec->parent; + rec = rec->next; + } + + return 0; +} + +static Eina_Bool +analyze_surrounding_text(Ecore_IMF_Context *ctx) +{ + char *plain_str = NULL; + char *markup_str = NULL; + const char *puncs[3] = {". ", "! ", "? "}; + Eina_Bool ret = EINA_FALSE; + int cursor_pos = 0; + int i = 0; + Eina_Unicode *tail = NULL; + Eina_Unicode *ustr = NULL; + Eina_Unicode *uni_puncs[3]; + EcoreIMFContextISF *context_scim; + + if (!ctx) return EINA_FALSE; + context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); + if (!context_scim || !context_scim->impl) return EINA_FALSE; + + switch (context_scim->impl->autocapital_type) + { + case ECORE_IMF_AUTOCAPITAL_TYPE_NONE: + return EINA_FALSE; + case ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER: + return EINA_TRUE; + default: + break; + } + + for (i=0; i<3; i++) + uni_puncs[i] = eina_unicode_utf8_to_unicode(puncs[i], NULL); + + ecore_imf_context_surrounding_get(ctx, &markup_str, &cursor_pos); + if (!markup_str) goto done; + + if (cursor_pos == 0) + { + ret = EINA_TRUE; + goto done; + } + + // Convert into plain string + plain_str = evas_textblock_text_markup_to_utf8(NULL, markup_str); + if (!plain_str) goto done; + + // Convert string from utf8 to unicode + ustr = eina_unicode_utf8_to_unicode(plain_str, NULL); + if (!ustr) goto done; + + if (cursor_pos >= 1) + { + if (context_scim->impl->autocapital_type == ECORE_IMF_AUTOCAPITAL_TYPE_WORD) + { + if (ustr[cursor_pos-1] == ' ') + { + ret = EINA_TRUE; + goto done; + } + } + + // Check paragraph separator and carrage return
+ if ((ustr[cursor_pos-1] == 0x2029) || (ustr[cursor_pos-1] == '\n')) + { + ret = EINA_TRUE; + goto done; + } + } + + // check punctuation + if (cursor_pos >= 2) + { + tail = eina_unicode_strndup(ustr+cursor_pos-2, 2); + + if (tail) + { + for (i=0; i<3; i++) + { + if (!eina_unicode_strcmp(tail, uni_puncs[i])) + { + ret = EINA_TRUE; + break; + } + } + free(tail); + tail = NULL; + } + } + +done: + if (ustr) free(ustr); + if (markup_str) free(markup_str); + if (plain_str) free(plain_str); + + for (i=0; i<3; i++) + if (uni_puncs[i]) free(uni_puncs[i]); + + return ret; +} + +static void +caps_mode_check(Ecore_IMF_Context *ctx, Eina_Bool force) +{ + Eina_Bool uppercase; + EcoreIMFContextISF *context_scim; + + if (!ctx) return; + context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); + + if (autocap_allow == EINA_FALSE) + return; + + // Check autocapital type + if (!context_scim || !context_scim->impl) + return; + + if (analyze_surrounding_text(ctx)) + uppercase = EINA_TRUE; + else + uppercase = EINA_FALSE; + + if (force) + context_scim->impl->uppercase = uppercase; + else + if (context_scim->impl->uppercase != uppercase) + context_scim->impl->uppercase = uppercase; +} + +static void +feed_key_event (Evas *evas, const char *str, Eina_Bool fake) +{ + char key_string[128] = {0}; + unsigned int timestamp = 0; + + if (!fake) + timestamp = get_time (); + + if (strncmp (str, "KeyRelease+", 11) == 0) + { + strncpy(key_string, str + 11, strlen(str)-11); + evas_event_feed_key_up (evas, key_string, key_string, NULL, NULL, timestamp, NULL); + SCIM_DEBUG_FRONTEND(1) << " evas_event_feed_key_up ()...\n"; + } + else + { + strncpy(key_string, str, strlen(str)); + evas_event_feed_key_down (evas, key_string, key_string, NULL, NULL, timestamp, NULL); + SCIM_DEBUG_FRONTEND(1) << " evas_event_feed_key_down ()...\n"; + } +} + +/* Public functions */ +/** + * isf_imf_context_new + * + * This function will be called by Ecore IMF. + * Create a instance of type EcoreIMFContextISF. + * + * Return value: A pointer to the newly created EcoreIMFContextISF instance + */ +EAPI EcoreIMFContextISF * +isf_imf_context_new (void) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + char *env; + + Ecore_X_Display *display = ecore_x_display_get (); + if (!display) + { + std::cerr << "ecore_x_display_get () failed !!!"; + return NULL; + } + + EcoreIMFContextISF *context_scim = new EcoreIMFContextISF; + if (context_scim == NULL) + { + std::cerr << "memory allocation failed in " << __FUNCTION__ << "\n"; + return NULL; + } + + context_scim->id = _context_count++; + + if (!_scim_initialized) + { + initialize (); + _scim_initialized = true; + } + + env = getenv("ECORE_IMF_AUTOCAPITAL_ALLOW"); + if (env) + autocap_allow = !!atoi(env); + + return context_scim; +} + +/** + * isf_imf_shutdown + * + * It will be called when the scim im module is unloaded by ecore. It will do some + * cleanup job. + */ +EAPI void +isf_imf_context_shutdown (void) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + if (_scim_initialized) + { + _scim_initialized = false; + finalize (); + } +} + +EAPI void +isf_imf_context_add (Ecore_IMF_Context *ctx) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get (ctx); + + if (!context_scim) return; + + context_scim->impl = NULL; + + if (_backend.null ()) + return; + + IMEngineInstancePointer si; + + // Use the default instance if "shared input method" mode is enabled. + if (_shared_input_method && !_default_instance.null ()) + { + si = _default_instance; + SCIM_DEBUG_FRONTEND(2) << "use default instance: " << si->get_id () << " " << si->get_factory_uuid () << "\n"; + } + + // Not in "shared input method" mode, or no default instance, create an instance. + if (si.null ()) + { + IMEngineFactoryPointer factory = _backend->get_default_factory (_language, "UTF-8"); + if (factory.null ()) return; + si = factory->create_instance ("UTF-8", _instance_count++); + if (si.null ()) return; + attach_instance (si); + SCIM_DEBUG_FRONTEND(2) << "create new instance: " << si->get_id () << " " << si->get_factory_uuid () << "\n"; + } + + // If "shared input method" mode is enabled, and there is no default instance, + // then store this instance as default one. + if (_shared_input_method && _default_instance.null ()) + { + SCIM_DEBUG_FRONTEND(2) << "update default instance.\n"; + _default_instance = si; + } + + context_scim->ctx = ctx; + context_scim->impl = new_ic_impl (context_scim); + if (context_scim->impl == NULL) + { + std::cerr << "memory allocation failed in " << __FUNCTION__ << "\n"; + return; + } + + context_scim->impl->si = si; + context_scim->impl->client_window = 0; + context_scim->impl->client_canvas = NULL; + context_scim->impl->preedit_caret = 0; + context_scim->impl->cursor_x = 0; + context_scim->impl->cursor_y = 0; + context_scim->impl->cursor_pos = -1; + context_scim->impl->is_on = false; + context_scim->impl->shared_si = _shared_input_method; + context_scim->impl->use_preedit = _on_the_spot; + context_scim->impl->preedit_started = false; + context_scim->impl->preedit_updating = false; + context_scim->impl->need_commit_preedit = false; + + if (!_ic_list) + context_scim->next = NULL; + else + context_scim->next = _ic_list; + _ic_list = context_scim; + + if (_shared_input_method) + context_scim->impl->is_on = _config->read (String (SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), context_scim->impl->is_on); + + _panel_client.prepare (context_scim->id); + _panel_client.register_input_context (context_scim->id, si->get_factory_uuid ()); + set_ic_capabilities (context_scim); + _panel_client.send (); + + SCIM_DEBUG_FRONTEND(2) << "input context created: id = " << context_scim->id << "\n"; +} + +EAPI void +isf_imf_context_del (Ecore_IMF_Context *ctx) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + if (!_ic_list) return; + + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get (ctx); + + if (context_scim) + { + if (context_scim->id != _ic_list->id) + { + EcoreIMFContextISF * pre = _ic_list; + EcoreIMFContextISF * cur = _ic_list->next; + while (cur != NULL) + { + if (cur->id == context_scim->id) + { + pre->next = cur->next; + break; + } + pre = cur; + cur = cur->next; + } + } + else + _ic_list = _ic_list->next; + } + + if (context_scim && context_scim->impl) + { + _panel_client.prepare (context_scim->id); + + if (context_scim == _focused_ic) + context_scim->impl->si->focus_out (); + + // Delete the instance. + EcoreIMFContextISF *old_focused = _focused_ic; + _focused_ic = context_scim; + context_scim->impl->si.reset (); + _focused_ic = old_focused; + + if (context_scim == _focused_ic) + { + _panel_client.turn_off (context_scim->id); + _panel_client.focus_out (context_scim->id); + } + + _panel_client.remove_input_context (context_scim->id); + _panel_client.send (); + + if (context_scim->impl->client_window) + isf_imf_context_client_window_set (ctx, NULL); + + if (context_scim->impl) + { + delete_ic_impl (context_scim->impl); + context_scim->impl = 0; + } + } + + if (context_scim == _focused_ic) + _focused_ic = 0; + + if (context_scim) + { + delete context_scim; + context_scim = 0; + } +} + +/** + * isf_imf_context_client_canvas_set + * @ctx: a #Ecore_IMF_Context + * @canvas: the client canvas + * + * This function will be called by Ecore IMF. + * + * Set the client canvas for the Input Method Context; this is the canvas + * in which the input appears. + * + * The canvas type can be determined by using the context canvas type. + * Actually only canvas with type "evas" (Evas *) is supported. This canvas + * may be used in order to correctly position status windows, and may also + * be used for purposes internal to the Input Method Context. + */ +EAPI void +isf_imf_context_client_canvas_set (Ecore_IMF_Context *ctx, void *canvas) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); + + if (context_scim && context_scim->impl && context_scim->impl->client_canvas != (Evas*) canvas) + context_scim->impl->client_canvas = (Evas*)canvas; +} + +/** + * isf_imf_context_client_window_set + * @ctx: a #Ecore_IMF_Context + * @window: the client window + * + * This function will be called by Ecore IMF. + * + * Set the client window for the Input Method Context; this is the Ecore_X_Window + * when using X11, Ecore_Win32_Window when using Win32, etc. + * + * This window is used in order to correctly position status windows, + * and may also be used for purposes internal to the Input Method Context. + */ +EAPI void +isf_imf_context_client_window_set (Ecore_IMF_Context *ctx, void *window) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); + + if (context_scim && context_scim->impl && context_scim->impl->client_window != (Ecore_X_Window)((Ecore_Window)window)) + { + context_scim->impl->client_window = (Ecore_X_Window)((Ecore_Window)window); + + if ((context_scim->impl->client_window != 0) && + (context_scim->impl->client_window != _client_window)) + _client_window = context_scim->impl->client_window; + } +} + +/** + * isf_imf_context_reset + * @ctx: a #Ecore_IMF_Context + * + * This function will be called by Ecore IMF. + * + * Notify the Input Method Context that a change such as a change in cursor + * position has been made. This will typically cause the Input Method Context + * to clear the preedit state. + */ +EAPI void +isf_imf_context_reset (Ecore_IMF_Context *ctx) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); + + if (context_scim && context_scim->impl && context_scim == _focused_ic) + { + WideString wstr = context_scim->impl->preedit_string; + + _panel_client.prepare (context_scim->id); + context_scim->impl->si->reset (); + _panel_client.send (); + + if (context_scim->impl->need_commit_preedit) + { + if (wstr.length ()) + { + ecore_imf_context_commit_event_add (context_scim->ctx, utf8_wcstombs (wstr).c_str ()); + ecore_imf_context_event_callback_call(context_scim->ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)utf8_wcstombs(wstr).c_str()); + } + _panel_client.prepare (context_scim->id); + _panel_client.send (); + } + } +} + +/** + * isf_imf_context_focus_in + * @ctx: a #Ecore_IMF_Context + * + * This function will be called by Ecore IMF. + * + * Notify the Input Method Context that the widget to which its correspond has gained focus. + */ +EAPI void +isf_imf_context_focus_in (Ecore_IMF_Context *ctx) +{ + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); + + if (!context_scim) + return; + + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__<< "(" << context_scim->id << ")...\n"; + + if (_focused_ic) + { + if (_focused_ic == context_scim) + { + SCIM_DEBUG_FRONTEND(1) << "It's already focused.\n"; + //isf_imf_context_cursor_position_set (ctx, 0); + return; + } + SCIM_DEBUG_FRONTEND(1) << "Focus out previous IC first: " << _focused_ic->id << "\n"; + if (_focused_ic->ctx) + isf_imf_context_focus_out (_focused_ic->ctx); + } + + bool need_cap = false; + bool need_reset = false; + bool need_reg = false; + + if (context_scim && context_scim->impl) + { + _focused_ic = context_scim; + _panel_client.prepare (context_scim->id); + + // Handle the "Shared Input Method" mode. + if (_shared_input_method) + { + SCIM_DEBUG_FRONTEND(2) << "shared input method.\n"; + IMEngineFactoryPointer factory = _backend->get_default_factory (_language, "UTF-8"); + if (!factory.null ()) + { + if (_default_instance.null () || _default_instance->get_factory_uuid () != factory->get_uuid ()) + { + _default_instance = factory->create_instance ("UTF-8", _default_instance.null () ? _instance_count++ : _default_instance->get_id ()); + attach_instance (_default_instance); + SCIM_DEBUG_FRONTEND(2) << "create new default instance: " << _default_instance->get_id () << " " << _default_instance->get_factory_uuid () << "\n"; + } + + context_scim->impl->shared_si = true; + context_scim->impl->si = _default_instance; + + context_scim->impl->is_on = _config->read (String (SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), context_scim->impl->is_on); + context_scim->impl->preedit_string.clear (); + context_scim->impl->preedit_attrlist.clear (); + context_scim->impl->preedit_caret = 0; + context_scim->impl->preedit_started = false; + need_cap = true; + need_reset = true; + need_reg = true; + } + } + else if (context_scim->impl->shared_si) + { + SCIM_DEBUG_FRONTEND(2) << "exit shared input method.\n"; + IMEngineFactoryPointer factory = _backend->get_default_factory (_language, "UTF-8"); + if (!factory.null ()) + { + context_scim->impl->si = factory->create_instance ("UTF-8", _instance_count++); + context_scim->impl->preedit_string.clear (); + context_scim->impl->preedit_attrlist.clear (); + context_scim->impl->preedit_caret = 0; + context_scim->impl->preedit_started = false; + attach_instance (context_scim->impl->si); + need_cap = true; + need_reg = true; + context_scim->impl->shared_si = false; + SCIM_DEBUG_FRONTEND(2) << "create new instance: " << context_scim->impl->si->get_id () << " " << context_scim->impl->si->get_factory_uuid () << "\n"; + } + } + + context_scim->impl->si->set_frontend_data (static_cast (context_scim)); + + if (need_reg) _panel_client.register_input_context (context_scim->id, context_scim->impl->si->get_factory_uuid ()); + if (need_cap) set_ic_capabilities (context_scim); + if (need_reset) context_scim->impl->si->reset (); + + panel_req_focus_in (context_scim); + panel_req_update_spot_location (context_scim); + panel_req_update_factory_info (context_scim); + + if (context_scim->impl->is_on) + { + _panel_client.turn_on (context_scim->id); + _panel_client.hide_preedit_string (context_scim->id); + _panel_client.hide_aux_string (context_scim->id); + _panel_client.hide_lookup_table (context_scim->id); + context_scim->impl->si->focus_in (); + } + else + { + _panel_client.turn_off (context_scim->id); + } + + _panel_client.send (); + } +} + +/** + * isf_imf_context_focus_out + * @ctx: a #Ecore_IMF_Context + * + * This function will be called by Ecore IMF. + * + * Notify the Input Method Context that the widget to which its correspond has lost focus. + */ +EAPI void +isf_imf_context_focus_out (Ecore_IMF_Context *ctx) +{ + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); + + if (!context_scim) return; + + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "(" << context_scim->id << ")...\n"; + + if (context_scim && context_scim->impl && context_scim == _focused_ic) + { + WideString wstr = context_scim->impl->preedit_string; + + if (context_scim->impl->need_commit_preedit) + { + if (wstr.length ()) + { + ecore_imf_context_commit_event_add (context_scim->ctx, utf8_wcstombs (wstr).c_str ()); + ecore_imf_context_event_callback_call(context_scim->ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)utf8_wcstombs(wstr).c_str()); + } + _panel_client.prepare (context_scim->id); + _panel_client.send (); + } + + _panel_client.prepare (context_scim->id); + context_scim->impl->si->focus_out (); + context_scim->impl->si->reset (); + _panel_client.turn_off (context_scim->id); + _panel_client.focus_out (context_scim->id); + _panel_client.send (); + _focused_ic = 0; + } +} + +/** + * isf_imf_context_cursor_location_set + * @ctx: a #Ecore_IMF_Context + * @x: x position of New cursor. + * @y: y position of New cursor. + * @w: the width of New cursor. + * @h: the height of New cursor. + * + * This function will be called by Ecore IMF. + * + * Notify the Input Method Context that a change in the cursor location has been made. + */ +EAPI void +isf_imf_context_cursor_location_set (Ecore_IMF_Context *ctx, int cx, int cy, int cw, int ch) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); + Ecore_Evas *ee; + int canvas_x, canvas_y; + + if (cw == 0 && ch == 0) + return; + + if (context_scim && context_scim->impl && context_scim == _focused_ic) + { + // Don't update spot location while updating preedit string. + if (context_scim->impl->preedit_updating) + return; + + if (!context_scim->impl->client_canvas) + return; + + ee = ecore_evas_ecore_evas_get(context_scim->impl->client_canvas); + if (!ee) return; + + ecore_evas_geometry_get (ee, &canvas_x, &canvas_y, NULL, NULL); + + if (context_scim->impl->cursor_x != canvas_x + cx || context_scim->impl->cursor_y != canvas_y + cy + ch) + { + context_scim->impl->cursor_x = canvas_x + cx; + context_scim->impl->cursor_y = canvas_y + cy + ch; + _panel_client.prepare (context_scim->id); + panel_req_update_spot_location (context_scim); + _panel_client.send (); + SCIM_DEBUG_FRONTEND(2) << "new cursor location = " << context_scim->impl->cursor_x << "," << context_scim->impl->cursor_y << "\n"; + } + } +} + +/** + * isf_imf_context_use_preedit_set + * @ctx: a #Ecore_IMF_Context + * @use_preedit: Whether the IM context should use the preedit string. + * + * This function will be called by Ecore IMF. + * + * Set whether the IM context should use the preedit string to display feedback. + * If is 0 (default is 1), then the IM context may use some other method to + * display feedback, such as displaying it in a child of the root window. + */ +EAPI void +isf_imf_context_use_preedit_set (Ecore_IMF_Context* ctx, Eina_Bool use_preedit) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " = " << (use_preedit ? "true" : "false") << "...\n"; + + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get (ctx); + + if (!_on_the_spot) return; + + if (context_scim && context_scim->impl) + { + bool old = context_scim->impl->use_preedit; + context_scim->impl->use_preedit = use_preedit; + if (context_scim == _focused_ic) + { + _panel_client.prepare (context_scim->id); + + if (old != use_preedit) + set_ic_capabilities (context_scim); + + if (context_scim->impl->preedit_string.length ()) + slot_show_preedit_string (context_scim->impl->si); + + _panel_client.send (); + } + } +} + +EAPI void +isf_imf_context_preedit_string_with_attributes_get (Ecore_IMF_Context *ctx, char** str, Eina_List **attrs, int *cursor_pos) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get (ctx); + + if (context_scim && context_scim->impl && context_scim->impl->is_on) + { + String mbs = utf8_wcstombs (context_scim->impl->preedit_string); + + if (str) + { + if (mbs.length ()) + *str = strdup (mbs.c_str ()); + else + *str = strdup (""); + } + + if (cursor_pos) + { + *cursor_pos = context_scim->impl->preedit_caret; + } + + if (attrs) + { + if (mbs.length ()) + { + int start_index, end_index; + int wlen = context_scim->impl->preedit_string.length (); + + Ecore_IMF_Preedit_Attr *attr = NULL; + AttributeList::const_iterator i; + bool *attrs_flag = new bool [mbs.length ()]; + memset (attrs_flag, 0, mbs.length () *sizeof (bool)); + + for (i = context_scim->impl->preedit_attrlist.begin (); + i != context_scim->impl->preedit_attrlist.end (); ++i) + { + start_index = i->get_start (); + end_index = i->get_end (); + + if (end_index <= wlen && start_index < end_index && i->get_type () != SCIM_ATTR_DECORATE_NONE) + { + start_index = utf8_offset_to_index (mbs.c_str (), i->get_start ()); + end_index = utf8_offset_to_index (mbs.c_str (), i->get_end ()); + + if (i->get_type () == SCIM_ATTR_DECORATE) + { + attr = (Ecore_IMF_Preedit_Attr *)calloc(1, sizeof(Ecore_IMF_Preedit_Attr)); + if (attr == NULL) + continue; + attr->start_index = start_index; + attr->end_index = end_index; + + if (i->get_value () == SCIM_ATTR_DECORATE_UNDERLINE) + { + attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB1; + *attrs = eina_list_append(*attrs, (void *)attr); + } + else if (i->get_value () == SCIM_ATTR_DECORATE_REVERSE) + { + attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB2; + *attrs = eina_list_append(*attrs, (void *)attr); + } + else if (i->get_value () == SCIM_ATTR_DECORATE_HIGHLIGHT) + { + attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB3; + *attrs = eina_list_append(*attrs, (void *)attr); + } + else + { + free (attr); + } + + switch(i->get_value()) + { + case SCIM_ATTR_DECORATE_UNDERLINE: + case SCIM_ATTR_DECORATE_REVERSE: + case SCIM_ATTR_DECORATE_HIGHLIGHT: + // Record which character has attribute. + for (int pos = start_index; pos < end_index; ++pos) + attrs_flag [pos] = 1; + break; + default: + break; + } + } + else if (i->get_type () == SCIM_ATTR_FOREGROUND) + { + SCIM_DEBUG_FRONTEND(4) << "SCIM_ATTR_FOREGROUND\n"; + } + else if (i->get_type () == SCIM_ATTR_BACKGROUND) + { + SCIM_DEBUG_FRONTEND(4) << "SCIM_ATTR_BACKGROUND\n"; + } + } + } + + // Add underline for all characters which don't have attribute. + for (unsigned int pos = 0; pos < mbs.length (); ++pos) + { + if (!attrs_flag [pos]) + { + int begin_pos = pos; + + while (pos < mbs.length () && !attrs_flag [pos]) + ++pos; + + // use REVERSE style as default + attr = (Ecore_IMF_Preedit_Attr *)calloc(1, sizeof(Ecore_IMF_Preedit_Attr)); + if (attr == NULL) + continue; + attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB2; + attr->start_index = begin_pos; + attr->end_index = pos; + *attrs = eina_list_append(*attrs, (void *)attr); + } + } + + delete [] attrs_flag; + } + } + } + else + { + if (str) + *str = strdup (""); + + if (cursor_pos) + *cursor_pos = 0; + + if (attrs) + *attrs = NULL; + } +} + +/** + * isf_imf_context_preedit_string_get + * @ctx: a #Ecore_IMF_Context + * @str: the preedit string + * @cursor_pos: the cursor position + * + * This function will be called by Ecore IMF. + * + * To get the preedit string of the input method. + */ +EAPI void +isf_imf_context_preedit_string_get (Ecore_IMF_Context *ctx, char** str, int *cursor_pos) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get (ctx); + + if (context_scim && context_scim->impl && context_scim->impl->is_on) + { + String mbs = utf8_wcstombs (context_scim->impl->preedit_string); + + if (str) + { + if (mbs.length ()) + *str = strdup (mbs.c_str ()); + else + *str = strdup (""); + } + + if (cursor_pos) + *cursor_pos = context_scim->impl->preedit_caret; + } + else + { + if (str) + *str = strdup (""); + + if (cursor_pos) + *cursor_pos = 0; + } +} + +/** + * isf_imf_context_cursor_position_set + * @ctx: a #Ecore_IMF_Context + * @cursor_pos: New cursor position in characters. + * + * This function will be called by Ecore IMF. + * + * Notify the Input Method Context that a change in the cursor position has been made. + */ +EAPI void +isf_imf_context_cursor_position_set (Ecore_IMF_Context *ctx, int cursor_pos) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); + + if (context_scim && context_scim->impl && context_scim == _focused_ic) + { + // Don't update spot location while updating preedit string. + if (context_scim->impl->preedit_updating) + return; + + if (context_scim->impl->cursor_pos != cursor_pos) + { + context_scim->impl->cursor_pos = cursor_pos; + caps_mode_check(ctx, EINA_FALSE); + } + } +} + +/** + * isf_imf_context_input_mode_set + * @ctx: a #Ecore_IMF_Context + * @input_mode: the input mode + * + * This function will be called by Ecore IMF. + * + * To set the input mode of input method. The definition of Ecore_IMF_Input_Mode + * is in Ecore_IMF.h. + */ +EAPI void +isf_imf_context_input_mode_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode input_mode) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF*)ecore_imf_context_data_get (ctx); + if (context_scim && context_scim->impl) + context_scim->impl->input_mode = input_mode; +} + +/** + * isf_imf_context_prediction_allow_set + * @ctx: a #Ecore_IMF_Context + * @use_prediction: Whether the IM context should use the prediction. + * + * This function will be called by Ecore IMF. + * + * Set whether the IM context should use the prediction. + */ +EAPI void +isf_imf_context_prediction_allow_set (Ecore_IMF_Context* ctx, Eina_Bool prediction) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " = " << (prediction ? "true" : "false") << "...\n"; + + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); + + if (context_scim && context_scim->impl && context_scim->impl->prediction_allow != prediction) + context_scim->impl->prediction_allow = prediction; +} + +EAPI void +isf_imf_context_autocapital_type_set (Ecore_IMF_Context* ctx, Ecore_IMF_Autocapital_Type autocapital_type) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " = " << autocapital_type << "...\n"; + + EcoreIMFContextISF *context_scim = (EcoreIMFContextISF *)ecore_imf_context_data_get (ctx); + + if (context_scim && context_scim->impl && context_scim->impl->autocapital_type != autocapital_type) + context_scim->impl->autocapital_type = autocapital_type; +} + +/** + * isf_imf_context_filter_event + * @ctx: a #Ecore_IMF_Context + * @type: The type of event defined by Ecore_IMF_Event_Type. + * @event: The event itself. + * Return value: %TRUE if the input method handled the key event. + * + * This function will be called by Ecore IMF. + * + * Allow an Ecore Input Context to internally handle an event. If this function + * returns 1, then no further processing should be done for this event. Input + * methods must be able to accept all types of events (simply returning 0 if + * the event was not handled), but there is no obligation of any events to be + * submitted to this function. + */ + +EAPI Eina_Bool +isf_imf_context_filter_event (Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, Ecore_IMF_Event *event) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = (EcoreIMFContextISF*)ecore_imf_context_data_get (ctx); + Eina_Bool ret = EINA_FALSE; + + if (ic == NULL || ic->impl == NULL) + return ret; + + KeyEvent key; + + if (type == ECORE_IMF_EVENT_KEY_DOWN) + { + Ecore_IMF_Event_Key_Down *ev = (Ecore_IMF_Event_Key_Down *)event; + scim_string_to_key (key, ev->key); + if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_SHIFT) key.mask |=SCIM_KEY_ShiftMask; + if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_CTRL) key.mask |=SCIM_KEY_ControlMask; + if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_ALT) key.mask |=SCIM_KEY_AltMask; + if (ev->locks & ECORE_IMF_KEYBOARD_LOCK_CAPS) key.mask |=SCIM_KEY_CapsLockMask; + if (ev->locks & ECORE_IMF_KEYBOARD_LOCK_NUM) key.mask |=SCIM_KEY_NumLockMask; + } + else if (type == ECORE_IMF_EVENT_KEY_UP) + { + Ecore_IMF_Event_Key_Up *ev = (Ecore_IMF_Event_Key_Up *)event; + scim_string_to_key (key, ev->key); + key.mask = SCIM_KEY_ReleaseMask; + if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_SHIFT) key.mask |=SCIM_KEY_ShiftMask; + if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_CTRL) key.mask |=SCIM_KEY_ControlMask; + if (ev->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_ALT) key.mask |=SCIM_KEY_AltMask; + if (ev->locks & ECORE_IMF_KEYBOARD_LOCK_CAPS) key.mask |=SCIM_KEY_CapsLockMask; + if (ev->locks & ECORE_IMF_KEYBOARD_LOCK_NUM) key.mask |=SCIM_KEY_NumLockMask; + } + else + { + return ret; + } + + key.mask &= _valid_key_mask; + + _panel_client.prepare (ic->id); + + ret = EINA_TRUE; + if (!filter_hotkeys (ic, key)) + { + if (!_focused_ic || !_focused_ic->impl->is_on || + !_focused_ic->impl->si->process_key_event (key)) + ret = EINA_FALSE; + } + + _panel_client.send (); + + return ret; +} + +/* Panel Slot functions */ +static void +panel_slot_reload_config (int context __UNUSED__) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + _config->reload (); +} + +static void +panel_slot_exit (int /* context */) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + finalize (); +} + +static void +panel_slot_update_lookup_table_page_size (int context, int page_size) +{ + EcoreIMFContextISF *ic = find_ic (context); + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " page_size=" << page_size << " ic=" << ic << "\n"; + if (ic && ic->impl) + { + _panel_client.prepare (ic->id); + ic->impl->si->update_lookup_table_page_size (page_size); + _panel_client.send (); + } +} + +static void +panel_slot_lookup_table_page_up (int context) +{ + EcoreIMFContextISF *ic = find_ic (context); + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " ic=" << ic << "\n"; + if (ic && ic->impl) + { + _panel_client.prepare (ic->id); + ic->impl->si->lookup_table_page_up (); + _panel_client.send (); + } +} + +static void +panel_slot_lookup_table_page_down (int context) +{ + EcoreIMFContextISF *ic = find_ic (context); + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " ic=" << ic << "\n"; + if (ic && ic->impl) + { + _panel_client.prepare (ic->id); + ic->impl->si->lookup_table_page_down (); + _panel_client.send (); + } +} + +static void +panel_slot_trigger_property (int context, const String &property) +{ + EcoreIMFContextISF *ic = find_ic (context); + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " property=" << property << " ic=" << ic << "\n"; + if (ic && ic->impl) + { + _panel_client.prepare (ic->id); + ic->impl->si->trigger_property (property); + _panel_client.send (); + } +} + +static void +panel_slot_process_helper_event (int context, const String &target_uuid, const String &helper_uuid, const Transaction &trans) +{ + EcoreIMFContextISF *ic = find_ic (context); + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " target=" << target_uuid + << " helper=" << helper_uuid << " ic=" << ic << " ic->impl=" << (ic ? ic->impl : 0) << " ic-uuid=" + << ((ic && ic->impl) ? ic->impl->si->get_factory_uuid () : "" ) << "\n"; + if (ic && ic->impl && ic->impl->si->get_factory_uuid () == target_uuid) + { + _panel_client.prepare (ic->id); + SCIM_DEBUG_FRONTEND(2) << "call process_helper_event\n"; + ic->impl->si->process_helper_event (helper_uuid, trans); + _panel_client.send (); + } +} + +static void +panel_slot_move_preedit_caret (int context, int caret_pos) +{ + EcoreIMFContextISF *ic = find_ic (context); + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " caret=" << caret_pos << " ic=" << ic << "\n"; + if (ic && ic->impl) + { + _panel_client.prepare (ic->id); + ic->impl->si->move_preedit_caret (caret_pos); + _panel_client.send (); + } +} + +static void +panel_slot_select_candidate (int context, int cand_index) +{ + EcoreIMFContextISF *ic = find_ic (context); + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " candidate=" << cand_index << " ic=" << ic << "\n"; + if (ic && ic->impl) + { + _panel_client.prepare (ic->id); + ic->impl->si->select_candidate (cand_index); + _panel_client.send (); + } +} + +static void +panel_slot_process_key_event (int context, const KeyEvent &key) +{ + EcoreIMFContextISF *ic = find_ic (context); + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " key=" << key.get_key_string () << " ic=" << ic << "\n"; + + if (ic && ic->impl && ic->impl->client_canvas) + feed_key_event(ic->impl->client_canvas, key.get_key_string().c_str(), EINA_FALSE); +} + +static void +panel_slot_commit_string (int context, const WideString &wstr) +{ + EcoreIMFContextISF *ic = find_ic (context); + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " str=" << utf8_wcstombs (wstr) << " ic=" << ic << "\n"; + + if (ic && ic->impl) + { + if (_focused_ic != ic) + return; + + ecore_imf_context_commit_event_add (ic->ctx, utf8_wcstombs (wstr).c_str ()); + ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)utf8_wcstombs(wstr).c_str()); + } +} + +static void +panel_slot_forward_key_event (int context, const KeyEvent &key) +{ + EcoreIMFContextISF *ic = find_ic (context); + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " key=" << key.get_key_string () << " ic=" << ic << "\n"; + + if (ic && ic->impl && ic->impl->client_canvas) + feed_key_event (ic->impl->client_canvas, key.get_key_string ().c_str (), EINA_TRUE); +} + +static void +panel_slot_request_help (int context) +{ + EcoreIMFContextISF *ic = find_ic (context); + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " ic=" << ic << "\n"; + + if (ic && ic->impl) + { + _panel_client.prepare (ic->id); + panel_req_show_help (ic); + _panel_client.send (); + } +} + +static void +panel_slot_request_factory_menu (int context) +{ + EcoreIMFContextISF *ic = find_ic (context); + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " ic=" << ic << "\n"; + + if (ic && ic->impl) + { + _panel_client.prepare (ic->id); + panel_req_show_factory_menu (ic); + _panel_client.send (); + } +} + +static void +panel_slot_change_factory (int context, const String &uuid) +{ + EcoreIMFContextISF *ic = find_ic (context); + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " context=" << context << " factory=" << uuid << " ic=" << ic << "\n"; + + if (ic && ic->impl) + { + ic->impl->si->reset (); + _panel_client.prepare (ic->id); + open_specific_factory (ic, uuid); + _panel_client.send (); + } +} + +/* Panel Requestion functions. */ +static void +panel_req_show_help (EcoreIMFContextISF *ic) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + String help; + + help = String ("Smart Common Input Method platform ") + + //String (SCIM_VERSION) + + String ("\n(C) 2002-2005 James Su \n\n"); + + if (ic && ic->impl) + { + IMEngineFactoryPointer sf = _backend->get_factory (ic->impl->si->get_factory_uuid ()); + if (sf) + { + help += utf8_wcstombs (sf->get_name ()); + help += String (":\n\n"); + + help += utf8_wcstombs (sf->get_help ()); + help += String ("\n\n"); + + help += utf8_wcstombs (sf->get_credits ()); + } + _panel_client.show_help (ic->id, help); + } +} + +static void +panel_req_show_factory_menu (EcoreIMFContextISF *ic) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + std::vector factories; + std::vector menu; + + _backend->get_factories_for_encoding (factories, "UTF-8"); + + for (size_t i = 0; i < factories.size (); ++ i) + { + menu.push_back (PanelFactoryInfo ( + factories [i]->get_uuid (), + utf8_wcstombs (factories [i]->get_name ()), + factories [i]->get_language (), + factories [i]->get_icon_file ())); + } + + if (menu.size ()) + _panel_client.show_factory_menu (ic->id, menu); +} + +static void +panel_req_update_factory_info (EcoreIMFContextISF *ic) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + if (ic && ic->impl && ic == _focused_ic) + { + PanelFactoryInfo info; + if (ic->impl->is_on) + { + IMEngineFactoryPointer sf = _backend->get_factory (ic->impl->si->get_factory_uuid ()); + if (sf) + info = PanelFactoryInfo (sf->get_uuid (), utf8_wcstombs (sf->get_name ()), sf->get_language (), sf->get_icon_file ()); + } + else + { + info = PanelFactoryInfo (String (""), String ("English/Keyboard"), String ("C"), ""); + } + _panel_client.update_factory_info (ic->id, info); + } +} + +static void +panel_req_focus_in (EcoreIMFContextISF *ic) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + _panel_client.focus_in (ic->id, ic->impl->si->get_factory_uuid ()); +} + +static void +panel_req_update_spot_location (EcoreIMFContextISF *ic) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + _panel_client.update_spot_location (ic->id, ic->impl->cursor_x, ic->impl->cursor_y); +} + +static bool +filter_hotkeys (EcoreIMFContextISF *ic, const KeyEvent &key) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + bool ret = false; + + _frontend_hotkey_matcher.push_key_event (key); + _imengine_hotkey_matcher.push_key_event (key); + + FrontEndHotkeyAction hotkey_action = _frontend_hotkey_matcher.get_match_result (); + + if (hotkey_action == SCIM_FRONTEND_HOTKEY_TRIGGER) + { + if (!ic->impl->is_on) + turn_on_ic (ic); + else + turn_off_ic (ic); + ret = true; + } + else if (hotkey_action == SCIM_FRONTEND_HOTKEY_ON) + { + if (!ic->impl->is_on) + turn_on_ic (ic); + ret = true; + } + else if (hotkey_action == SCIM_FRONTEND_HOTKEY_OFF) + { + if (ic->impl->is_on) + turn_off_ic (ic); + ret = true; + } + else if (hotkey_action == SCIM_FRONTEND_HOTKEY_NEXT_FACTORY) + { + open_next_factory (ic); + ret = true; + } + else if (hotkey_action == SCIM_FRONTEND_HOTKEY_PREVIOUS_FACTORY) + { + open_previous_factory (ic); + ret = true; + } + else if (hotkey_action == SCIM_FRONTEND_HOTKEY_SHOW_FACTORY_MENU) + { + panel_req_show_factory_menu (ic); + ret = true; + } + else if (_imengine_hotkey_matcher.is_matched ()) + { + String sfid = _imengine_hotkey_matcher.get_match_result (); + open_specific_factory (ic, sfid); + ret = true; + } + return ret; +} + +static bool +panel_initialize (void) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + String display_name; + { + const char *p = getenv ("DISPLAY"); + if (p) display_name = String (p); + } + + if (_panel_client.open_connection (_config->get_name (), display_name) >= 0) + { + int fd = _panel_client.get_connection_number (); + + _panel_iochannel_read_handler = ecore_main_fd_handler_add (fd, ECORE_FD_READ, panel_iochannel_handler, NULL, NULL, NULL); + + SCIM_DEBUG_FRONTEND(2) << " Panel FD= " << fd << "\n"; + + return true; + } + std::cerr << "panel_initialize () failed!!!\n"; + return false; +} + +static void +panel_finalize (void) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + _panel_client.close_connection (); + + if (_panel_iochannel_read_handler) + { + ecore_main_fd_handler_del (_panel_iochannel_read_handler); + _panel_iochannel_read_handler = 0; + } + + if (_panel_iochannel_err_handler) + { + ecore_main_fd_handler_del (_panel_iochannel_err_handler); + _panel_iochannel_err_handler = 0; + } +} + +static Eina_Bool +panel_iochannel_handler (void *data __UNUSED__, Ecore_Fd_Handler *fd_handler) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + if (fd_handler == _panel_iochannel_read_handler) + { + if (!_panel_client.filter_event ()) + { + panel_finalize (); + panel_initialize (); + return ECORE_CALLBACK_CANCEL; + } + } + else if (fd_handler == _panel_iochannel_err_handler) + { + panel_finalize (); + panel_initialize (); + return ECORE_CALLBACK_CANCEL; + } + return ECORE_CALLBACK_RENEW; +} + +static void +turn_on_ic (EcoreIMFContextISF *ic) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + if (ic && ic->impl && !ic->impl->is_on) + { + ic->impl->is_on = true; + + if (ic == _focused_ic) + { + panel_req_focus_in (ic); + panel_req_update_spot_location (ic); + panel_req_update_factory_info (ic); + _panel_client.turn_on (ic->id); + _panel_client.hide_preedit_string (ic->id); + _panel_client.hide_aux_string (ic->id); + _panel_client.hide_lookup_table (ic->id); + ic->impl->si->focus_in (); + } + + //Record the IC on/off status + if (_shared_input_method) + _config->write (String (SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), true); + + if (ic->impl->use_preedit && ic->impl->preedit_string.length ()) + { + ecore_imf_context_preedit_start_event_add (ic->ctx); + ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_START, NULL); + ecore_imf_context_preedit_changed_event_add (ic->ctx); + ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); + ic->impl->preedit_started = true; + } + } +} + +static void +turn_off_ic (EcoreIMFContextISF *ic) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + if (ic && ic->impl && ic->impl->is_on) + { + ic->impl->is_on = false; + + if (ic == _focused_ic) + { + ic->impl->si->focus_out (); + + panel_req_update_factory_info (ic); + _panel_client.turn_off (ic->id); + } + + //Record the IC on/off status + if (_shared_input_method) + _config->write (String (SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), false); + + if (ic->impl->use_preedit && ic->impl->preedit_string.length ()) + { + ecore_imf_context_preedit_changed_event_add (ic->ctx); + ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); + ecore_imf_context_preedit_end_event_add (ic->ctx); + ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_END, NULL); + ic->impl->preedit_started = false; + } + } +} + +static void +set_ic_capabilities (EcoreIMFContextISF *ic) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + if (ic && ic->impl) + { + unsigned int cap = SCIM_CLIENT_CAP_ALL_CAPABILITIES; + + if (!_on_the_spot || !ic->impl->use_preedit) + cap -= SCIM_CLIENT_CAP_ONTHESPOT_PREEDIT; + + ic->impl->si->update_client_capabilities (cap); + } +} + +static bool +check_socket_frontend (void) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + SocketAddress address; + SocketClient client; + + uint32 magic; + + address.set_address (scim_get_default_socket_frontend_address ()); + + if (!client.connect (address)) + return false; + + if (!scim_socket_open_connection (magic, + String ("ConnectionTester"), + String ("SocketFrontEnd"), + client, + 1000)) + return false; + + return true; +} + +void +initialize (void) +{ + std::vector config_list; + std::vector engine_list; + std::vector load_engine_list; + + std::vector::iterator it; + + bool manual = false; + + bool socket = true; + + String config_module_name = "simple"; + + printf("Initializing Ecore SCIM IMModule...\n"); + + SCIM_DEBUG_FRONTEND(1) << "Initializing Ecore SCIM IMModule...\n"; + + // Get system language. + _language = scim_get_locale_language (scim_get_current_locale ()); + + if (socket) + { + // If no Socket FrontEnd is running, then launch one. + // And set manual to false. + bool check_result = check_socket_frontend (); + if (!check_result) + { + std::cerr << "Launching a SCIM daemon with Socket FrontEnd...\n"; + //get modules list + scim_get_imengine_module_list (engine_list); + + for (it = engine_list.begin (); it != engine_list.end (); it++) + { + if (*it != "socket") + load_engine_list.push_back (*it); + } + + const char *new_argv [] = { "--no-stay", 0 }; + scim_launch (true, + config_module_name, + (load_engine_list.size () ? scim_combine_string_list (load_engine_list, ',') : "none"), + "socket", + (char **)new_argv); + manual = false; + } + + // If there is one Socket FrontEnd running and it's not manual mode, + // then just use this Socket Frontend. + if (!manual) + { + for (int i = 0; i < 200; ++i) + { + if (check_result) + { + config_module_name = "socket"; + load_engine_list.clear (); + load_engine_list.push_back ("socket"); + break; + } + scim_usleep (50000); + check_result = check_socket_frontend (); + } + } + } + + if (config_module_name != "dummy") + { + //load config module + SCIM_DEBUG_FRONTEND(1) << "Loading Config module: " << config_module_name << "...\n"; + _config_module = new ConfigModule (config_module_name); + + //create config instance + if (_config_module != NULL && _config_module->valid ()) + _config = _config_module->create_config (); + } + + if (_config.null ()) + { + SCIM_DEBUG_FRONTEND(1) << "Config module cannot be loaded, using dummy Config.\n"; + + if (_config_module) delete _config_module; + _config_module = NULL; + + _config = new DummyConfig (); + config_module_name = "dummy"; + } + + reload_config_callback (_config); + _config->signal_connect_reload (slot (reload_config_callback)); + + // create backend + _backend = new CommonBackEnd (_config, load_engine_list.size () ? load_engine_list : engine_list); + + if (_backend.null ()) + std::cerr << "Cannot create BackEnd Object!\n"; + else + _fallback_factory = _backend->get_factory (SCIM_COMPOSE_KEY_FACTORY_UUID); + + if (_fallback_factory.null ()) + _fallback_factory = new DummyIMEngineFactory (); + + _fallback_instance = _fallback_factory->create_instance (String ("UTF-8"), 0); + _fallback_instance->signal_connect_commit_string (slot (fallback_commit_string_cb)); + + // Attach Panel Client signal. + _panel_client.signal_connect_reload_config (slot (panel_slot_reload_config)); + _panel_client.signal_connect_exit (slot (panel_slot_exit)); + _panel_client.signal_connect_update_lookup_table_page_size (slot (panel_slot_update_lookup_table_page_size)); + _panel_client.signal_connect_lookup_table_page_up (slot (panel_slot_lookup_table_page_up)); + _panel_client.signal_connect_lookup_table_page_down (slot (panel_slot_lookup_table_page_down)); + _panel_client.signal_connect_trigger_property (slot (panel_slot_trigger_property)); + _panel_client.signal_connect_process_helper_event (slot (panel_slot_process_helper_event)); + _panel_client.signal_connect_move_preedit_caret (slot (panel_slot_move_preedit_caret)); + _panel_client.signal_connect_select_candidate (slot (panel_slot_select_candidate)); + _panel_client.signal_connect_process_key_event (slot (panel_slot_process_key_event)); + _panel_client.signal_connect_commit_string (slot (panel_slot_commit_string)); + _panel_client.signal_connect_forward_key_event (slot (panel_slot_forward_key_event)); + _panel_client.signal_connect_request_help (slot (panel_slot_request_help)); + _panel_client.signal_connect_request_factory_menu (slot (panel_slot_request_factory_menu)); + _panel_client.signal_connect_change_factory (slot (panel_slot_change_factory)); + + if (!panel_initialize ()) + std::cerr << "Ecore IM Module: Cannot connect to Panel!\n"; +} + +static void +finalize (void) +{ + SCIM_DEBUG_FRONTEND(1) << "Finalizing Ecore ISF IMModule...\n"; + + // Reset this first so that the shared instance could be released correctly afterwards. + _default_instance.reset (); + + SCIM_DEBUG_FRONTEND(2) << "Finalize all IC partially.\n"; + while (_used_ic_impl_list) + { + // In case in "shared input method" mode, + // all contexts share only one instance, + // so we need point the reference pointer correctly before finalizing. + _used_ic_impl_list->si->set_frontend_data (static_cast (_used_ic_impl_list->parent)); + isf_imf_context_del (_used_ic_impl_list->parent->ctx); + } + + delete_all_ic_impl (); + + _fallback_instance.reset (); + _fallback_factory.reset (); + + SCIM_DEBUG_FRONTEND(2) << " Releasing BackEnd...\n"; + _backend.reset (); + + SCIM_DEBUG_FRONTEND(2) << " Releasing Config...\n"; + _config.reset (); + + if (_config_module) + { + SCIM_DEBUG_FRONTEND(2) << " Deleting _config_module...\n"; + delete _config_module; + _config_module = 0; + } + + _focused_ic = NULL; + _ic_list = NULL; + + _scim_initialized = false; + + panel_finalize (); +} + +static void +open_next_factory (EcoreIMFContextISF *ic) +{ + SCIM_DEBUG_FRONTEND(2) << __FUNCTION__ << " context=" << ic->id << "\n"; + IMEngineFactoryPointer sf = _backend->get_next_factory ("", "UTF-8", ic->impl->si->get_factory_uuid ()); + + if (!sf.null ()) + { + turn_off_ic (ic); + ic->impl->si = sf->create_instance ("UTF-8", ic->impl->si->get_id ()); + ic->impl->si->set_frontend_data (static_cast (ic)); + ic->impl->preedit_string = WideString (); + ic->impl->preedit_caret = 0; + attach_instance (ic->impl->si); + _backend->set_default_factory (_language, sf->get_uuid ()); + _panel_client.register_input_context (ic->id, sf->get_uuid ()); + set_ic_capabilities (ic); + turn_on_ic (ic); + + if (_shared_input_method) + { + _default_instance = ic->impl->si; + ic->impl->shared_si = true; + } + } +} + +static void +open_previous_factory (EcoreIMFContextISF *ic) +{ + if (ic == NULL) + return; + + SCIM_DEBUG_FRONTEND(2) << __FUNCTION__ << " context=" << ic->id << "\n"; + IMEngineFactoryPointer sf = _backend->get_previous_factory ("", "UTF-8", ic->impl->si->get_factory_uuid ()); + + if (!sf.null ()) + { + turn_off_ic (ic); + ic->impl->si = sf->create_instance ("UTF-8", ic->impl->si->get_id ()); + ic->impl->si->set_frontend_data (static_cast (ic)); + ic->impl->preedit_string = WideString (); + ic->impl->preedit_caret = 0; + attach_instance (ic->impl->si); + _backend->set_default_factory (_language, sf->get_uuid ()); + _panel_client.register_input_context (ic->id, sf->get_uuid ()); + set_ic_capabilities (ic); + turn_on_ic (ic); + + if (_shared_input_method) + { + _default_instance = ic->impl->si; + ic->impl->shared_si = true; + } + } +} + +static void +open_specific_factory (EcoreIMFContextISF *ic, + const String &uuid) +{ + if (ic == NULL) + return; + + SCIM_DEBUG_FRONTEND(2) << __FUNCTION__ << " context=" << ic->id << "\n"; + + // The same input method is selected, just turn on the IC. + if (ic->impl->si->get_factory_uuid () == uuid) + { + turn_on_ic (ic); + return; + } + + IMEngineFactoryPointer sf = _backend->get_factory (uuid); + + if (uuid.length () && !sf.null ()) + { + turn_off_ic (ic); + ic->impl->si = sf->create_instance ("UTF-8", ic->impl->si->get_id ()); + ic->impl->si->set_frontend_data (static_cast (ic)); + ic->impl->preedit_string = WideString (); + ic->impl->preedit_caret = 0; + attach_instance (ic->impl->si); + _backend->set_default_factory (_language, sf->get_uuid ()); + _panel_client.register_input_context (ic->id, sf->get_uuid ()); + set_ic_capabilities (ic); + turn_on_ic (ic); + + if (_shared_input_method) + { + _default_instance = ic->impl->si; + ic->impl->shared_si = true; + } + } + else + { + // turn_off_ic comment out panel_req_update_factory_info () + turn_off_ic (ic); + if (ic && ic->impl->is_on) + { + ic->impl->is_on = false; + + if (ic == _focused_ic) + { + ic->impl->si->focus_out (); + + panel_req_update_factory_info (ic); + _panel_client.turn_off (ic->id); + } + + //Record the IC on/off status + if (_shared_input_method) + _config->write (String (SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), false); + + if (ic->impl->use_preedit && ic->impl->preedit_string.length ()) + { + ecore_imf_context_preedit_changed_event_add (ic->ctx); + ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); + ecore_imf_context_preedit_end_event_add (ic->ctx); + ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_END, NULL); + ic->impl->preedit_started = false; + } + } + } +} + +static void initialize_modifier_bits (Display *display) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + if (__current_display == display) + return; + + __current_display = display; + + if (display == 0) + { + __current_alt_mask = Mod1Mask; + __current_meta_mask = ShiftMask | Mod1Mask; + __current_super_mask = 0; + __current_hyper_mask = 0; + __current_numlock_mask = Mod2Mask; + return; + } + + XModifierKeymap *mods = NULL; + + ::KeyCode ctrl_l = XKeysymToKeycode (display, XK_Control_L); + ::KeyCode ctrl_r = XKeysymToKeycode (display, XK_Control_R); + ::KeyCode meta_l = XKeysymToKeycode (display, XK_Meta_L); + ::KeyCode meta_r = XKeysymToKeycode (display, XK_Meta_R); + ::KeyCode alt_l = XKeysymToKeycode (display, XK_Alt_L); + ::KeyCode alt_r = XKeysymToKeycode (display, XK_Alt_R); + ::KeyCode super_l = XKeysymToKeycode (display, XK_Super_L); + ::KeyCode super_r = XKeysymToKeycode (display, XK_Super_R); + ::KeyCode hyper_l = XKeysymToKeycode (display, XK_Hyper_L); + ::KeyCode hyper_r = XKeysymToKeycode (display, XK_Hyper_R); + ::KeyCode numlock = XKeysymToKeycode (display, XK_Num_Lock); + + int i, j; + + mods = XGetModifierMapping (display); + if (mods == NULL) + return; + + __current_alt_mask = 0; + __current_meta_mask = 0; + __current_super_mask = 0; + __current_hyper_mask = 0; + __current_numlock_mask = 0; + + /* We skip the first three sets for Shift, Lock, and Control. The + remaining sets are for Mod1, Mod2, Mod3, Mod4, and Mod5. */ + for (i = 3; i < 8; i++) + { + for (j = 0; j < mods->max_keypermod; j++) + { + ::KeyCode code = mods->modifiermap [i * mods->max_keypermod + j]; + if (! code) continue; + if (code == alt_l || code == alt_r) + __current_alt_mask |= (1 << i); + else if (code == meta_l || code == meta_r) + __current_meta_mask |= (1 << i); + else if (code == super_l || code == super_r) + __current_super_mask |= (1 << i); + else if (code == hyper_l || code == hyper_r) + __current_hyper_mask |= (1 << i); + else if (code == numlock) + __current_numlock_mask |= (1 << i); + } + } + + /* Check whether there is a combine keys mapped to Meta */ + if (__current_meta_mask == 0) + { + char buf [32]; + XKeyEvent xkey; + KeySym keysym_l, keysym_r; + + xkey.type = KeyPress; + xkey.display = display; + xkey.serial = 0L; + xkey.send_event = False; + xkey.x = xkey.y = xkey.x_root = xkey.y_root = 0; + xkey.time = 0; + xkey.same_screen = False; + xkey.subwindow = None; + xkey.window = None; + xkey.root = DefaultRootWindow (display); + xkey.state = ShiftMask; + + xkey.keycode = meta_l; + XLookupString (&xkey, buf, 32, &keysym_l, 0); + xkey.keycode = meta_r; + XLookupString (&xkey, buf, 32, &keysym_r, 0); + + if ((meta_l == alt_l && keysym_l == XK_Meta_L) || (meta_r == alt_r && keysym_r == XK_Meta_R)) + __current_meta_mask = ShiftMask + __current_alt_mask; + else if ((meta_l == ctrl_l && keysym_l == XK_Meta_L) || (meta_r == ctrl_r && keysym_r == XK_Meta_R)) + __current_meta_mask = ShiftMask + ControlMask; + } + + XFreeModifiermap (mods); +} + +static unsigned int scim_x11_keymask_scim_to_x11 (Display *display, uint16 scimkeymask) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + unsigned int state = 0; + + initialize_modifier_bits (display); + + if (scimkeymask & SCIM_KEY_ShiftMask) state |= ShiftMask; + if (scimkeymask & SCIM_KEY_CapsLockMask) state |= LockMask; + if (scimkeymask & SCIM_KEY_ControlMask) state |= ControlMask; + if (scimkeymask & SCIM_KEY_AltMask) state |= __current_alt_mask; + if (scimkeymask & SCIM_KEY_MetaMask) state |= __current_meta_mask; + if (scimkeymask & SCIM_KEY_SuperMask) state |= __current_super_mask; + if (scimkeymask & SCIM_KEY_HyperMask) state |= __current_hyper_mask; + if (scimkeymask & SCIM_KEY_NumLockMask) state |= __current_numlock_mask; + + return state; +} + +static XKeyEvent createKeyEvent (Display *display, Window &win, + Window &winRoot, bool press, + int keycode, int modifiers) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + XKeyEvent event; + + event.display = display; + event.window = win; + event.root = winRoot; + event.subwindow = None; + event.time = CurrentTime; + event.x = 1; + event.y = 1; + event.x_root = 1; + event.y_root = 1; + event.same_screen = EINA_TRUE; + event.state = modifiers; + event.keycode = XKeysymToKeycode (display, keycode); + if (press) + event.type = KeyPress; + else + event.type = KeyRelease; + event.send_event = EINA_FALSE; + event.serial = 0; + + return event; +} + +static void _x_send_key_event (const KeyEvent &key) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + // Obtain the X11 display. + Display *display = XOpenDisplay (NULL); + if (display == NULL) + { + std::cerr << "XOpenDisplay failed\n"; + return; + } + + // Get the root window for the current display. + Window winRoot = 0;// = XRootWindow (display, 1); + + // Find the window which has the current keyboard focus. + Window winFocus = 0; + int revert = RevertToParent; + + XGetInputFocus (display, &winFocus, &revert); + + // Send a fake key press event to the window. + XSelectInput (display, winFocus, FocusChangeMask|KeyPressMask|KeyReleaseMask); + XMapWindow (display, winFocus); + + unsigned int modifier = scim_x11_keymask_scim_to_x11 (display, key.mask); + XKeyEvent event; + if (key.is_key_press ()) + { + event = createKeyEvent (display, winFocus, winRoot, true, key.code, modifier); + XSendEvent (event.display, event.window, True, KeyPressMask, (XEvent *)&event); + } + else + { + event = createKeyEvent (display, winFocus, winRoot, false, key.code, modifier); + XSendEvent (event.display, event.window, True, KeyReleaseMask, (XEvent *)&event); + } + + XCloseDisplay (display); +} + +static void +attach_instance (const IMEngineInstancePointer &si) +{ + si->signal_connect_show_preedit_string ( + slot (slot_show_preedit_string)); + si->signal_connect_show_aux_string ( + slot (slot_show_aux_string)); + si->signal_connect_show_lookup_table ( + slot (slot_show_lookup_table)); + + si->signal_connect_hide_preedit_string ( + slot (slot_hide_preedit_string)); + si->signal_connect_hide_aux_string ( + slot (slot_hide_aux_string)); + si->signal_connect_hide_lookup_table ( + slot (slot_hide_lookup_table)); + + si->signal_connect_update_preedit_caret ( + slot (slot_update_preedit_caret)); + si->signal_connect_update_preedit_string ( + slot (slot_update_preedit_string)); + si->signal_connect_update_aux_string ( + slot (slot_update_aux_string)); + si->signal_connect_update_lookup_table ( + slot (slot_update_lookup_table)); + + si->signal_connect_commit_string ( + slot (slot_commit_string)); + + si->signal_connect_forward_key_event ( + slot (slot_forward_key_event)); + + si->signal_connect_register_properties ( + slot (slot_register_properties)); + + si->signal_connect_update_property ( + slot (slot_update_property)); + + si->signal_connect_beep ( + slot (slot_beep)); + + si->signal_connect_start_helper ( + slot (slot_start_helper)); + + si->signal_connect_stop_helper ( + slot (slot_stop_helper)); + + si->signal_connect_send_helper_event ( + slot (slot_send_helper_event)); + + si->signal_connect_get_surrounding_text ( + slot (slot_get_surrounding_text)); + + si->signal_connect_delete_surrounding_text ( + slot (slot_delete_surrounding_text)); +} + +// Implementation of slot functions +static void +slot_show_preedit_string (IMEngineInstanceBase *si) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->impl && _focused_ic == ic) + { + if (ic->impl->use_preedit) + { + if (!ic->impl->preedit_started) + { + ecore_imf_context_preedit_start_event_add (_focused_ic->ctx); + ecore_imf_context_event_callback_call(_focused_ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_START, NULL); + ic->impl->preedit_started = true; + } + } + else + _panel_client.show_preedit_string (ic->id); + } +} + +static void +slot_show_aux_string (IMEngineInstanceBase *si) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->impl && _focused_ic == ic) + _panel_client.show_aux_string (ic->id); +} + +static void +slot_show_lookup_table (IMEngineInstanceBase *si) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->impl && _focused_ic == ic) + _panel_client.show_lookup_table (ic->id); +} + +static void +slot_hide_preedit_string (IMEngineInstanceBase *si) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->impl && _focused_ic == ic) + { + bool emit = false; + if (ic->impl->preedit_string.length ()) + { + ic->impl->preedit_string = WideString (); + ic->impl->preedit_caret = 0; + ic->impl->preedit_attrlist.clear (); + emit = true; + } + if (ic->impl->use_preedit) + { + if (emit) + { + ecore_imf_context_preedit_changed_event_add (ic->ctx); + ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); + } + if (ic->impl->preedit_started) + { + ecore_imf_context_preedit_end_event_add (ic->ctx); + ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_END, NULL); + ic->impl->preedit_started = false; + } + } + else + _panel_client.hide_preedit_string (ic->id); + } +} + +static void +slot_hide_aux_string (IMEngineInstanceBase *si) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->impl && _focused_ic == ic) + _panel_client.hide_aux_string (ic->id); +} + +static void +slot_hide_lookup_table (IMEngineInstanceBase *si) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->impl && _focused_ic == ic) + _panel_client.hide_lookup_table (ic->id); +} + +static void +slot_update_preedit_caret (IMEngineInstanceBase *si, int caret) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->impl && _focused_ic == ic && ic->impl->preedit_caret != caret) + { + ic->impl->preedit_caret = caret; + if (ic->impl->use_preedit) + { + if (!ic->impl->preedit_started) + { + ecore_imf_context_preedit_start_event_add (ic->ctx); + ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_START, NULL); + ic->impl->preedit_started = true; + } + ecore_imf_context_preedit_changed_event_add (ic->ctx); + ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); + } + else + _panel_client.update_preedit_caret (ic->id, caret); + } +} + +static void +slot_update_preedit_string (IMEngineInstanceBase *si, + const WideString & str, + const AttributeList & attrs) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->impl && _focused_ic == ic && (ic->impl->preedit_string != str || str.length ())) + { + ic->impl->preedit_string = str; + ic->impl->preedit_attrlist = attrs; + if (ic->impl->use_preedit) + { + if (!ic->impl->preedit_started) + { + ecore_imf_context_preedit_start_event_add (_focused_ic->ctx); + ecore_imf_context_event_callback_call(_focused_ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_START, NULL); + ic->impl->preedit_started = true; + } + ic->impl->preedit_caret = str.length (); + ic->impl->preedit_updating = true; + ecore_imf_context_preedit_changed_event_add (ic->ctx); + ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); + ic->impl->preedit_updating = false; + } + else + { + _panel_client.update_preedit_string (ic->id, str, attrs); + } + } +} + +static void +slot_update_aux_string (IMEngineInstanceBase *si, + const WideString & str, + const AttributeList & attrs) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->impl && _focused_ic == ic) + _panel_client.update_aux_string (ic->id, str, attrs); +} + +static void +slot_commit_string (IMEngineInstanceBase *si, + const WideString & str) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->ctx) + { + ecore_imf_context_commit_event_add (ic->ctx, utf8_wcstombs (str).c_str ()); + ecore_imf_context_event_callback_call(ic->ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)utf8_wcstombs(str).c_str()); + } +} + +static void +slot_forward_key_event (IMEngineInstanceBase *si, + const KeyEvent & key) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && _focused_ic == ic) + { + if (!_fallback_instance->process_key_event (key)) + _x_send_key_event(key); + } +} + +static void +slot_update_lookup_table (IMEngineInstanceBase *si, + const LookupTable & table) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->impl && _focused_ic == ic) + _panel_client.update_lookup_table (ic->id, table); +} + +static void +slot_register_properties (IMEngineInstanceBase *si, + const PropertyList & properties) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->impl && _focused_ic == ic) + _panel_client.register_properties (ic->id, properties); +} + +static void +slot_update_property (IMEngineInstanceBase *si, + const Property & property) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->impl && _focused_ic == ic) + _panel_client.update_property (ic->id, property); +} + +static void +slot_beep (IMEngineInstanceBase *si __UNUSED__) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; +} + +static void +slot_start_helper (IMEngineInstanceBase *si, + const String &helper_uuid) +{ + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " helper= " << helper_uuid << " context=" + << (ic ? ic->id : -1) << " ic=" << ic + << " ic-uuid=" << ((ic ) ? ic->impl->si->get_factory_uuid () : "") << "...\n"; + + if (ic && ic->impl) + _panel_client.start_helper (ic->id, helper_uuid); +} + +static void +slot_stop_helper (IMEngineInstanceBase *si, + const String &helper_uuid) +{ + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " helper= " << helper_uuid << " context=" << (ic ? ic->id : -1) << " ic=" << ic << "...\n"; + + if (ic && ic->impl) + _panel_client.stop_helper (ic->id, helper_uuid); +} + +static void +slot_send_helper_event (IMEngineInstanceBase *si, + const String &helper_uuid, + const Transaction &trans) +{ + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " helper= " << helper_uuid << " context=" + << (ic ? ic->id : -1) << " ic=" << ic + << " ic-uuid=" << ((ic) ? ic->impl->si->get_factory_uuid () : "") << "...\n"; + + if (ic && ic->impl) + _panel_client.send_helper_event (ic->id, helper_uuid, trans); +} + +static bool +slot_get_surrounding_text (IMEngineInstanceBase *si, + WideString &text, + int &cursor, + int maxlen_before, + int maxlen_after) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->impl && _focused_ic == ic) + { + char *surrounding = NULL; + int cursor_index; + if (ecore_imf_context_surrounding_get (_focused_ic->ctx, &surrounding, &cursor_index)) + { + SCIM_DEBUG_FRONTEND(2) << "Surrounding text: " << surrounding <<"\n"; + SCIM_DEBUG_FRONTEND(2) << "Cursor Index : " << cursor_index <<"\n"; + WideString before (utf8_mbstowcs (String (surrounding, surrounding + cursor_index))); + WideString after (utf8_mbstowcs (String (surrounding + cursor_index))); + if (maxlen_before > 0 && ((unsigned int)maxlen_before) < before.length ()) + before = WideString (before.begin () + (before.length () - maxlen_before), before.end ()); + else if (maxlen_before == 0) before = WideString (); + if (maxlen_after > 0 && ((unsigned int)maxlen_after) < after.length ()) + after = WideString (after.begin (), after.begin () + maxlen_after); + else if (maxlen_after == 0) after = WideString (); + text = before + after; + cursor = before.length (); + return true; + } + } + return false; +} + +static bool +slot_delete_surrounding_text (IMEngineInstanceBase *si, + int offset, + int len) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = static_cast (si->get_frontend_data ()); + + if (ic && ic->impl && _focused_ic == ic) + { + Ecore_IMF_Event_Delete_Surrounding ev; + ev.ctx = _focused_ic->ctx; + ev.n_chars = len; + ev.offset = offset; + ecore_imf_context_delete_surrounding_event_add (_focused_ic->ctx, offset, len); + ecore_imf_context_event_callback_call(_focused_ic->ctx, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, &ev); + return true; + } + return false; +} + +static void +reload_config_callback (const ConfigPointer &config) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + _frontend_hotkey_matcher.load_hotkeys (config); + _imengine_hotkey_matcher.load_hotkeys (config); + + KeyEvent key; + + scim_string_to_key (key, + config->read (String (SCIM_CONFIG_HOTKEYS_FRONTEND_VALID_KEY_MASK), + String ("Shift+Control+Alt+Lock"))); + + _valid_key_mask = (key.mask > 0)?(key.mask):0xFFFF; + _valid_key_mask |= SCIM_KEY_ReleaseMask; + // Special treatment for two backslash keys on jp106 keyboard. + _valid_key_mask |= SCIM_KEY_QuirkKanaRoMask; + + _on_the_spot = config->read (String (SCIM_CONFIG_FRONTEND_ON_THE_SPOT), _on_the_spot); + _shared_input_method = config->read (String (SCIM_CONFIG_FRONTEND_SHARED_INPUT_METHOD), _shared_input_method); + + // Get keyboard layout setting + // Flush the global config first, in order to load the new configs from disk. + scim_global_config_flush (); + + _keyboard_layout = scim_get_default_keyboard_layout (); +} + +static void +fallback_commit_string_cb (IMEngineInstanceBase *si __UNUSED__, + const WideString &str) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + if (_focused_ic && _focused_ic->impl) + { + ecore_imf_context_commit_event_add (_focused_ic->ctx, utf8_wcstombs (str).c_str ()); + ecore_imf_context_event_callback_call(_focused_ic->ctx, ECORE_IMF_CALLBACK_COMMIT, (void *)utf8_wcstombs(str).c_str()); + } +} + diff --git a/libraries/ecore/src/modules/immodules/scim/scim_imcontext.h b/libraries/ecore/src/modules/immodules/scim/scim_imcontext.h new file mode 100644 index 0000000..84f1a2f --- /dev/null +++ b/libraries/ecore/src/modules/immodules/scim/scim_imcontext.h @@ -0,0 +1,40 @@ +#ifndef __ISF_IMF_CONTEXT_H +#define __ISF_IMF_CONTEXT_H + +#include + +typedef struct _EcoreIMFContextISF EcoreIMFContextISF; +typedef struct _EcoreIMFContextISFImpl EcoreIMFContextISFImpl; + +struct _EcoreIMFContextISF { + Ecore_IMF_Context *ctx; + + EcoreIMFContextISFImpl *impl; + + int id; /* Input Context id*/ + struct _EcoreIMFContextISF *next; +}; + +void isf_imf_context_add (Ecore_IMF_Context *ctx); +void isf_imf_context_del (Ecore_IMF_Context *ctx); +void isf_imf_context_client_window_set (Ecore_IMF_Context *ctx, void *window); +void isf_imf_context_client_canvas_set (Ecore_IMF_Context *ctx, void *window); +void isf_imf_context_focus_in (Ecore_IMF_Context *ctx); +void isf_imf_context_focus_out (Ecore_IMF_Context *ctx); +void isf_imf_context_reset (Ecore_IMF_Context *ctx); +void isf_imf_context_cursor_position_set (Ecore_IMF_Context *ctx, int cursor_pos); +void isf_imf_context_cursor_location_set (Ecore_IMF_Context *ctx, int x, int y, int w, int h); +void isf_imf_context_input_mode_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode input_mode); +void isf_imf_context_preedit_string_get (Ecore_IMF_Context *ctx, char** str, int *cursor_pos); +void isf_imf_context_preedit_string_with_attributes_get (Ecore_IMF_Context *ctx, char** str, Eina_List **attrs, int *cursor_pos); +void isf_imf_context_use_preedit_set (Ecore_IMF_Context* ctx, Eina_Bool use_preedit); +Eina_Bool isf_imf_context_filter_event (Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, Ecore_IMF_Event *event); +void isf_imf_context_prediction_allow_set (Ecore_IMF_Context* ctx, Eina_Bool prediction); +void isf_imf_context_autocapital_type_set (Ecore_IMF_Context* ctx, Ecore_IMF_Autocapital_Type autocapital_type); +void isf_imf_context_input_panel_layout_set (Ecore_IMF_Context* ctx, Ecore_IMF_Input_Panel_Layout layout); + +EcoreIMFContextISF* isf_imf_context_new (void); +void isf_imf_context_shutdown (void); + +#endif /* __ISF_IMF_CONTEXT_H */ + diff --git a/libraries/ecore/src/modules/immodules/scim/scim_module.cpp b/libraries/ecore/src/modules/immodules/scim/scim_module.cpp new file mode 100644 index 0000000..eff6381 --- /dev/null +++ b/libraries/ecore/src/modules/immodules/scim/scim_module.cpp @@ -0,0 +1,93 @@ +#include +#include "scim_imcontext.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + static const Ecore_IMF_Context_Info isf_imf_info = { + "scim", /* ID */ + "SCIM immodule for Ecore", /* Description */ + "*", /* Default locales */ + NULL, /* Canvas type */ + 0 /* Canvas required */ + }; + + static Ecore_IMF_Context_Class isf_imf_class = { + isf_imf_context_add, /* add */ + isf_imf_context_del, /* del */ + isf_imf_context_client_window_set, /* client_window_set */ + isf_imf_context_client_canvas_set, /* client_canvas_set */ + NULL, /* isf_imf_context_input_panel_show, - show */ + NULL, /* isf_imf_context_input_panel_hide, - hide */ + isf_imf_context_preedit_string_get, /* get_preedit_string */ + isf_imf_context_focus_in, /* focus_in */ + isf_imf_context_focus_out, /* focus_out */ + isf_imf_context_reset, /* reset */ + isf_imf_context_cursor_position_set, /* cursor_position_set */ + isf_imf_context_use_preedit_set, /* use_preedit_set */ + isf_imf_context_input_mode_set, /* input_mode_set */ + isf_imf_context_filter_event, /* filter_event */ + isf_imf_context_preedit_string_with_attributes_get, /* preedit_string_with_attribute_get */ + isf_imf_context_prediction_allow_set, /* prediction_allow_set */ + isf_imf_context_autocapital_type_set, /* autocapital_type_set */ + NULL, /* control panel show */ + NULL, /* control panel hide */ + NULL, /* input_panel_layout_set */ + NULL, /* isf_imf_context_input_panel_layout_get, */ + NULL, /* isf_imf_context_input_panel_language_set, */ + NULL, /* isf_imf_context_input_panel_language_get, */ + isf_imf_context_cursor_location_set /* cursor_location_set */ + }; + + static Ecore_IMF_Context *imf_module_create (void); + static Ecore_IMF_Context *imf_module_exit (void); + + static Eina_Bool imf_module_init (void) + { + ecore_imf_module_register (&isf_imf_info, imf_module_create, imf_module_exit); + return EINA_TRUE; + } + + static void imf_module_shutdown (void) + { + isf_imf_context_shutdown (); + } + + static Ecore_IMF_Context *imf_module_create (void) + { + Ecore_IMF_Context *ctx = NULL; + EcoreIMFContextISF *ctxd = NULL; + + ctxd = isf_imf_context_new (); + if (!ctxd) + { + printf ("isf_imf_context_new () failed!!!\n"); + return NULL; + } + + ctx = ecore_imf_context_new (&isf_imf_class); + if (!ctx) + { + delete ctxd; + return NULL; + } + + ecore_imf_context_data_set (ctx, ctxd); + + return ctx; + } + + static Ecore_IMF_Context *imf_module_exit (void) + { + return NULL; + } + + EINA_MODULE_INIT(imf_module_init); + EINA_MODULE_SHUTDOWN(imf_module_shutdown); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + diff --git a/libraries/ecore/src/modules/immodules/xim/Makefile.in b/libraries/ecore/src/modules/immodules/xim/Makefile.in index ec58d4b..5b78946 100644 --- a/libraries/ecore/src/modules/immodules/xim/Makefile.in +++ b/libraries/ecore/src/modules/immodules/xim/Makefile.in @@ -244,10 +244,10 @@ PATH_SEPARATOR = @PATH_SEPARATOR@ PIXMAN_CFLAGS = @PIXMAN_CFLAGS@ PIXMAN_LIBS = @PIXMAN_LIBS@ PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POSUB = @POSUB@ RANLIB = @RANLIB@ +SCIM_CFLAGS = @SCIM_CFLAGS@ +SCIM_LIBS = @SCIM_LIBS@ SDL_CFLAGS = @SDL_CFLAGS@ SDL_CONFIG = @SDL_CONFIG@ SDL_LIBS = @SDL_LIBS@ @@ -266,6 +266,10 @@ TSLIB_LIBS = @TSLIB_LIBS@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ VMAJ = @VMAJ@ +WAYLAND_CFLAGS = @WAYLAND_CFLAGS@ +WAYLAND_EGL_CFLAGS = @WAYLAND_EGL_CFLAGS@ +WAYLAND_EGL_LIBS = @WAYLAND_EGL_LIBS@ +WAYLAND_LIBS = @WAYLAND_LIBS@ WIN32_CFLAGS = @WIN32_CFLAGS@ WIN32_CPPFLAGS = @WIN32_CPPFLAGS@ WIN32_LIBS = @WIN32_LIBS@ @@ -379,6 +383,8 @@ ecore_imf_cflags = @ecore_imf_cflags@ ecore_imf_evas_cflags = @ecore_imf_evas_cflags@ ecore_imf_evas_libs = @ecore_imf_evas_libs@ ecore_imf_libs = @ecore_imf_libs@ +ecore_imf_scim_cflags = @ecore_imf_scim_cflags@ +ecore_imf_scim_libs = @ecore_imf_scim_libs@ ecore_imf_xim_cflags = @ecore_imf_xim_cflags@ ecore_imf_xim_libs = @ecore_imf_xim_libs@ ecore_input_cflags = @ecore_input_cflags@ @@ -391,6 +397,8 @@ ecore_psl1ght_cflags = @ecore_psl1ght_cflags@ ecore_psl1ght_libs = @ecore_psl1ght_libs@ ecore_sdl_cflags = @ecore_sdl_cflags@ ecore_sdl_libs = @ecore_sdl_libs@ +ecore_wayland_cflags = @ecore_wayland_cflags@ +ecore_wayland_libs = @ecore_wayland_libs@ ecore_win32_cflags = @ecore_win32_cflags@ ecore_win32_libs = @ecore_win32_libs@ ecore_wince_cflags = @ecore_wince_cflags@ @@ -435,12 +443,14 @@ requirements_ecore_fb = @requirements_ecore_fb@ requirements_ecore_file = @requirements_ecore_file@ requirements_ecore_imf = @requirements_ecore_imf@ requirements_ecore_imf_evas = @requirements_ecore_imf_evas@ +requirements_ecore_imf_scim = @requirements_ecore_imf_scim@ requirements_ecore_imf_xim = @requirements_ecore_imf_xim@ requirements_ecore_input = @requirements_ecore_input@ requirements_ecore_input_evas = @requirements_ecore_input_evas@ requirements_ecore_ipc = @requirements_ecore_ipc@ requirements_ecore_psl1ght = @requirements_ecore_psl1ght@ requirements_ecore_sdl = @requirements_ecore_sdl@ +requirements_ecore_wayland = @requirements_ecore_wayland@ requirements_ecore_win32 = @requirements_ecore_win32@ requirements_ecore_wince = @requirements_ecore_wince@ requirements_ecore_x = @requirements_ecore_x@ diff --git a/libraries/ecore/src/modules/immodules/xim/ecore_imf_xim.c b/libraries/ecore/src/modules/immodules/xim/ecore_imf_xim.c index 7c40606..ea7ee7f 100644 --- a/libraries/ecore/src/modules/immodules/xim/ecore_imf_xim.c +++ b/libraries/ecore/src/modules/immodules/xim/ecore_imf_xim.c @@ -1,3 +1,7 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include #include @@ -12,9 +16,6 @@ #include #include #include -#ifdef HAVE_CONFIG_H -# include -#endif #define CLAMP(x, low, high) (x > high) ? high : (x < low) ? low : x #define _(x) x @@ -23,6 +24,8 @@ static Eina_List *open_ims = NULL; #endif +#define FEEDBACK_MASK (XIMReverse | XIMUnderline | XIMHighlight) + typedef struct _XIM_Im_Info XIM_Im_Info; struct _XIM_Im_Info { @@ -51,6 +54,7 @@ struct _Ecore_IMF_Context_Data Eina_Bool finalizing; Eina_Bool has_focus; Eina_Bool in_toplevel; + XIMFeedback *feedbacks; XIMCallback preedit_start_cb; XIMCallback preedit_done_cb; @@ -63,40 +67,62 @@ Ecore_IMF_Context_Data *imf_context_data_new(); void imf_context_data_destroy(Ecore_IMF_Context_Data *imf_context_data); #ifdef ENABLE_XIM -static void reinitialize_ic(Ecore_IMF_Context *ctx); -static void reinitialize_all_ics(XIM_Im_Info *info); -static void set_ic_client_window(Ecore_IMF_Context *ctx, - Ecore_X_Window window); -static int preedit_start_callback(XIC xic, - XPointer client_data, - XPointer call_data); -static void preedit_done_callback(XIC xic, - XPointer client_data, - XPointer call_data); -static int xim_text_to_utf8(Ecore_IMF_Context *ctx, - XIMText *xim_text, - char **text); -static void preedit_draw_callback(XIC xic, - XPointer client_data, - XIMPreeditDrawCallbackStruct *call_data); -static void preedit_caret_callback(XIC xic, - XPointer client_data, - XIMPreeditCaretCallbackStruct *call_data); +static void add_feedback_attr(Eina_List **attrs, + const char *str, + XIMFeedback feedback, + int start_pos, + int end_pos); + +static void reinitialize_ic(Ecore_IMF_Context *ctx); +static void reinitialize_all_ics(XIM_Im_Info *info); +static void set_ic_client_window(Ecore_IMF_Context *ctx, + Ecore_X_Window window); +static int preedit_start_callback(XIC xic, + XPointer client_data, + XPointer call_data); +static void preedit_done_callback(XIC xic, + XPointer client_data, + XPointer call_data); +static int xim_text_to_utf8(Ecore_IMF_Context *ctx, + XIMText *xim_text, + char **text); +static void preedit_draw_callback(XIC xic, + XPointer client_data, + XIMPreeditDrawCallbackStruct *call_data); +static void preedit_caret_callback(XIC xic, + XPointer client_data, + XIMPreeditCaretCallbackStruct *call_data); static XVaNestedList preedit_callback_set(Ecore_IMF_Context *ctx); static XIC get_ic(Ecore_IMF_Context *ctx); static XIM_Im_Info *get_im(Ecore_X_Window window, - char *locale); + char *locale); static void xim_info_try_im(XIM_Im_Info *info); static void xim_info_display_closed(Ecore_X_Display *display, - int is_error, - XIM_Im_Info *info); -static void xim_instantiate_callback(Display *display, - XPointer client_data, - XPointer call_data); -static void setup_im(XIM_Im_Info *info); -static void xim_destroy_callback(XIM xim, - XPointer client_data, - XPointer call_data); + int is_error, + XIM_Im_Info *info); +static void xim_instantiate_callback(Display *display, + XPointer client_data, + XPointer call_data); +static void setup_im(XIM_Im_Info *info); +static void xim_destroy_callback(XIM xim, + XPointer client_data, + XPointer call_data); +#endif + +#ifdef ENABLE_XIM +static unsigned int +utf8_offset_to_index(const char *str, int offset) +{ + int index = 0; + int i; + for (i = 0; i < offset; i++) + { + eina_unicode_utf8_get_next(str, &index); + } + + return index; +} + #endif static void @@ -107,7 +133,7 @@ _ecore_imf_context_xim_add(Ecore_IMF_Context *ctx) Ecore_IMF_Context_Data *imf_context_data = NULL; imf_context_data = imf_context_data_new(); - if(!imf_context_data) return; + if (!imf_context_data) return; imf_context_data->use_preedit = EINA_TRUE; imf_context_data->finalizing = EINA_FALSE; @@ -115,6 +141,8 @@ _ecore_imf_context_xim_add(Ecore_IMF_Context *ctx) imf_context_data->in_toplevel = EINA_FALSE; ecore_imf_context_data_set(ctx, imf_context_data); +#else + (void)ctx; #endif } @@ -127,48 +155,53 @@ _ecore_imf_context_xim_del(Ecore_IMF_Context *ctx) imf_context_data = ecore_imf_context_data_get(ctx); imf_context_data->finalizing = EINA_TRUE; - if(imf_context_data->im_info && !imf_context_data->im_info->ics->next) + if (imf_context_data->im_info && !imf_context_data->im_info->ics->next) { - if(imf_context_data->im_info->reconnecting == EINA_TRUE) + if (imf_context_data->im_info->reconnecting == EINA_TRUE) { Ecore_X_Display *dsp; dsp = ecore_x_display_get(); - XUnregisterIMInstantiateCallback (dsp, - NULL, NULL, NULL, - xim_instantiate_callback, - (XPointer)imf_context_data->im_info); + XUnregisterIMInstantiateCallback(dsp, + NULL, NULL, NULL, + xim_instantiate_callback, + (XPointer)imf_context_data->im_info); } - else if(imf_context_data->im_info->im) + else if (imf_context_data->im_info->im) { XIMCallback im_destroy_callback; im_destroy_callback.client_data = NULL; im_destroy_callback.callback = NULL; - XSetIMValues (imf_context_data->im_info->im, - XNDestroyCallback, &im_destroy_callback, - NULL); + XSetIMValues(imf_context_data->im_info->im, + XNDestroyCallback, &im_destroy_callback, + NULL); } } set_ic_client_window(ctx, 0); imf_context_data_destroy(imf_context_data); +#else + (void)ctx; #endif } static void _ecore_imf_context_xim_client_window_set(Ecore_IMF_Context *ctx, - void *window) + void *window) { EINA_LOG_DBG("in"); #ifdef ENABLE_XIM set_ic_client_window(ctx, (Ecore_X_Window)((Ecore_Window)window)); +#else + (void)ctx; + (void)window; #endif } static void _ecore_imf_context_xim_preedit_string_get(Ecore_IMF_Context *ctx, - char **str, - int *cursor_pos) + char **str, + int *cursor_pos) { EINA_LOG_DBG("in"); #ifdef ENABLE_XIM @@ -180,25 +213,73 @@ _ecore_imf_context_xim_preedit_string_get(Ecore_IMF_Context *ctx, { utf8 = eina_unicode_unicode_to_utf8(imf_context_data->preedit_chars, &len); - if(str) - *str = utf8; + if (str) + *str = utf8; else - free(utf8); + free(utf8); } else { - if(str) - *str = NULL; - if(cursor_pos) - *cursor_pos = 0; + if (str) + *str = NULL; + if (cursor_pos) + *cursor_pos = 0; } - if(cursor_pos) + if (cursor_pos) *cursor_pos = imf_context_data->preedit_cursor; #else - if(str) + (void)ctx; + if (str) + *str = NULL; + if (cursor_pos) + *cursor_pos = 0; +#endif +} + +static void +_ecore_imf_context_xim_preedit_string_with_attributes_get(Ecore_IMF_Context *ctx, + char **str, + Eina_List **attrs, + int *cursor_pos) +{ + EINA_LOG_DBG("in"); + +#ifdef ENABLE_XIM + Ecore_IMF_Context_Data *imf_context_data = ecore_imf_context_data_get(ctx); + + _ecore_imf_context_xim_preedit_string_get(ctx, str, cursor_pos); + + if (!attrs) return; + if (!imf_context_data || !imf_context_data->feedbacks) return; + + int i = 0; + XIMFeedback last_feedback = 0; + int start = -1; + + for (i = 0; i < imf_context_data->preedit_length; i++) + { + XIMFeedback new_feedback = imf_context_data->feedbacks[i] & FEEDBACK_MASK; + + if (new_feedback != last_feedback) + { + if (start >= 0) + add_feedback_attr(attrs, *str, last_feedback, start, i); + + last_feedback = new_feedback; + start = i; + } + } + + if (start >= 0) + add_feedback_attr(attrs, *str, last_feedback, start, i); +#else + (void)ctx; + if (str) *str = NULL; - if(cursor_pos) + if (attrs) + *attrs = NULL; + if (cursor_pos) *cursor_pos = 0; #endif } @@ -213,7 +294,7 @@ _ecore_imf_context_xim_focus_in(Ecore_IMF_Context *ctx) imf_context_data = ecore_imf_context_data_get(ctx); ic = imf_context_data->ic; imf_context_data->has_focus = EINA_TRUE; - if(ic) + if (ic) { char *str; @@ -226,6 +307,8 @@ _ecore_imf_context_xim_focus_in(Ecore_IMF_Context *ctx) XSetICFocus(ic); } +#else + (void)ctx; #endif } @@ -237,13 +320,15 @@ _ecore_imf_context_xim_focus_out(Ecore_IMF_Context *ctx) XIC ic; Ecore_IMF_Context_Data *imf_context_data; imf_context_data = ecore_imf_context_data_get(ctx); - if(imf_context_data->has_focus == EINA_TRUE) + if (imf_context_data->has_focus == EINA_TRUE) { imf_context_data->has_focus = EINA_FALSE; ic = imf_context_data->ic; - if(ic) + if (ic) XUnsetICFocus(ic); } +#else + (void)ctx; #endif } @@ -263,18 +348,18 @@ _ecore_imf_context_xim_reset(Ecore_IMF_Context *ctx) imf_context_data = ecore_imf_context_data_get(ctx); ic = imf_context_data->ic; - if(!ic) + if (!ic) return; - if(imf_context_data->preedit_length == 0) + if (imf_context_data->preedit_length == 0) return; preedit_attr = XVaCreateNestedList(0, XNPreeditState, &preedit_state, NULL); - if(!XGetICValues(ic, - XNPreeditAttributes, preedit_attr, - NULL)) + if (!XGetICValues(ic, + XNPreeditAttributes, preedit_attr, + NULL)) have_preedit_state = EINA_TRUE; XFree(preedit_attr); @@ -284,38 +369,49 @@ _ecore_imf_context_xim_reset(Ecore_IMF_Context *ctx) preedit_attr = XVaCreateNestedList(0, XNPreeditState, preedit_state, NULL); - if(have_preedit_state) + if (have_preedit_state) XSetICValues(ic, XNPreeditAttributes, preedit_attr, NULL); XFree(preedit_attr); - if(imf_context_data->preedit_length) + if (imf_context_data->feedbacks) + { + free(imf_context_data->feedbacks); + imf_context_data->feedbacks = NULL; + } + + if (imf_context_data->preedit_length) { imf_context_data->preedit_length = 0; free(imf_context_data->preedit_chars); imf_context_data->preedit_chars = NULL; + ecore_imf_context_preedit_changed_event_add(ctx); + ecore_imf_context_event_callback_call(ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); } - if(result) + if (result) { - char *result_utf8 = strdup(result); - if(result_utf8) - { - ecore_imf_context_commit_event_add(ctx, result_utf8); - free(result_utf8); - } + char *result_utf8 = strdup(result); + if (result_utf8) + { + ecore_imf_context_commit_event_add(ctx, result_utf8); + ecore_imf_context_event_callback_call(ctx, ECORE_IMF_CALLBACK_COMMIT, result_utf8); + free(result_utf8); + } } - XFree (result); + XFree(result); +#else + (void)ctx; #endif } static void _ecore_imf_context_xim_use_preedit_set(Ecore_IMF_Context *ctx, - Eina_Bool use_preedit) + Eina_Bool use_preedit) { EINA_LOG_DBG("in"); #ifdef ENABLE_XIM @@ -324,17 +420,53 @@ _ecore_imf_context_xim_use_preedit_set(Ecore_IMF_Context *ctx, use_preedit = use_preedit != EINA_FALSE; - if(imf_context_data->use_preedit != use_preedit) + if (imf_context_data->use_preedit != use_preedit) { imf_context_data->use_preedit = use_preedit; reinitialize_ic(ctx); } +#else + (void)ctx; + (void)use_preedit; #endif } +#ifdef ENABLE_XIM +static void +add_feedback_attr(Eina_List **attrs, + const char *str, + XIMFeedback feedback, + int start_pos, + int end_pos) +{ + Ecore_IMF_Preedit_Attr *attr = NULL; + + unsigned int start_index = utf8_offset_to_index(str, start_pos); + unsigned int end_index = utf8_offset_to_index(str, end_pos); + + if (feedback & FEEDBACK_MASK) + { + attr = (Ecore_IMF_Preedit_Attr *)calloc(1, sizeof(Ecore_IMF_Preedit_Attr)); + attr->start_index = start_index; + attr->end_index = end_index; + *attrs = eina_list_append(*attrs, (void *)attr); + } + + if (feedback & XIMUnderline) + attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB1; + + if (feedback & XIMReverse) + attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB2; + + if (feedback & XIMHighlight) + attr->preedit_type = ECORE_IMF_PREEDIT_TYPE_SUB3; +} + +#endif + static void -_ecore_imf_context_xim_cursor_location_set (Ecore_IMF_Context *ctx, - int x, int y, int w, int h) +_ecore_imf_context_xim_cursor_location_set(Ecore_IMF_Context *ctx, + int x, int y, int w, int h) { EINA_LOG_DBG("%s in", __FUNCTION__); @@ -342,7 +474,7 @@ _ecore_imf_context_xim_cursor_location_set (Ecore_IMF_Context *ctx, Ecore_IMF_Context_Data *imf_context_data; XIC ic; XVaNestedList preedit_attr; - XPoint spot; + XPoint spot; imf_context_data = ecore_imf_context_data_get(ctx); ic = imf_context_data->ic; @@ -351,15 +483,20 @@ _ecore_imf_context_xim_cursor_location_set (Ecore_IMF_Context *ctx, spot.x = x; spot.y = y + h; - - preedit_attr = XVaCreateNestedList (0, - XNSpotLocation, &spot, - NULL); - XSetICValues (ic, - XNPreeditAttributes, preedit_attr, - NULL); + + preedit_attr = XVaCreateNestedList(0, + XNSpotLocation, &spot, + NULL); + XSetICValues(ic, + XNPreeditAttributes, preedit_attr, + NULL); XFree(preedit_attr); +#else + (void)ctx; + (void)x; + (void)y; + (void)h; #endif (void)(w); // yes w is unused, but only a bi-product of the algorithm } @@ -371,19 +508,19 @@ _ecore_x_event_reverse_modifiers(unsigned int state) unsigned int modifiers = 0; /**< "Control" is pressed */ - if(state & ECORE_IMF_KEYBOARD_MODIFIER_CTRL) + if (state & ECORE_IMF_KEYBOARD_MODIFIER_CTRL) modifiers |= ControlMask; /**< "Alt" is pressed */ - if(state & ECORE_IMF_KEYBOARD_MODIFIER_ALT) + if (state & ECORE_IMF_KEYBOARD_MODIFIER_ALT) modifiers |= Mod1Mask; /**< "Shift" is pressed */ - if(state & ECORE_IMF_KEYBOARD_MODIFIER_SHIFT) + if (state & ECORE_IMF_KEYBOARD_MODIFIER_SHIFT) modifiers |= ShiftMask; /**< "Win" (between "Ctrl" and "A */ - if(state & ECORE_IMF_KEYBOARD_MODIFIER_WIN) + if (state & ECORE_IMF_KEYBOARD_MODIFIER_WIN) modifiers |= Mod5Mask; return modifiers; @@ -395,14 +532,14 @@ _ecore_x_event_reverse_locks(unsigned int state) unsigned int locks = 0; /**< "Num" lock is active */ - if(state & ECORE_IMF_KEYBOARD_LOCK_NUM) + if (state & ECORE_IMF_KEYBOARD_LOCK_NUM) locks |= Mod3Mask; - if(state & ECORE_IMF_KEYBOARD_LOCK_CAPS) + if (state & ECORE_IMF_KEYBOARD_LOCK_CAPS) locks |= LockMask; -#if 0 /* FIXME: add mask. */ - if(state & ECORE_IMF_KEYBOARD_LOCK_SCROLL) +#if 0 /* FIXME: add mask. */ + if (state & ECORE_IMF_KEYBOARD_LOCK_SCROLL) ; #endif @@ -411,12 +548,12 @@ _ecore_x_event_reverse_locks(unsigned int state) static KeyCode _keycode_get(Ecore_X_Display *dsp, - const char *keyname) + const char *keyname) { KeyCode keycode; // EINA_LOG_DBG("keyname:%s keysym:%lu", keyname, XStringToKeysym(keyname)); - if(strcmp(keyname, "Keycode-0") == 0) + if (strcmp(keyname, "Keycode-0") == 0) { keycode = 0; } @@ -430,9 +567,9 @@ _keycode_get(Ecore_X_Display *dsp, #endif static Eina_Bool -_ecore_imf_context_xim_filter_event(Ecore_IMF_Context *ctx, +_ecore_imf_context_xim_filter_event(Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, - Ecore_IMF_Event *event) + Ecore_IMF_Event *event) { EINA_LOG_DBG("%s in", __FUNCTION__); #ifdef ENABLE_XIM @@ -451,12 +588,12 @@ _ecore_imf_context_xim_filter_event(Ecore_IMF_Context *ctx, imf_context_data = ecore_imf_context_data_get(ctx); ic = imf_context_data->ic; - if(!ic) + if (!ic) { ic = get_ic(ctx); } - if(type == ECORE_IMF_EVENT_KEY_DOWN) + if (type == ECORE_IMF_EVENT_KEY_DOWN) { XKeyPressedEvent xev; Ecore_IMF_Event_Key_Down *ev = (Ecore_IMF_Event_Key_Down *)event; @@ -481,7 +618,7 @@ _ecore_imf_context_xim_filter_event(Ecore_IMF_Context *ctx, xev.keycode = _keycode_get(dsp, ev->keyname); xev.same_screen = True; - if(ic) + if (ic) { Status mbstatus; #ifdef X_HAVE_UTF8_STRING @@ -563,15 +700,16 @@ _ecore_imf_context_xim_filter_event(Ecore_IMF_Context *ctx, } } - if(compose) + if (compose) { Eina_Unicode *unicode; int len; unicode = eina_unicode_utf8_to_unicode(compose, &len); - if(!unicode) abort(); - if(unicode[0] >= 0x20 && unicode[0] != 0x7f) + if (!unicode) abort(); + if (unicode[0] >= 0x20 && unicode[0] != 0x7f) { ecore_imf_context_commit_event_add(ctx, compose); + ecore_imf_context_event_callback_call(ctx, ECORE_IMF_CALLBACK_COMMIT, compose); result = EINA_TRUE; } free(compose); @@ -581,6 +719,9 @@ _ecore_imf_context_xim_filter_event(Ecore_IMF_Context *ctx, return result; #else + (void)ctx; + (void)type; + (void)event; return EINA_FALSE; #endif } @@ -608,7 +749,7 @@ static Ecore_IMF_Context_Class xim_class = { .use_preedit_set = _ecore_imf_context_xim_use_preedit_set, .input_mode_set = NULL, .filter_event = _ecore_imf_context_xim_filter_event, - .preedit_string_with_attributes_get = NULL, + .preedit_string_with_attributes_get = _ecore_imf_context_xim_preedit_string_with_attributes_get, .prediction_allow_set = NULL, .autocapital_type_set = NULL, .control_panel_show = NULL, @@ -627,7 +768,7 @@ xim_imf_module_create(void) Ecore_IMF_Context *ctx = NULL; ctx = ecore_imf_context_new(&xim_class); - if(!ctx) + if (!ctx) goto error; return ctx; @@ -686,15 +827,15 @@ imf_context_data_new() char *locale; locale = setlocale(LC_CTYPE, ""); - if(!locale) return NULL; + if (!locale) return NULL; - if(!XSupportsLocale()) return NULL; + if (!XSupportsLocale()) return NULL; imf_context_data = calloc(1, sizeof(Ecore_IMF_Context_Data)); - if(!imf_context_data) return NULL; + if (!imf_context_data) return NULL; imf_context_data->locale = strdup(locale); - if(!imf_context_data->locale) goto error; + if (!imf_context_data->locale) goto error; return imf_context_data; error: @@ -705,19 +846,26 @@ error: void imf_context_data_destroy(Ecore_IMF_Context_Data *imf_context_data) { - if(!imf_context_data) + if (!imf_context_data) return; - if(imf_context_data->ic) + if (imf_context_data->ic) XDestroyIC(imf_context_data->ic); free(imf_context_data->preedit_chars); + + if (imf_context_data->feedbacks) + { + free(imf_context_data->feedbacks); + imf_context_data->feedbacks = NULL; + } + free(imf_context_data->locale); free(imf_context_data); } static int -preedit_start_callback(XIC xic __UNUSED__, +preedit_start_callback(XIC xic __UNUSED__, XPointer client_data, XPointer call_data __UNUSED__) { @@ -726,14 +874,16 @@ preedit_start_callback(XIC xic __UNUSED__, Ecore_IMF_Context_Data *imf_context_data; imf_context_data = ecore_imf_context_data_get(ctx); - if(imf_context_data->finalizing == EINA_FALSE) - ecore_imf_context_preedit_start_event_add(ctx); - + if (imf_context_data->finalizing == EINA_FALSE) + { + ecore_imf_context_preedit_start_event_add(ctx); + ecore_imf_context_event_callback_call(ctx, ECORE_IMF_CALLBACK_PREEDIT_START, NULL); + } return -1; } static void -preedit_done_callback(XIC xic __UNUSED__, +preedit_done_callback(XIC xic __UNUSED__, XPointer client_data, XPointer call_data __UNUSED__) { @@ -742,30 +892,34 @@ preedit_done_callback(XIC xic __UNUSED__, Ecore_IMF_Context_Data *imf_context_data; imf_context_data = ecore_imf_context_data_get(ctx); - if(imf_context_data->preedit_length) + if (imf_context_data->preedit_length) { imf_context_data->preedit_length = 0; free(imf_context_data->preedit_chars); imf_context_data->preedit_chars = NULL; ecore_imf_context_preedit_changed_event_add(ctx); + ecore_imf_context_event_callback_call(ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); } - if(imf_context_data->finalizing == EINA_FALSE) - ecore_imf_context_preedit_end_event_add(ctx); + if (imf_context_data->finalizing == EINA_FALSE) + { + ecore_imf_context_preedit_end_event_add(ctx); + ecore_imf_context_event_callback_call(ctx, ECORE_IMF_CALLBACK_PREEDIT_END, NULL); + } } /* FIXME */ static int xim_text_to_utf8(Ecore_IMF_Context *ctx __UNUSED__, - XIMText *xim_text, - char **text) + XIMText *xim_text, + char **text) { int text_length = 0; char *result = NULL; - if(xim_text && xim_text->string.multi_byte) + if (xim_text && xim_text->string.multi_byte) { - if(xim_text->encoding_is_wchar) + if (xim_text->encoding_is_wchar) { EINA_LOG_WARN("Wide character return from Xlib not currently supported"); *text = NULL; @@ -774,7 +928,7 @@ xim_text_to_utf8(Ecore_IMF_Context *ctx __UNUSED__, /* XXX Convert to UTF-8 */ result = strdup(xim_text->string.multi_byte); - if(result) + if (result) { text_length = eina_unicode_utf8_get_len(result); if (text_length != xim_text->length) @@ -798,8 +952,8 @@ xim_text_to_utf8(Ecore_IMF_Context *ctx __UNUSED__, } static void -preedit_draw_callback(XIC xic __UNUSED__, - XPointer client_data, +preedit_draw_callback(XIC xic __UNUSED__, + XPointer client_data, XIMPreeditDrawCallbackStruct *call_data) { EINA_LOG_DBG("in"); @@ -811,59 +965,83 @@ preedit_draw_callback(XIC xic __UNUSED__, Eina_Unicode *new_text = NULL; Eina_UStrbuf *preedit_bufs = NULL; int new_text_length; + int i = 0; preedit_bufs = eina_ustrbuf_new(); - if(imf_context_data->preedit_chars) { - ret = eina_ustrbuf_append(preedit_bufs, imf_context_data->preedit_chars); - if(ret == EINA_FALSE) goto done; - } + if (imf_context_data->preedit_chars) + { + ret = eina_ustrbuf_append(preedit_bufs, imf_context_data->preedit_chars); + if (ret == EINA_FALSE) goto done; + } new_text_length = xim_text_to_utf8(ctx, t, &tmp); - if(tmp) + if (tmp) { int tmp_len; new_text = eina_unicode_utf8_to_unicode((const char *)tmp, &tmp_len); free(tmp); } - if(t == NULL) { - /* delete string */ - ret = eina_ustrbuf_remove(preedit_bufs, - call_data->chg_first, call_data->chg_length); - } else if(call_data->chg_length == 0) { - /* insert string */ - ret = eina_ustrbuf_insert(preedit_bufs, new_text, call_data->chg_first); - } else if(call_data->chg_length > 0) { - /* replace string */ - ret = eina_ustrbuf_remove(preedit_bufs, - call_data->chg_first, call_data->chg_length); - if(ret == EINA_FALSE) goto done; - - ret = eina_ustrbuf_insert_n(preedit_bufs, new_text, - new_text_length, call_data->chg_first); - if(ret == EINA_FALSE) goto done; - } else { - ret = EINA_FALSE; - } - - done: - if(ret == EINA_TRUE) { - free(imf_context_data->preedit_chars); - imf_context_data->preedit_chars = + if (t == NULL) + { + /* delete string */ + ret = eina_ustrbuf_remove(preedit_bufs, + call_data->chg_first, call_data->chg_length); + } + else if (call_data->chg_length == 0) + { + /* insert string */ + ret = eina_ustrbuf_insert(preedit_bufs, new_text, call_data->chg_first); + } + else if (call_data->chg_length > 0) + { + /* replace string */ + ret = eina_ustrbuf_remove(preedit_bufs, + call_data->chg_first, call_data->chg_length); + if (ret == EINA_FALSE) goto done; + + ret = eina_ustrbuf_insert_n(preedit_bufs, new_text, + new_text_length, call_data->chg_first); + if (ret == EINA_FALSE) goto done; + } + else { + ret = EINA_FALSE; + } + +done: + if (ret == EINA_TRUE) + { + free(imf_context_data->preedit_chars); + imf_context_data->preedit_chars = eina_ustrbuf_string_steal(preedit_bufs); - imf_context_data->preedit_length = + imf_context_data->preedit_length = eina_unicode_strlen(imf_context_data->preedit_chars); - ecore_imf_context_preedit_changed_event_add(ctx); - } + if (imf_context_data->feedbacks) + { + free(imf_context_data->feedbacks); + imf_context_data->feedbacks = NULL; + } + + if (imf_context_data->preedit_length > 0) + { + imf_context_data->feedbacks = calloc(imf_context_data->preedit_length, sizeof(XIMFeedback)); + + for (i = 0; i < imf_context_data->preedit_length; i++) + imf_context_data->feedbacks[i] = t->feedback[i]; + } + + ecore_imf_context_preedit_changed_event_add(ctx); + ecore_imf_context_event_callback_call(ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); + } free(new_text); eina_ustrbuf_free(preedit_bufs); } static void -preedit_caret_callback(XIC xic __UNUSED__, - XPointer client_data, +preedit_caret_callback(XIC xic __UNUSED__, + XPointer client_data, XIMPreeditCaretCallbackStruct *call_data) { EINA_LOG_DBG("in"); @@ -871,12 +1049,15 @@ preedit_caret_callback(XIC xic __UNUSED__, Ecore_IMF_Context_Data *imf_context_data; imf_context_data = ecore_imf_context_data_get(ctx); - if(call_data->direction == XIMAbsolutePosition) + if (call_data->direction == XIMAbsolutePosition) { // printf("call_data->position:%d\n", call_data->position); - imf_context_data->preedit_cursor = call_data->position; - if(imf_context_data->finalizing == EINA_FALSE) - ecore_imf_context_preedit_changed_event_add(ctx); + imf_context_data->preedit_cursor = call_data->position; + if (imf_context_data->finalizing == EINA_FALSE) + { + ecore_imf_context_preedit_changed_event_add(ctx); + ecore_imf_context_event_callback_call(ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); + } } } @@ -917,7 +1098,7 @@ get_ic(Ecore_IMF_Context *ctx) XIC ic; imf_context_data = ecore_imf_context_data_get(ctx); ic = imf_context_data->ic; - if(!ic) + if (!ic) { XIM_Im_Info *im_info = imf_context_data->im_info; XVaNestedList preedit_attr = NULL; @@ -930,7 +1111,7 @@ get_ic(Ecore_IMF_Context *ctx) EINA_LOG_WARN("Doesn't open XIM."); return NULL; } - + // supported styles #if 0 int i; @@ -940,23 +1121,23 @@ get_ic(Ecore_IMF_Context *ctx) { printf("%i: ", i); if (im_info->xim_styles->supported_styles[i] & XIMPreeditCallbacks) - printf("XIMPreeditCallbacks | "); + printf("XIMPreeditCallbacks | "); if (im_info->xim_styles->supported_styles[i] & XIMPreeditPosition) - printf("XIMPreeditPosition | "); + printf("XIMPreeditPosition | "); if (im_info->xim_styles->supported_styles[i] & XIMPreeditArea) - printf("XIMPreeditArea | "); + printf("XIMPreeditArea | "); if (im_info->xim_styles->supported_styles[i] & XIMPreeditNothing) - printf("XIMPreeditNothing | "); + printf("XIMPreeditNothing | "); if (im_info->xim_styles->supported_styles[i] & XIMPreeditNone) - printf("XIMPreeditNone | "); + printf("XIMPreeditNone | "); if (im_info->xim_styles->supported_styles[i] & XIMStatusArea) - printf("XIMStatusArea | "); + printf("XIMStatusArea | "); if (im_info->xim_styles->supported_styles[i] & XIMStatusCallbacks) - printf("XIMStatusCallbacks | "); + printf("XIMStatusCallbacks | "); if (im_info->xim_styles->supported_styles[i] & XIMStatusNothing) - printf("XIMStatusNothing | "); + printf("XIMStatusNothing | "); if (im_info->xim_styles->supported_styles[i] & XIMStatusNone) - printf("XIMStatusNone | "); + printf("XIMStatusNone | "); printf("\n"); } } @@ -969,12 +1150,12 @@ get_ic(Ecore_IMF_Context *ctx) { if (im_info->supports_cursor) { - // kinput2 DOES do this... + // kinput2 DOES do this... XFontSet fs; char **missing_charset_list; int missing_charset_count; char *def_string; - + im_style |= XIMPreeditPosition; im_style |= XIMStatusNothing; fs = XCreateFontSet(ecore_x_display_get(), @@ -995,7 +1176,7 @@ get_ic(Ecore_IMF_Context *ctx) } name = XNPreeditAttributes; } - else + else { im_style |= XIMPreeditNothing; im_style |= XIMStatusNothing; @@ -1009,18 +1190,18 @@ get_ic(Ecore_IMF_Context *ctx) name, preedit_attr, NULL); } XFree(preedit_attr); - if(ic) + if (ic) { unsigned long mask = 0xaaaaaaaa; - XGetICValues (ic, - XNFilterEvents, &mask, - NULL); + XGetICValues(ic, + XNFilterEvents, &mask, + NULL); imf_context_data->mask = mask; ecore_x_event_mask_set(imf_context_data->win, mask); } imf_context_data->ic = ic; - if(ic && imf_context_data->has_focus == EINA_TRUE) + if (ic && imf_context_data->has_focus == EINA_TRUE) XSetICFocus(ic); } @@ -1032,16 +1213,17 @@ reinitialize_ic(Ecore_IMF_Context *ctx) { Ecore_IMF_Context_Data *imf_context_data = ecore_imf_context_data_get(ctx); XIC ic = imf_context_data->ic; - if(ic) + if (ic) { XDestroyIC(ic); imf_context_data->ic = NULL; - if(imf_context_data->preedit_length) + if (imf_context_data->preedit_length) { imf_context_data->preedit_length = 0; free(imf_context_data->preedit_chars); imf_context_data->preedit_chars = NULL; ecore_imf_context_preedit_changed_event_add(ctx); + ecore_imf_context_event_callback_call(ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); } } } @@ -1052,13 +1234,13 @@ reinitialize_all_ics(XIM_Im_Info *info) Eina_List *tmp_list; Ecore_IMF_Context *ctx; - EINA_LIST_FOREACH(info->ics, tmp_list, ctx) + EINA_LIST_FOREACH (info->ics, tmp_list, ctx) reinitialize_ic(ctx); } static void set_ic_client_window(Ecore_IMF_Context *ctx, - Ecore_X_Window window) + Ecore_X_Window window) { EINA_LOG_DBG("in"); Ecore_IMF_Context_Data *imf_context_data = ecore_imf_context_data_get(ctx); @@ -1069,7 +1251,7 @@ set_ic_client_window(Ecore_IMF_Context *ctx, old_win = imf_context_data->win; EINA_LOG_DBG("old_win:%d window:%d ", old_win, window); - if(old_win != 0 && old_win != window) /* XXX how do check window... */ + if (old_win != 0 && old_win != window) /* XXX how do check window... */ { XIM_Im_Info *info; info = imf_context_data->im_info; @@ -1079,7 +1261,7 @@ set_ic_client_window(Ecore_IMF_Context *ctx, imf_context_data->win = window; - if(window) /* XXX */ + if (window) /* XXX */ { XIM_Im_Info *info = NULL; info = get_im(window, imf_context_data->locale); @@ -1092,17 +1274,17 @@ set_ic_client_window(Ecore_IMF_Context *ctx, static XIM_Im_Info * get_im(Ecore_X_Window window, - char *locale) + char *locale) { EINA_LOG_DBG("in"); Eina_List *l; XIM_Im_Info *im_info = NULL; XIM_Im_Info *info = NULL; - EINA_LIST_FOREACH(open_ims, l, im_info) { - if(strcmp(im_info->locale, locale) == 0) + EINA_LIST_FOREACH (open_ims, l, im_info) { + if (strcmp(im_info->locale, locale) == 0) { - if(im_info->im) + if (im_info->im) { return im_info; } @@ -1113,10 +1295,10 @@ get_im(Ecore_X_Window window, } } - if(!info) + if (!info) { info = calloc(1, sizeof(XIM_Im_Info)); - if(!info) return NULL; + if (!info) return NULL; open_ims = eina_list_prepend(open_ims, info); info->win = window; info->locale = strdup(locale); @@ -1137,13 +1319,13 @@ xim_info_try_im(XIM_Im_Info *info) if (info->reconnecting == EINA_TRUE) return; - if(XSupportsLocale()) + if (XSupportsLocale()) { - if (!XSetLocaleModifiers ("")) + if (!XSetLocaleModifiers("")) EINA_LOG_WARN("Unable to set locale modifiers with XSetLocaleModifiers()"); dsp = ecore_x_display_get(); info->im = XOpenIM(dsp, NULL, NULL, NULL); - if(!info->im) + if (!info->im) { XRegisterIMInstantiateCallback(dsp, NULL, NULL, NULL, @@ -1158,8 +1340,8 @@ xim_info_try_im(XIM_Im_Info *info) static void xim_info_display_closed(Ecore_X_Display *display __UNUSED__, - int is_error __UNUSED__, - XIM_Im_Info *info) + int is_error __UNUSED__, + XIM_Im_Info *info) { Eina_List *ics, *tmp_list; Ecore_IMF_Context *ctx; @@ -1169,21 +1351,21 @@ xim_info_display_closed(Ecore_X_Display *display __UNUSED__, ics = info->ics; info->ics = NULL; - EINA_LIST_FOREACH(ics, tmp_list, ctx) + EINA_LIST_FOREACH (ics, tmp_list, ctx) set_ic_client_window(ctx, 0); - EINA_LIST_FREE(ics, ctx) { + EINA_LIST_FREE (ics, ctx) { Ecore_IMF_Context_Data *imf_context_data; imf_context_data = ecore_imf_context_data_get(ctx); imf_context_data_destroy(imf_context_data); } - free (info->locale); + free(info->locale); if (info->im) - XCloseIM (info->im); + XCloseIM(info->im); - free (info); + free(info); } static void @@ -1203,11 +1385,11 @@ xim_instantiate_callback(Display *display, } info->im = im; - setup_im (info); + setup_im(info); - XUnregisterIMInstantiateCallback (display, NULL, NULL, NULL, - xim_instantiate_callback, - (XPointer)info); + XUnregisterIMInstantiateCallback(display, NULL, NULL, NULL, + xim_instantiate_callback, + (XPointer)info); info->reconnecting = EINA_FALSE; } @@ -1217,7 +1399,7 @@ setup_im(XIM_Im_Info *info) XIMValuesList *ic_values = NULL; XIMCallback im_destroy_callback; - if(!info->im) + if (!info->im) return; im_destroy_callback.client_data = (XPointer)info; @@ -1239,25 +1421,25 @@ setup_im(XIM_Im_Info *info) { if (!strcmp(ic_values->supported_values[i], XNStringConversionCallback)) - info->supports_string_conversion = EINA_TRUE; + info->supports_string_conversion = EINA_TRUE; if (!strcmp(ic_values->supported_values[i], XNCursor)) - info->supports_cursor = EINA_TRUE; + info->supports_cursor = EINA_TRUE; } #if 0 printf("values........\n"); for (i = 0; i < ic_values->count_values; i++) - printf("%s\n", ic_values->supported_values[i]); + printf("%s\n", ic_values->supported_values[i]); printf("styles........\n"); for (i = 0; i < info->xim_styles->count_styles; i++) - printf("%lx\n", info->xim_styles->supported_styles[i]); + printf("%lx\n", info->xim_styles->supported_styles[i]); #endif XFree(ic_values); } } static void -xim_destroy_callback(XIM xim __UNUSED__, +xim_destroy_callback(XIM xim __UNUSED__, XPointer client_data, XPointer call_data __UNUSED__) { -- cgit v1.1