From ddf186365411bba8c25526facafa069869584fa9 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 10 Feb 2012 13:12:19 +0900 Subject: [PATCH 1/1] upload isf tizen beta package Change-Id: I2d91d27e192453edbeecec4c7e75d60d35859a8d --- configure.ac | 7 +- debian/changelog | 8 + debian/control | 2 +- ism/demos/isf_demo_efl.cpp | 22 -- ism/demos/isf_imcontrol_efl.cpp | 12 - ism/demos/isf_layout_efl.cpp | 2 - ism/extras/efl_immodule/isf_imf_context.cpp | 332 +++++++++++++++++++------ ism/extras/efl_immodule/isf_imf_control_ui.cpp | 38 +-- ism/extras/efl_panel/Makefile.am | 5 +- ism/extras/efl_panel/isf_panel_efl.cpp | 4 +- ism/extras/gtk_panel/isf_setup_win.cpp | 2 +- ism/src/Makefile.am | 14 +- ism/src/ise_context.h | 2 +- ism/src/isf_query_engines.cpp | 10 +- ism/src/isf_query_utility.h | 2 +- ism/src/scim_config_path.h | 5 +- ism/src/scim_helper.cpp | 87 +++++++ ism/src/scim_helper.h | 42 +++- ism/src/scim_helper_launcher.cpp | 3 + ism/src/scim_hotkey.cpp | 66 +---- ism/src/scim_hotkey.h | 1 - ism/src/scim_launcher.cpp | 9 + ism/src/scim_panel_agent.cpp | 144 ++++++++++- ism/src/scim_panel_client.cpp | 58 +++++ ism/src/scim_panel_client.h | 36 +++ ism/src/scim_trans_commands.h | 1 + releasenote.txt | 7 +- 27 files changed, 697 insertions(+), 224 deletions(-) diff --git a/configure.ac b/configure.ac index 0cbef2d..51c21e2 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ # Process this file with autoconf to produce a configure script #AC_INIT(scim, 1.4.7, suzhe@tsinghua.org.cn) -AC_INIT(isf, 2.3.4821, isf@samsung.com) +AC_INIT(isf, 2.3.5009, isf@samsung.com) AC_CONFIG_SRCDIR([ism/src/scim.h]) m4_pattern_allow([^AS_]) @@ -11,7 +11,7 @@ m4_pattern_allow([^AS_]) # ISF version ISF_MAJOR_VERSION=2 ISF_MINOR_VERSION=3 -ISF_MICRO_VERSION=4821 +ISF_MICRO_VERSION=5009 ISF_VERSION=$ISF_MAJOR_VERSION.$ISF_MINOR_VERSION.$ISF_MICRO_VERSION @@ -248,6 +248,9 @@ PKG_CHECK_MODULES(HEYNOTI, [heynoti]) # Check dlog library PKG_CHECK_MODULES(DLOG, [dlog >= 0]) +# Check privilege control library +PKG_CHECK_MODULES(PRIVILEGE_CONTROL, [libprivilege-control >= 0]) + # Check if we should build isf-setting-efl PKG_CHECK_MODULES(VCONF, [vconf], [ISF_HAS_VCONF=yes], diff --git a/debian/changelog b/debian/changelog index 26d834b..7d8c11f 100755 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +isf (2.3.5009-1slp2+1) unstable; urgency=low + + * upload tizen beta code + * Git: slp/pkgs/i/isf + * Tag: isf_2.3.5009-1slp2+1 + + -- Jihoon Kim Thu, 09 Feb 2012 17:48:05 +0900 + isf (2.3.4821-1slp2+1) unstable; urgency=low * code cleanup diff --git a/debian/control b/debian/control index 53b6926..1595376 100755 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Maintainer: Sehwan Park , Haifeng Deng Build-Depends: debhelper (>= 5), autotools-dev, pkg-config, libelm-dev, libglib2.0-dev, libappcore-efl-dev, libslp-utilx-dev, libslp-setting-dev, libui-gadget-dev, libheynoti-dev, - libecore-dev, libevas-dev, libx11-dev, dlog-dev + libecore-dev, libevas-dev, libx11-dev, dlog-dev, libprivilege-control-dev Standards-Version: 3.7.2 Homepage: http://www.scim-im.org diff --git a/ism/demos/isf_demo_efl.cpp b/ism/demos/isf_demo_efl.cpp index a2716f9..e60f2cd 100644 --- a/ism/demos/isf_demo_efl.cpp +++ b/ism/demos/isf_demo_efl.cpp @@ -85,8 +85,6 @@ static void layout_cb (struct ui_gadget *ug, enum ug_mode mode, void *priv) static void result_cb (struct ui_gadget *ug, bundle *result, void *priv) { - struct appdata *ad = (appdata*) priv; - if (!result) return; const char *name = bundle_get_val(result, "name"); @@ -106,20 +104,6 @@ static void destroy_cb (struct ui_gadget *ug, void *priv) ug_destroy (ug); } -static void cam_destroy_cb (struct ui_gadget *ug, void *priv) -{ - printf ("enter cam_destroy_cb ().........\n"); - if (!ug) - return; - - ug_destroy (ug); - struct appdata *ad = (struct appdata *) priv; - if (ad->layout_main != NULL) - evas_object_show(ad->layout_main); - if (ad->bg != NULL) - evas_object_show(ad->bg); -} - static void isfsetting_bt (void *data, Evas_Object *obj, void *event_info) { struct appdata *ad = (struct appdata *)data; @@ -160,12 +144,6 @@ static void keyboard_setting_wizard_bt (void *data, Evas_Object *obj, void *even ad->data = NULL; } -static void response_cb (void *data, Evas_Object *obj, void *event_info) -{ - if ((int)event_info != 5) - evas_object_del (obj); -} - static int create_demo_view (struct appdata *ad) { Evas_Object *li = NULL; diff --git a/ism/demos/isf_imcontrol_efl.cpp b/ism/demos/isf_imcontrol_efl.cpp index 0951d98..bc0cd00 100644 --- a/ism/demos/isf_imcontrol_efl.cpp +++ b/ism/demos/isf_imcontrol_efl.cpp @@ -38,7 +38,6 @@ enum { INPUT_PANEL_PRIVATE_KEY_SET, INPUT_PANEL_KEY_DISABLED_SET, INPUT_PANEL_STATE_GET, - INPUT_PANEL_MOVE, CONTROL_PANEL_SHOW, CONTROL_PANEL_HIDE, }; @@ -54,7 +53,6 @@ const char *api_list[]={ "PANEL PRIVATE KEY SET", "PANEL KEY DISABLED SET", "INPUT PANEL STATE GET", - "INPUT PANEL MOVE", "CTRL PANEL SHOW", "CTRL PANEL HIDE", }; @@ -164,13 +162,6 @@ void test_control_panel_hide (void *data, Evas_Object *obj, void *event_info) } } -void test_input_panel_move (void *data, Evas_Object *obj, void *event_info) -{ - if (imf_context != NULL) { - ecore_imf_context_input_panel_move (imf_context, 100, 100); - } -} - char *gli_label_get (void *data, Evas_Object *obj, const char *part) { int j = (int)data; @@ -211,9 +202,6 @@ static void test_api (void *data, Evas_Object *obj, void *event_info) case INPUT_PANEL_STATE_GET: test_input_panel_state_get (NULL, obj, event_info); break; - case INPUT_PANEL_MOVE: - test_input_panel_move (NULL, obj, event_info); - break; case CONTROL_PANEL_SHOW: test_control_panel_show (NULL, obj, event_info); break; diff --git a/ism/demos/isf_layout_efl.cpp b/ism/demos/isf_layout_efl.cpp index bf184e0..40203c2 100644 --- a/ism/demos/isf_layout_efl.cpp +++ b/ism/demos/isf_layout_efl.cpp @@ -127,8 +127,6 @@ static Evas_Object * create_inner_layout (void *data) struct appdata *ad = (struct appdata *)data; Evas_Object *bx = NULL ; Evas_Object *ef = NULL ; - Evas_Object *en = NULL ; - Evas_Object *parent = ad->naviframe; bx = elm_box_add (parent); diff --git a/ism/extras/efl_immodule/isf_imf_context.cpp b/ism/extras/efl_immodule/isf_imf_context.cpp index 89db031..6fe658d 100644 --- a/ism/extras/efl_immodule/isf_imf_context.cpp +++ b/ism/extras/efl_immodule/isf_imf_context.cpp @@ -33,11 +33,11 @@ #include #include #include +#include -#include +#include #include #include -#include #include #include #include @@ -52,6 +52,10 @@ #include "isf_imf_context.h" #include "isf_imf_control_ui.h" +#ifndef CODESET +# define CODESET "INVALID" +#endif + const double DOUBLE_SPACE_INTERVAL=1.0; const int PREDICTION_ALLOW_SET = 0xa0; @@ -127,6 +131,12 @@ static void panel_slot_hide_preedit_string (int static void panel_slot_update_preedit_string (int context, const WideString &str, const AttributeList &attrs); +static void panel_slot_get_surrounding_text (int context, + int maxlen_before, + int maxlen_after); +static void panel_slot_delete_surrounding_text (int context, + int offset, + int len); static void panel_req_focus_in (EcoreIMFContextISF *ic); static void panel_req_update_factory_info (EcoreIMFContextISF *ic); @@ -157,10 +167,8 @@ static void open_specific_factory (EcoreIMFContextISF 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, const Window &win, - const Window &winRoot, bool press, - int keycode, int modifiers); -static void _x_send_key_event (const KeyEvent &key); +static XKeyEvent createKeyEvent (bool press, int keycode, int modifiers, bool fake); +static void send_x_key_event (const KeyEvent &key, bool fake); static void attach_instance (const IMEngineInstancePointer &si); @@ -484,7 +492,7 @@ analyze_surrounding_text(Ecore_IMF_Context *ctx) break; } - for (i=0; i < punc_num; i++) { + for (i = 0; i < punc_num; i++) { uni_puncs[i] = eina_unicode_utf8_to_unicode(puncs[i], NULL); } @@ -497,7 +505,7 @@ analyze_surrounding_text(Ecore_IMF_Context *ctx) } // Convert into plain string - plain_str = elm_entry_markup_to_utf8(markup_str); + plain_str = evas_textblock_text_markup_to_utf8(NULL, markup_str); if (!plain_str) goto done; // Convert string from utf8 to unicode @@ -524,7 +532,7 @@ analyze_surrounding_text(Ecore_IMF_Context *ctx) tail = eina_unicode_strndup(ustr+cursor_pos-2, 2); if (tail) { - for (i=0; i < punc_num; i++) { + for (i = 0; i < punc_num; i++) { if (!eina_unicode_strcmp(tail, uni_puncs[i])) { ret = EINA_TRUE; break; @@ -540,7 +548,7 @@ done: if (markup_str) free(markup_str); if (plain_str) free(plain_str); - for (i=0; i < punc_num; i++) { + for (i = 0; i < punc_num; i++) { if (uni_puncs[i]) free(uni_puncs[i]); } @@ -620,11 +628,6 @@ isf_imf_context_new (void) SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; int val; - 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) { @@ -1104,9 +1107,6 @@ isf_imf_context_cursor_position_set (Ecore_IMF_Context *ctx, int cursor_pos) if (context_scim->impl->preedit_updating) return; - if (!context_scim->impl->client_canvas) - return; - if (context_scim->impl->cursor_pos != cursor_pos) { context_scim->impl->cursor_pos = cursor_pos; @@ -1148,13 +1148,15 @@ isf_imf_context_cursor_location_set (Ecore_IMF_Context *ctx, int cx, int cy, int 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; + if (context_scim->impl->client_canvas) { + ee = ecore_evas_ecore_evas_get(context_scim->impl->client_canvas); - ecore_evas_geometry_get (ee, &canvas_x, &canvas_y, NULL, NULL); + if (ee) + ecore_evas_geometry_get (ee, &canvas_x, &canvas_y, NULL, NULL); + } + else if (context_scim->impl->client_window) { + ecore_x_window_geometry_get(context_scim->impl->client_window, &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; @@ -1463,7 +1465,6 @@ isf_imf_context_autocapital_type_set (Ecore_IMF_Context* ctx, Ecore_IMF_Autocapi * 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) { @@ -1482,6 +1483,8 @@ isf_imf_context_filter_event (Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, Ecore_IMF_Event_Key_Down *ev = (Ecore_IMF_Event_Key_Down *)event; timestamp = ev->timestamp; scim_string_to_key (key, ev->key); + if (isupper(key.code)) + key.mask |=SCIM_KEY_ShiftMask; 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; @@ -1492,6 +1495,8 @@ isf_imf_context_filter_event (Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, timestamp = ev->timestamp; scim_string_to_key (key, ev->key); key.mask = SCIM_KEY_ReleaseMask; + if (isupper(key.code)) + key.mask |=SCIM_KEY_ShiftMask; 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; @@ -1670,44 +1675,124 @@ panel_slot_select_candidate (int context, int cand_index) } } -static const char * -get_sw_keyname (const char *key_string) +static int +_keyname_to_keycode(const char *keyname) { - const static char *SW_KEY_NAMES[][2] = { - {"0x1008ff84", "XF86XK_UserPB"}, - {"0x1008ff85", "XF86XK_User1KB"}, - {"0x1008ff86", "XF86XK_User2KB"}, - }; - const char* key_name = key_string; - int loop; - if (key_string) { - for (loop = 0; ((unsigned int)loop) < (sizeof (SW_KEY_NAMES) / sizeof (SW_KEY_NAMES[0])); loop++) { - if (!strcmp (key_string, SW_KEY_NAMES[loop][0])) { - key_name = SW_KEY_NAMES[loop][1]; - break; - } - } + int keycode = 0; + int keysym; + Display *display = (Display *)ecore_x_display_get(); + + keysym = XStringToKeysym(keyname); + + if (!strncmp(keyname, "Keycode-", 8)) + keycode = atoi(keyname + 8); + else { + keycode = XKeysymToKeycode(display, keysym); } - return key_name; + + return keycode; } static void -feed_key_event (Evas *evas, const char *str, Eina_Bool fake) -{ - char key_string[128] = {0}; +send_evas_key_event (Evas *evas, const KeyEvent &scim_key, bool fake) +{ + char *keyname; + char *key; + char key_string[256] = {0}; + char *keysym_str; + char compose_buffer[256] = {0}; + const char *str = scim_key.get_key_string().c_str(); + char *compose = NULL; unsigned int timestamp = 0; + int shift = 0; + int val; + KeySym keysym; + ::KeyCode keycode; + XKeyEvent xkey; + + Display *display = (Display *)ecore_x_display_get (); + + if (!evas) return; 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, get_sw_keyname(key_string), NULL, NULL, timestamp, NULL); - SCIM_DEBUG_FRONTEND(1) << " evas_event_feed_key_up ()...\n"; - } else { + if (scim_key.is_key_press ()) { strncpy(key_string, str, strlen(str)); - evas_event_feed_key_down (evas, key_string, get_sw_keyname(key_string), NULL, NULL, timestamp, NULL); + } else { + if (strncmp (str, "KeyRelease+", 11) == 0) { + strncpy(key_string, str + 11, strlen(str)-11); + } + } + + if (strncmp (key_string, "Shift+", 6) == 0) { + keysym_str = key_string + 6; + } + else { + keysym_str = key_string; + } + + // get x keysym, keycode, keyname, and key + keysym = XStringToKeysym(keysym_str); + if (keysym == NoSymbol) + return; + + keycode = _keyname_to_keycode(keysym_str); + keyname = XKeysymToString(XKeycodeToKeysym(display, keycode, 0)); + key = keysym_str; + + // check modifier + if (XKeycodeToKeysym(display, keycode, 0) != keysym) { + if (XKeycodeToKeysym(display, keycode, 1) == keysym) + shift = 1; + else + keycode = 0; + } + else + shift = 0; + + unsigned int modifier = scim_x11_keymask_scim_to_x11 (display, scim_key.mask); + + if (shift) + modifier |= ShiftMask; + + // get keystring + xkey = createKeyEvent(scim_key.is_key_press(), keycode, modifier, False); + val = XLookupString (&xkey, compose_buffer, sizeof(compose_buffer), NULL, 0); + + if (val > 0) { + compose_buffer[val] = 0; + compose = eina_str_convert(nl_langinfo(CODESET), "UTF-8", + compose_buffer); + } + + if (!keyname) + keyname = key; + + // feed key event + if (scim_key.is_key_press()) { + evas_event_feed_key_down (evas, keyname, key, compose, compose, timestamp, NULL); SCIM_DEBUG_FRONTEND(1) << " evas_event_feed_key_down ()...\n"; + } else { + evas_event_feed_key_up (evas, keyname, key, compose, compose, timestamp, NULL); + SCIM_DEBUG_FRONTEND(1) << " evas_event_feed_key_up ()...\n"; + } + + if (compose) + free(compose); +} + +static void +feed_key_event (EcoreIMFContextISF *ic, const KeyEvent &key, bool fake) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + if (!ic || !ic->impl) return; + + if (ic->impl->client_canvas) { + send_evas_key_event(ic->impl->client_canvas, key, fake); + } else { + send_x_key_event(key, fake); } } @@ -1717,9 +1802,7 @@ 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); - } + feed_key_event (ic, key, false); } static void @@ -1745,8 +1828,7 @@ panel_slot_forward_key_event (int context, const KeyEvent &key) if (strlen (key.get_key_string ().c_str ()) >= 116) return; - if (ic && ic->impl && ic->impl->client_canvas) - feed_key_event (ic->impl->client_canvas, key.get_key_string ().c_str (), EINA_TRUE); + feed_key_event (ic, key, true); } static void @@ -1899,6 +1981,35 @@ panel_slot_update_preedit_string (int context, } } +static void +panel_slot_get_surrounding_text (int context, int maxlen_before, int maxlen_after) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = find_ic (context); + + if (ic && ic->impl && _focused_ic == ic && ic->impl->si) { + int cursor = 0; + WideString text = WideString (); + slot_get_surrounding_text (ic->impl->si, text, cursor, maxlen_before, maxlen_after); + _panel_client.prepare (ic->id); + _panel_client.update_surrounding_text (ic->id, text, cursor); + _panel_client.send (); + } +} + +static void +panel_slot_delete_surrounding_text (int context, int offset, int len) +{ + SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; + + EcoreIMFContextISF *ic = find_ic (context); + + if (ic && ic->impl && _focused_ic == ic && ic->impl->si) { + slot_delete_surrounding_text (ic->impl->si, offset, len); + } +} + /* Panel Requestion functions. */ static void panel_req_show_help (EcoreIMFContextISF *ic) @@ -2335,6 +2446,8 @@ initialize (void) _panel_client.signal_connect_show_preedit_string (slot (panel_slot_show_preedit_string)); _panel_client.signal_connect_hide_preedit_string (slot (panel_slot_hide_preedit_string)); _panel_client.signal_connect_update_preedit_string (slot (panel_slot_update_preedit_string)); + _panel_client.signal_connect_get_surrounding_text (slot (panel_slot_get_surrounding_text)); + _panel_client.signal_connect_delete_surrounding_text (slot (panel_slot_delete_surrounding_text)); if (!panel_initialize ()) { std::cerr << "Ecore IM Module: Cannot connect to Panel!\n"; @@ -2612,51 +2725,99 @@ static unsigned int scim_x11_keymask_scim_to_x11 (Display *display, uint16 scimk return state; } -static XKeyEvent createKeyEvent (Display *display, const Window &win, - const Window &winRoot, bool press, - int keycode, int modifiers) +static XKeyEvent createKeyEvent (bool press, int keycode, int modifiers, bool fake) { SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; XKeyEvent event; + Window focus_win; + Display *display = (Display *)ecore_x_display_get (); + int revert = RevertToParent; + + XGetInputFocus (display, &focus_win, &revert); event.display = display; - event.window = win; - event.root = winRoot; + event.window = focus_win; + event.root = DefaultRootWindow (display); event.subwindow = None; - event.time = CurrentTime; + if (fake) + event.time = 0; + else + event.time = get_time(); + event.x = 1; event.y = 1; event.x_root = 1; event.y_root = 1; - event.same_screen = EINA_TRUE; + event.same_screen = True; event.state = modifiers; - event.keycode = XKeysymToKeycode (display, keycode); + event.keycode = keycode; if (press) event.type = KeyPress; else event.type = KeyRelease; - event.send_event = EINA_FALSE; + event.send_event = False; event.serial = 0; return event; } -static void _x_send_key_event (const KeyEvent &key) +static void send_x_key_event (const KeyEvent &key, bool fake) { SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n"; - //std::cout << "[slot_send_key_event] code : " << key.code << " mask : " << key.mask << "\n"; + ::KeyCode keycode = 0; + ::KeySym keysym = 0; + int shift = 0; + const char *key_string; // Obtain the X11 display. - Display *display = XOpenDisplay (NULL); + Display *display = (Display *)ecore_x_display_get (); if (display == NULL) { - std::cerr << "XOpenDisplay failed\n"; + std::cerr << "ecore_x_display_get () failed\n"; return; } - // Get the root window for the current display. - Window winRoot = 0;// = XRootWindow (display, 1); + if (strncmp (key.get_key_string().c_str(), "KeyRelease+", 11) == 0) { + key_string = key.get_key_string().c_str() + 11; + } else { + key_string = key.get_key_string().c_str(); + } + + keysym = XStringToKeysym(key_string); + if (keysym == NoSymbol) + return; + + keycode = _keyname_to_keycode(key_string); + if (XKeycodeToKeysym(display, keycode, 0) != keysym) { + if (XKeycodeToKeysym(display, keycode, 1) == keysym) + shift = 1; + else + keycode = 0; + } + else + shift = 0; + + if (keycode == 0) { + static int mod = 0; + KeySym *keysyms; + int keycode_min, keycode_max, keycode_num; + int i; + + XDisplayKeycodes(display, &keycode_min, &keycode_max); + keysyms = XGetKeyboardMapping(display, keycode_min, + keycode_max - keycode_min + 1, + &keycode_num); + mod = (mod + 1) & 0x7; + i = (keycode_max - keycode_min - mod - 1) * keycode_num; + + keysyms[i] = keysym; + XChangeKeyboardMapping(display, keycode_min, keycode_num, + keysyms, (keycode_max - keycode_min)); + XFree(keysyms); + XSync(display, False); + keycode = keycode_max - mod - 1; + } // Find the window which has the current keyboard focus. Window winFocus = 0; @@ -2669,16 +2830,28 @@ static void _x_send_key_event (const KeyEvent &key) XMapWindow (display, winFocus); unsigned int modifier = scim_x11_keymask_scim_to_x11 (display, key.mask); + + if (shift) + modifier |= ShiftMask; + XKeyEvent event; if (key.is_key_press ()) { - event = createKeyEvent (display, winFocus, winRoot, true, key.code, modifier); + if (shift) { + event = createKeyEvent (true, XKeysymToKeycode(display, XK_Shift_L), modifier, fake); + XSendEvent (event.display, event.window, True, KeyPressMask, (XEvent *)&event); + } + + event = createKeyEvent (true, keycode, modifier, fake); XSendEvent (event.display, event.window, True, KeyPressMask, (XEvent *)&event); } else { - event = createKeyEvent (display, winFocus, winRoot, false, key.code, modifier); + event = createKeyEvent (false, keycode, modifier, fake); XSendEvent (event.display, event.window, True, KeyReleaseMask, (XEvent *)&event); - } - XCloseDisplay (display); + if (shift) { + event = createKeyEvent (false, XKeysymToKeycode(display, XK_Shift_L), modifier, fake); + XSendEvent (event.display, event.window, True, KeyReleaseMask, (XEvent *)&event); + } + } } static void @@ -2750,7 +2923,6 @@ slot_show_preedit_string (IMEngineInstanceBase *si) if (ic->impl->use_preedit) { if (!ic->impl->preedit_started) { ecore_imf_context_preedit_start_event_add (_focused_ic->ctx); - //ecore_x_window_background_color_set ((Ecore_X_Window)(_focused_ic->impl->client_window), 0, 128, 128); ic->impl->preedit_started = true; } //if (ic->impl->preedit_string.length ()) @@ -2917,7 +3089,7 @@ slot_forward_key_event (IMEngineInstanceBase *si, if (ic && _focused_ic == ic) { if (!_fallback_instance->process_key_event (key)) { - _x_send_key_event(key); + feed_key_event (ic, key, true); } } } @@ -3027,8 +3199,10 @@ slot_get_surrounding_text (IMEngineInstanceBase *si, 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))); + WideString before = utf8_mbstowcs (String (surrounding)); + before = before.substr (0, cursor_index); + WideString after = utf8_mbstowcs (String (surrounding)); + after = after.substr (cursor_index, after.length () - 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 (); diff --git a/ism/extras/efl_immodule/isf_imf_control_ui.cpp b/ism/extras/efl_immodule/isf_imf_control_ui.cpp index cc6fe1c..bfdbf86 100644 --- a/ism/extras/efl_immodule/isf_imf_control_ui.cpp +++ b/ism/extras/efl_immodule/isf_imf_control_ui.cpp @@ -64,7 +64,6 @@ static Ecore_Timer *hide_timer = NULL; Ecore_IMF_Context *input_panel_ctx = NULL; - static Eina_Bool _prop_change (void *data, int ev_type, void *ev) { Ecore_X_Event_Window_Property *event = (Ecore_X_Event_Window_Property *)ev; @@ -86,15 +85,20 @@ static Eina_Bool _prop_change (void *data, int ev_type, void *ev) return ECORE_CALLBACK_PASS_ON; } -static void _save_current_xid (Evas *evas) +static void _save_current_xid (Ecore_IMF_Context *ctx) { Ecore_X_Window xid = 0, rootwin_xid = 0; Ecore_Evas *ee = NULL; + Evas *evas = NULL; + + evas = (Evas *)ecore_imf_context_client_canvas_get(ctx); if (evas) { ee = ecore_evas_ecore_evas_get (evas); if (ee) xid = (Ecore_X_Window)ecore_evas_window_get (ee); + } else { + xid = (Ecore_X_Window)ecore_imf_context_client_window_get (ctx); } if (xid == 0) @@ -108,25 +112,6 @@ static void _save_current_xid (Evas *evas) ecore_x_sync (); } -static Ecore_IMF_Input_Panel_Orient _orient_get (Evas *evas) -{ - Ecore_Evas *ee = NULL; - int degree; - Ecore_IMF_Input_Panel_Orient orient; - - if (!evas) - return ECORE_IMF_INPUT_PANEL_ORIENT_NONE; - ee = ecore_evas_ecore_evas_get (evas); - if (!ee) - return ECORE_IMF_INPUT_PANEL_ORIENT_NONE; - - degree = ecore_evas_rotation_get (ee); - - orient = (Ecore_IMF_Input_Panel_Orient)(degree % 360 / 90); - - return orient; -} - static void _event_callback_call (Ecore_IMF_Input_Panel_Event type, int value) { void *list_data = NULL; @@ -161,7 +146,7 @@ static void _isf_imf_context_init (void) iseContext.IfFullStyle = FALSE; iseContext.state = ECORE_IMF_INPUT_PANEL_STATE_HIDE; iseContext.language = ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC; - iseContext.orient = ECORE_IMF_INPUT_PANEL_ORIENT_NONE; + iseContext.orient = 0; iseContext.fUseImEffect = TRUE; if (!IfInitContext) { @@ -280,7 +265,6 @@ EAPI void isf_imf_context_input_panel_show (Ecore_IMF_Context* ctx) void *list_data = NULL; void *offset = NULL; void *packet = NULL; - Evas *evas = NULL; input_panel_ctx = ctx; @@ -324,12 +308,6 @@ EAPI void isf_imf_context_input_panel_show (Ecore_IMF_Context* ctx) iseContext.private_key_num = eina_list_count (private_key_list); IMFCONTROLUIDBG("private key_num : %d\n", iseContext.private_key_num); - evas = (Evas *)ecore_imf_context_client_canvas_get (ctx); - - if (evas) { - iseContext.orient = _orient_get (evas); - } - /* calculate packet size */ length = sizeof (iseContext); length += iseContext.disabled_key_num * sizeof (Disable_Key_Item); @@ -363,7 +341,7 @@ EAPI void isf_imf_context_input_panel_show (Ecore_IMF_Context* ctx) } /* Set the current XID of the active window into the root window property */ - _save_current_xid (evas); + _save_current_xid (ctx); iseContext.state = ECORE_IMF_INPUT_PANEL_STATE_SHOW; diff --git a/ism/extras/efl_panel/Makefile.am b/ism/extras/efl_panel/Makefile.am index bed3dab..1e52241 100644 --- a/ism/extras/efl_panel/Makefile.am +++ b/ism/extras/efl_panel/Makefile.am @@ -28,12 +28,13 @@ bin_PROGRAMS = $(CONFIG_SCIM_PANEL_EFL) isf_panel_efl_SOURCES = isf_panel_efl.cpp \ isf_panel_utility.cpp -isf_panel_efl_CXXFLAGS = @EFL_CFLAGS@ @VCONF_CFLAGS@ @HEYNOTI_CFLAGS@ +isf_panel_efl_CXXFLAGS = @EFL_CFLAGS@ @VCONF_CFLAGS@ @HEYNOTI_CFLAGS@ @PRIVILEGE_CONTROL_CFLAGS@ isf_panel_efl_LDFLAGS = @EFL_LIBS@ @LTLIBINTL@ -rpath $(libdir) \ @VCONF_LIBS@ \ @HEYNOTI_LIBS@ \ - @X11_LIBS@ + @X11_LIBS@ \ + @PRIVILEGE_CONTROL_LIBS@ isf_panel_efl_LDADD = $(top_builddir)/ism/src/libscim@SCIM_EPOCH@.la diff --git a/ism/extras/efl_panel/isf_panel_efl.cpp b/ism/extras/efl_panel/isf_panel_efl.cpp index a1d2c96..2ad884f 100644 --- a/ism/extras/efl_panel/isf_panel_efl.cpp +++ b/ism/extras/efl_panel/isf_panel_efl.cpp @@ -54,6 +54,7 @@ #include #include #endif +#include #include "isf_panel_utility.h" @@ -69,7 +70,6 @@ using namespace scim; #define ISF_CONFIG_PANEL_LOOKUP_TABLE_VERTICAL "/Panel/Gtk/LookupTableVertical" #define ISF_CONFIG_PANEL_LOOKUP_TABLE_STYLE "/Panel/Gtk/LookupTableStyle" #define ISF_CONFIG_PANEL_LOOKUP_TABLE_MODE "/Panel/Gtk/LookupTableMode" -#define ISF_CONFIG_HARDWARE_KEYBOARD_DETECT "/isf/hw_keyboard_detect" #define ISF_CANDIDATE_TABLE 0 @@ -2844,6 +2844,8 @@ int main (int argc, char *argv []) Ecore_Event_Handler *xclient_msg_handler = NULL; Ecore_Event_Handler *prop_change_handler = NULL; + control_privilege (); + check_time ("\nStarting ISF Panel EFL...... "); DebugOutput::disable_debug (SCIM_DEBUG_AllMask); diff --git a/ism/extras/gtk_panel/isf_setup_win.cpp b/ism/extras/gtk_panel/isf_setup_win.cpp index 6e5d75e..5e86c32 100644 --- a/ism/extras/gtk_panel/isf_setup_win.cpp +++ b/ism/extras/gtk_panel/isf_setup_win.cpp @@ -481,7 +481,7 @@ void ISFSetupWin::create_ise_help_main (gint type, char *name, char *title) String (_("\n(C) 2008 SAMSUNG")) + String (_("\n\n Help file is needed!!")); } else { - /* FIXME -- 256 char per line for now -- mingbin.qu */ + /* FIXME -- 256 char per line for now -- */ char str[256]; while (helpfile.getline (str, sizeof (str))) { help_line = help_line + String (str) + String("\n"); diff --git a/ism/src/Makefile.am b/ism/src/Makefile.am index d71b1f3..ff9424f 100644 --- a/ism/src/Makefile.am +++ b/ism/src/Makefile.am @@ -167,20 +167,22 @@ isf_log_LDFLAGS = @LTLIBINTL@ -rpath $(libdir) -lglib-2.0 -lgobject-2.0 endif isf_query_engines_SOURCES = isf_query_engines.cpp -isf_query_engines_CXXFLAGS = @VCONF_CFLAGS@ +isf_query_engines_CXXFLAGS = @VCONF_CFLAGS@ @PRIVILEGE_CONTROL_CFLAGS@ isf_query_engines_LDADD = libscim@SCIM_EPOCH@.la -isf_query_engines_LDFLAGS = @LTLIBINTL@ @VCONF_LIBS@ +isf_query_engines_LDFLAGS = @LTLIBINTL@ @VCONF_LIBS@ @PRIVILEGE_CONTROL_LIBS@ libexecdir = $(libdir)/scim@SCIM_EPOCH@ libexec_PROGRAMS = scim-launcher scim-helper-launcher -scim_launcher_SOURCES = scim_launcher.cpp +scim_launcher_SOURCES = scim_launcher.cpp scim_launcher_LDADD = libscim@SCIM_EPOCH@.la -scim_launcher_LDFLAGS = @LTLIBINTL@ +scim_launcher_CXXFLAGS = @PRIVILEGE_CONTROL_CFLAGS@ +scim_launcher_LDFLAGS = @LTLIBINTL@ @PRIVILEGE_CONTROL_LIBS@ -scim_helper_launcher_SOURCES = scim_helper_launcher.cpp +scim_helper_launcher_SOURCES = scim_helper_launcher.cpp +scim_helper_launcher_CXXFLAGS = @PRIVILEGE_CONTROL_CFLAGS@ scim_helper_launcher_LDADD = libscim@SCIM_EPOCH@.la -scim_helper_launcher_LDFLAGS = @LTLIBINTL@ +scim_helper_launcher_LDFLAGS = @LTLIBINTL@ @PRIVILEGE_CONTROL_LIBS@ diff --git a/ism/src/ise_context.h b/ism/src/ise_context.h index c185a2d..f2ce1d9 100644 --- a/ism/src/ise_context.h +++ b/ism/src/ise_context.h @@ -35,7 +35,7 @@ typedef struct { int fUseImEffect; Ecore_IMF_Input_Panel_Lang language; Ecore_IMF_Input_Panel_Layout layout; - Ecore_IMF_Input_Panel_Orient orient; + int orient; unsigned int disabled_key_num; unsigned int private_key_num; int input_panel_x; diff --git a/ism/src/isf_query_engines.cpp b/ism/src/isf_query_engines.cpp index dc9914c..620481e 100644 --- a/ism/src/isf_query_engines.cpp +++ b/ism/src/isf_query_engines.cpp @@ -38,6 +38,7 @@ #include "scim_private.h" #include "scim.h" #include "isf_query_utility.h" +#include using namespace scim; @@ -58,6 +59,8 @@ int main (int argc, char *argv[]) int isetype = 0; int uninstall = 0; + control_privilege (); + int i = 1; while (i < argc) { if (String ("-t") == String (argv[i]) || String ("--type") == String (argv[i])) { @@ -91,10 +94,13 @@ int main (int argc, char *argv[]) if (access (engine_file_name.c_str (), F_OK | W_OK) != 0) { FILE *filp = fopen (engine_file_name.c_str (), "a"); - if (filp == NULL) + if (filp == NULL) { engine_file_name = user_file_name; - else + // Create folder for saving engine list + scim_make_dir (USER_ENGINE_LIST_PATH); + } else { fclose (filp); + } } if (uninstall == 1) { diff --git a/ism/src/isf_query_utility.h b/ism/src/isf_query_utility.h index 779ed1a..e05c39f 100644 --- a/ism/src/isf_query_utility.h +++ b/ism/src/isf_query_utility.h @@ -32,7 +32,7 @@ using namespace scim; // Declaration of macro. ///////////////////////////////////////////////////////////////////////////// #define MAXLINE 4096 -#define USER_ENGINE_LIST_PATH "/opt/home/root/.scim" +#define USER_ENGINE_LIST_PATH "/opt/home/app/.scim" #ifndef SCIM_SYSCONFDIR #define SCIM_SYSCONFDIR "/usr/etc" diff --git a/ism/src/scim_config_path.h b/ism/src/scim_config_path.h index 3294d69..42be142 100644 --- a/ism/src/scim_config_path.h +++ b/ism/src/scim_config_path.h @@ -60,8 +60,6 @@ namespace scim { #define SCIM_CONFIG_HOTKEYS_IMENGINE_LIST "/Hotkeys/IMEngine/List" #define SCIM_CONFIG_HOTKEYS_HELPER "/Hotkeys/Helper" #define SCIM_CONFIG_HOTKEYS_HELPER_LIST "/Hotkeys/Helper/List" -#define SCIM_CONFIG_HOTKEYS_NEWISE "/Hotkeys/NewISE" -#define SCIM_CONFIG_HOTKEYS_NEWISE_LIST "/Hotkeys/NewISE/List" #define SCIM_CONFIG_FILTER_FILTERED_IMENGINES "/Filter/FilteredIMEngines" #define SCIM_CONFIG_FILTER_FILTERED_IMENGINES_LIST "/Filter/FilteredIMEngines/List" @@ -104,6 +102,9 @@ namespace scim { #define SCIM_PREDICTION_ENGINE_CONFIG_QWERTY_NEXT_WORD_PREDIECTION "/QWERTY/next_word_prediction" #define SCIM_PREDICTION_ENGINE_CONFIG_QWERTY_AUTO_SUBSTITUTION "/QWERTY/auto_substitution" #define SCIM_PREDICTION_ENGINE_CONFIG_QWERTY_REGIONAL_INPUT "/QWERTY/regional_input" + +#define ISF_CONFIG_HARDWARE_KEYBOARD_DETECT "/isf/hw_keyboard_detect" + /** @} */ } // namespace scim diff --git a/ism/src/scim_helper.cpp b/ism/src/scim_helper.cpp index dbb3c97..bc4738a 100644 --- a/ism/src/scim_helper.cpp +++ b/ism/src/scim_helper.cpp @@ -111,6 +111,7 @@ public: HelperAgentSignalInt signal_update_screen; HelperAgentSignalIntInt signal_update_spot_location; HelperAgentSignalInt signal_update_cursor_position; + HelperAgentSignalInt signal_update_surrounding_text; HelperAgentSignalString signal_trigger_property; HelperAgentSignalTransaction signal_process_imengine_event; HelperAgentSignalVoid signal_focus_out; @@ -136,6 +137,7 @@ public: HelperAgentSignalStringVector signal_update_keyboard_ise_list; HelperAgentSignalVoid signal_candidate_more_window_show; HelperAgentSignalVoid signal_candidate_more_window_hide; + HelperAgentSignalInt signal_select_aux; HelperAgentSignalInt signal_select_candidate; HelperAgentSignalVoid signal_candidate_table_page_up; HelperAgentSignalVoid signal_candidate_table_page_down; @@ -421,6 +423,14 @@ HelperAgent::filter_event () m_impl->signal_update_cursor_position (this, ic, ic_uuid, (int) cursor_pos); break; } + case ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT: + { + String text; + uint32 cursor; + if (m_impl->recv.get_data (text) && m_impl->recv.get_data (cursor)) + m_impl->signal_update_surrounding_text (this, ic, text, (int) cursor); + break; + } case SCIM_TRANS_CMD_TRIGGER_PROPERTY: { String property; @@ -682,6 +692,13 @@ HelperAgent::filter_event () m_impl->signal_candidate_more_window_hide (this, ic, ic_uuid); break; } + case ISM_TRANS_CMD_SELECT_AUX: + { + uint32 item; + if (m_impl->recv.get_data (item)) + m_impl->signal_select_aux (this, ic, ic_uuid, item); + break; + } case SCIM_TRANS_CMD_SELECT_CANDIDATE: { uint32 item; @@ -1268,6 +1285,48 @@ HelperAgent::update_input_context (uint32 type, uint32 value) const } /** + * @ brief Request to get surrounding text. + * + * @param uuid The helper ISE UUID. + * @param maxlen_before The max length of before. + * @param maxlen_after The max length of after. + */ +void +HelperAgent::get_surrounding_text (const String &uuid, int maxlen_before, int maxlen_after) const +{ + if (m_impl->socket_active.is_connected ()) { + m_impl->send.clear (); + m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST); + m_impl->send.put_data (m_impl->magic_active); + m_impl->send.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT); + m_impl->send.put_data (uuid); + m_impl->send.put_data (maxlen_before); + m_impl->send.put_data (maxlen_after); + m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active); + } +} + +/** + * @ brief Request to delete surrounding text. + * + * @param offset The offset for cursor position. + * @param len The length for delete text. + */ +void +HelperAgent::delete_surrounding_text (int offset, int len) const +{ + if (m_impl->socket_active.is_connected ()) { + m_impl->send.clear (); + m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST); + m_impl->send.put_data (m_impl->magic_active); + m_impl->send.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT); + m_impl->send.put_data (offset); + m_impl->send.put_data (len); + m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active); + } +} + +/** * @brief Request to get uuid list of all keyboard ISEs. * * @param uuid The helper ISE UUID. @@ -1561,6 +1620,20 @@ HelperAgent::signal_connect_update_cursor_position (HelperAgentSlotInt *slot) } /** + * @brief Connect a slot to Helper update surrounding text signal. + * + * This signal is used to let the Helper get the surrounding text. + * + * The prototype of the slot is: + * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor); + */ +Connection +HelperAgent::signal_connect_update_surrounding_text (HelperAgentSlotInt *slot) +{ + return m_impl->signal_update_surrounding_text.connect (slot); +} + +/** * @brief Connect a slot to Helper trigger property signal. * * This signal is used to trigger a property registered by this Helper. @@ -1916,6 +1989,20 @@ HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slo } /** + * @brief Connect a slot to Helper select aux signal. + * + * This signal is used to do something when aux is selected. + * + * The prototype of the slot is: + * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index); + */ +Connection +HelperAgent::signal_connect_select_aux (HelperAgentSlotInt *slot) +{ + return m_impl->signal_select_aux.connect (slot); +} + +/** * @brief Connect a slot to Helper select candidate signal. * * This signal is used to do something when candidate is selected. diff --git a/ism/src/scim_helper.h b/ism/src/scim_helper.h index 0795f1e..f54ffc0 100644 --- a/ism/src/scim_helper.h +++ b/ism/src/scim_helper.h @@ -464,6 +464,26 @@ public: uint32 value) const; /** + * @ brief Request to get surrounding text. + * + * @param uuid The helper ISE UUID. + * @param maxlen_before The max length of before. + * @param maxlen_after The max length of after. + */ + void get_surrounding_text (const String &uuid, + int maxlen_before, + int maxlen_after) const; + + /** + * @ brief Request to delete surrounding text. + * + * @param offset The offset for cursor position. + * @param len The length for delete text. + */ + void delete_surrounding_text (int offset, + int len) const; + + /** * @ brief Set new candidate UI. * * @param style style of new candidate UI. @@ -616,7 +636,7 @@ public: * void update_spot_location (const HelperAgent *agent, int ic, const String &ic_uuid, int x, int y); */ Connection signal_connect_update_spot_location (HelperAgentSlotIntInt *slot); - + /** * @brief Connect a slot to Helper update cursor position signal. * @@ -628,6 +648,16 @@ public: Connection signal_connect_update_cursor_position (HelperAgentSlotInt *slot); /** + * @brief Connect a slot to Helper update surrounding text signal. + * + * This signal is used to let the Helper get the surrounding text. + * + * The prototype of the slot is: + * void update_surrounding_text (const HelperAgent *agent, int ic, const String &text, int cursor); + */ + Connection signal_connect_update_surrounding_text (HelperAgentSlotInt *slot); + + /** * @brief Connect a slot to Helper trigger property signal. * * This signal is used to trigger a property registered by this Helper. @@ -883,6 +913,16 @@ public: Connection signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot); /** + * @brief Connect a slot to Helper select aux signal. + * + * This signal is used to do something when aux is selected. + * + * The prototype of the slot is: + * void select_aux (const HelperAgent *agent, int ic, const String &uuid, int index); + */ + Connection signal_connect_select_aux (HelperAgentSlotInt *slot); + + /** * @brief Connect a slot to Helper select candidate signal. * * This signal is used to do something when candidate is selected. diff --git a/ism/src/scim_helper_launcher.cpp b/ism/src/scim_helper_launcher.cpp index 8c6281e..04ae36c 100644 --- a/ism/src/scim_helper_launcher.cpp +++ b/ism/src/scim_helper_launcher.cpp @@ -31,6 +31,7 @@ #include #include "scim_private.h" #include "scim.h" +#include using namespace scim; @@ -44,6 +45,8 @@ int main (int argc, char *argv []) String uuid; bool daemon = false; + control_privilege (); + char *p = getenv ("DISPLAY"); if (p) display = String (p); diff --git a/ism/src/scim_hotkey.cpp b/ism/src/scim_hotkey.cpp index 6b6f3e1..2c9f8cd 100644 --- a/ism/src/scim_hotkey.cpp +++ b/ism/src/scim_hotkey.cpp @@ -101,7 +101,7 @@ HotkeyMatcher::get_all_hotkeys (KeyEventList &keys, std::vector &ids) cons } size_t -HotkeyMatcher::find_hotkeys (int id, KeyEventList &keys) const +HotkeyMatcher::find_hotkeys (int id, KeyEventList &keys) const { keys.clear (); @@ -155,12 +155,12 @@ HotkeyMatcher::get_match_result (void) const return m_impl->m_result; } -//===================== IMEngineHotkeyMatcher ======================= +/*===================== IMEngineHotkeyMatcher =======================*/ class IMEngineHotkeyMatcher::IMEngineHotkeyMatcherImpl { public: HotkeyMatcher m_matcher; - std::vector m_uuids; + std::vector m_uuids; }; IMEngineHotkeyMatcher::IMEngineHotkeyMatcher () @@ -219,30 +219,12 @@ IMEngineHotkeyMatcher::load_hotkeys (const ConfigPointer &config) } } uuids.clear (); - - scim_split_string_list (uuids, config->read (String (SCIM_CONFIG_HOTKEYS_NEWISE_LIST), String (""))); - - std::sort (uuids.begin (), uuids.end ()); - uuids.erase (std::unique (uuids.begin (), uuids.end ()), uuids.end ()); - - if (uuids.size ()) { - KeyEventList keys; - for (std::vector ::iterator uit = uuids.begin (); uit != uuids.end (); ++uit) { - if (scim_string_to_key_list (keys, config->read (String (SCIM_CONFIG_HOTKEYS_NEWISE "/") + *uit, String ("")))) { - ISEInfo info; - info.type = NEWISE_T; - info.uuid = *uit; - m_impl->m_matcher.add_hotkeys (keys, (int) m_impl->m_uuids.size ()); - m_impl->m_uuids.push_back (info); - } - } - } } void IMEngineHotkeyMatcher::save_hotkeys (const ConfigPointer &config) const { - if (config.null () || !config->valid () /*|| !m_impl->m_uuids.size ()*/) return;//liushuo + if (config.null () || !config->valid () /*|| !m_impl->m_uuids.size ()*/) return; std::vector uuids; KeyEventList keys; @@ -250,7 +232,7 @@ IMEngineHotkeyMatcher::save_hotkeys (const ConfigPointer &config) const std::vector i_uuids; std::vector n_uuids; std::vector h_uuids; -//-------------------clear imengine hotkeys in config file -------------------- + /* Clear imengine hotkeys in config file */ scim_split_string_list (uuids, config->read (String (SCIM_CONFIG_HOTKEYS_IMENGINE_LIST), String (""))); std::sort (uuids.begin (), uuids.end ()); @@ -258,29 +240,12 @@ IMEngineHotkeyMatcher::save_hotkeys (const ConfigPointer &config) const if (uuids.size ()) { for (std::vector ::iterator uit = uuids.begin (); uit != uuids.end (); ++uit) - { config->write (String (SCIM_CONFIG_HOTKEYS_IMENGINE "/") + *uit, ""); - } } config->write (String (SCIM_CONFIG_HOTKEYS_IMENGINE_LIST), ""); - uuids.clear(); -//---------------clear new ise hotkeys in config file-------------------------- - scim_split_string_list (uuids, config->read (String (SCIM_CONFIG_HOTKEYS_NEWISE_LIST), String (""))); - - std::sort (uuids.begin (), uuids.end ()); - uuids.erase (std::unique (uuids.begin (), uuids.end ()), uuids.end ()); - - if (uuids.size ()) { - for (std::vector ::iterator uit = uuids.begin (); uit != uuids.end (); ++uit) - { - config->write (String (SCIM_CONFIG_HOTKEYS_NEWISE "/") + *uit, ""); - } - } - - config->write (String (SCIM_CONFIG_HOTKEYS_NEWISE_LIST), ""); uuids.clear (); -//-----------------clear helper hotkeys in config file---------------------------- + /* Clear helper hotkeys in config file */ scim_split_string_list (uuids, config->read (String (SCIM_CONFIG_HOTKEYS_HELPER_LIST), String (""))); std::sort (uuids.begin (), uuids.end ()); @@ -288,24 +253,19 @@ IMEngineHotkeyMatcher::save_hotkeys (const ConfigPointer &config) const if (uuids.size ()) { for (std::vector ::iterator uit = uuids.begin (); uit != uuids.end (); ++uit) - { config->write (String (SCIM_CONFIG_HOTKEYS_HELPER "/") + *uit, ""); - } } config->write (String (SCIM_CONFIG_HOTKEYS_HELPER_LIST), ""); uuids.clear (); -//---------------------- save to config -------------------------------------------- + /* Save to config */ for (size_t i = 0; i < m_impl->m_uuids.size (); ++i) { if (m_impl->m_matcher.find_hotkeys ((int) i, keys) > 0 && scim_key_list_to_string (keystr, keys)) { ISE_TYPE type = m_impl->m_uuids [i].type; if (type == IMENGINE_T) { config->write (String (SCIM_CONFIG_HOTKEYS_IMENGINE "/") + m_impl->m_uuids [i].uuid, keystr); i_uuids.push_back (m_impl->m_uuids [i].uuid); - } else if (type == NEWISE_T) { - config->write (String (SCIM_CONFIG_HOTKEYS_NEWISE "/") + m_impl->m_uuids [i].uuid, keystr); - n_uuids.push_back (m_impl->m_uuids [i].uuid); } else if (type == HELPER_T) { config->write (String (SCIM_CONFIG_HOTKEYS_HELPER "/") + m_impl->m_uuids [i].uuid, keystr); h_uuids.push_back (m_impl->m_uuids [i].uuid); @@ -314,12 +274,11 @@ IMEngineHotkeyMatcher::save_hotkeys (const ConfigPointer &config) const } config->write (String (SCIM_CONFIG_HOTKEYS_IMENGINE_LIST), scim_combine_string_list (i_uuids)); - config->write (String (SCIM_CONFIG_HOTKEYS_NEWISE_LIST), scim_combine_string_list (n_uuids)); config->write (String (SCIM_CONFIG_HOTKEYS_HELPER_LIST), scim_combine_string_list (h_uuids)); } void -IMEngineHotkeyMatcher::add_hotkey(const KeyEvent &key, const String &uuid, const ISE_TYPE &type) +IMEngineHotkeyMatcher::add_hotkey (const KeyEvent &key, const String &uuid, const ISE_TYPE &type) { if (key.empty () || !uuid.length ()) return; @@ -337,7 +296,6 @@ IMEngineHotkeyMatcher::add_hotkey(const KeyEvent &key, const String &uuid, const m_impl->m_uuids.push_back (info); } - m_impl->m_matcher.add_hotkey (key, i); } @@ -426,7 +384,7 @@ IMEngineHotkeyMatcher::get_match_result (void) const return ISEInfo (); } -//============================ FrontEndHotkeyMatcher ========================== +/*============================ FrontEndHotkeyMatcher ==========================*/ static const char *__scim_frontend_hotkey_config_paths [] = { 0, @@ -454,7 +412,7 @@ static const char *__scim_frontend_hotkey_defaults [] = class FrontEndHotkeyMatcher::FrontEndHotkeyMatcherImpl { public: - HotkeyMatcher m_matcher; + HotkeyMatcher m_matcher; }; FrontEndHotkeyMatcher::FrontEndHotkeyMatcher () @@ -476,7 +434,7 @@ FrontEndHotkeyMatcher::load_hotkeys (const ConfigPointer &config) KeyEventList keys; - // Load the least important hotkeys first. + /* Load the least important hotkeys first */ for (int i = SCIM_FRONTEND_HOTKEY_SHOW_FACTORY_MENU; i >= SCIM_FRONTEND_HOTKEY_TRIGGER; --i) { if (scim_string_to_key_list (keys, config->read (String (__scim_frontend_hotkey_config_paths [i]), String (__scim_frontend_hotkey_defaults [i])))) m_impl->m_matcher.add_hotkeys (keys, i); @@ -570,7 +528,7 @@ FrontEndHotkeyMatcher::get_match_result (void) const return SCIM_FRONTEND_HOTKEY_NOOP; } -} // namespace scim +} /* namespace scim */ /* vi:ts=4:nowrap:ai:expandtab diff --git a/ism/src/scim_hotkey.h b/ism/src/scim_hotkey.h index 64fb969..39bddf7 100644 --- a/ism/src/scim_hotkey.h +++ b/ism/src/scim_hotkey.h @@ -146,7 +146,6 @@ public: }; typedef enum { - NEWISE_T, HELPER_T, IMENGINE_T } ISE_TYPE; diff --git a/ism/src/scim_launcher.cpp b/ism/src/scim_launcher.cpp index ff151ad..148db3a 100644 --- a/ism/src/scim_launcher.cpp +++ b/ism/src/scim_launcher.cpp @@ -32,12 +32,16 @@ #define Uses_SCIM_CONFIG #define Uses_C_LOCALE #define Uses_SCIM_UTILITY +#define Uses_SCIM_PANEL_AGENT + #include "scim_private.h" #include "scim.h" #include #include #include #include +#include +#include "isf_query_utility.h" using namespace scim; @@ -90,6 +94,8 @@ int main (int argc, char *argv []) new_argv [new_argc ++] = argv [0]; + control_privilege (); + while (i < argc) { if (++i >= argc) break; @@ -219,6 +225,9 @@ int main (int argc, char *argv []) } gettime (clock_start, "Create Config"); + // Create folder for saving engine list + scim_make_dir (USER_ENGINE_LIST_PATH); + /* create backend */ backend = new CommonBackEnd (config, engine_list); gettime (clock_start, "Create backend"); diff --git a/ism/src/scim_panel_agent.cpp b/ism/src/scim_panel_agent.cpp index 1ea3bb4..785d136 100644 --- a/ism/src/scim_panel_agent.cpp +++ b/ism/src/scim_panel_agent.cpp @@ -750,6 +750,8 @@ public: unlock (); + helper_select_aux (item); + return client >= 0; } @@ -3452,6 +3454,8 @@ private: socket_update_spot_location (); else if (cmd == ISM_TRANS_CMD_UPDATE_CURSOR_POSITION) socket_update_cursor_position (); + else if (cmd == ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT) + socket_update_surrounding_text (); else if (cmd == SCIM_TRANS_CMD_PANEL_UPDATE_FACTORY_INFO) socket_update_factory_info (); else if (cmd == SCIM_TRANS_CMD_SHOW_PREEDIT_STRING) @@ -3596,6 +3600,10 @@ private: socket_helper_im_embedded_editor_preedit_changed (client_id); } else if(cmd == ISM_TRANS_CMD_LAUNCH_HELPER_ISE_LIST_SELECTION){ socket_helper_launch_helper_ise_list_selection(); + } else if (cmd == SCIM_TRANS_CMD_GET_SURROUNDING_TEXT) { + socket_helper_get_surrounding_text (client_id); + } else if (cmd == SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT) { + socket_helper_delete_surrounding_text (client_id); } } socket_transaction_end (); @@ -3974,6 +3982,41 @@ private: } } + void socket_update_surrounding_text (void) + { + SCIM_DEBUG_MAIN(4) << __FUNCTION__ << "...\n"; + + String text; + uint32 cursor; + if (m_recv_trans.get_data (text) && m_recv_trans.get_data (cursor)) { + HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid); + + if (it != m_helper_client_index.end ()) + { + int client; + uint32 context; + Socket client_socket (it->second.id); + uint32 ctx; + + lock (); + + get_focused_context (client, context); + ctx = get_helper_ic (client, context); + + m_send_trans.clear (); + m_send_trans.put_command (SCIM_TRANS_CMD_REPLY); + m_send_trans.put_data (ctx); + m_send_trans.put_data (m_current_helper_uuid); + m_send_trans.put_command (ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT); + m_send_trans.put_data (text); + m_send_trans.put_data (cursor); + m_send_trans.write_to_socket (client_socket); + + unlock (); + } + } + } + void socket_update_factory_info (void) { SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_update_factory_info ()\n"; @@ -4719,6 +4762,71 @@ private: } } + void socket_helper_get_surrounding_text (int client) + { + SCIM_DEBUG_MAIN(4) << __FUNCTION__ << " (" << client << ")\n"; + + String uuid; + uint32 maxlen_before; + uint32 maxlen_after; + + if (m_recv_trans.get_data (uuid) && + m_recv_trans.get_data (maxlen_before) && + m_recv_trans.get_data (maxlen_after)) { + + int focused_client; + uint32 focused_context; + String focused_uuid; + + focused_uuid = get_focused_context (focused_client, focused_context); + + ClientInfo client_info = socket_get_client_info (focused_client); + if (client_info.type == FRONTEND_CLIENT) { + Socket socket_client (focused_client); + lock (); + m_send_trans.clear (); + m_send_trans.put_command (SCIM_TRANS_CMD_REPLY); + m_send_trans.put_data (focused_context); + m_send_trans.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT); + m_send_trans.put_data (maxlen_before); + m_send_trans.put_data (maxlen_after); + m_send_trans.write_to_socket (socket_client); + unlock (); + } + } + } + + void socket_helper_delete_surrounding_text (int client) + { + SCIM_DEBUG_MAIN(4) << __FUNCTION__ << " (" << client << ")\n"; + + uint32 offset; + uint32 len; + + if (m_recv_trans.get_data (offset) && m_recv_trans.get_data (len)) { + + int focused_client; + uint32 focused_context; + String focused_uuid; + + focused_uuid = get_focused_context (focused_client, focused_context); + + ClientInfo client_info = socket_get_client_info (focused_client); + if (client_info.type == FRONTEND_CLIENT) { + Socket socket_client (focused_client); + lock (); + m_send_trans.clear (); + m_send_trans.put_command (SCIM_TRANS_CMD_REPLY); + m_send_trans.put_data (focused_context); + m_send_trans.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT); + m_send_trans.put_data (offset); + m_send_trans.put_data (len); + m_send_trans.write_to_socket (socket_client); + unlock (); + } + } + } + void socket_helper_show_preedit_string (int client) { SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_show_preedit_string (" << client << ")\n"; @@ -5176,7 +5284,7 @@ private: } } - void socket_helper_im_embedded_editor_preedit_changed (int client) + void socket_helper_im_embedded_editor_preedit_changed (int client) { SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_im_embedded_editor_preedit_changed (" << client << ")\n"; @@ -5209,8 +5317,40 @@ private: } } + bool helper_select_aux (uint32 item) + { + SCIM_DEBUG_MAIN(4) << "PanelAgent::helper_select_aux \n"; + + if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode) + { + HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid); + + if (it != m_helper_client_index.end ()) + { + int client; + uint32 context; + Socket client_socket (it->second.id); + uint32 ctx; + + get_focused_context (client, context); + ctx = get_helper_ic (client, context); + + m_send_trans.clear (); + m_send_trans.put_command (SCIM_TRANS_CMD_REPLY); + m_send_trans.put_data (ctx); + m_send_trans.put_data (m_current_helper_uuid); + m_send_trans.put_command (ISM_TRANS_CMD_SELECT_AUX); + m_send_trans.put_data ((uint32)item); + m_send_trans.write_to_socket (client_socket); + + return true; + } + } + + return false; + } - bool helper_select_candidate (uint32 item) + bool helper_select_candidate (uint32 item) { SCIM_DEBUG_MAIN(4) << "PanelAgent::helper_select_candidate \n"; diff --git a/ism/src/scim_panel_client.cpp b/ism/src/scim_panel_client.cpp index acad661..03849ac 100644 --- a/ism/src/scim_panel_client.cpp +++ b/ism/src/scim_panel_client.cpp @@ -46,6 +46,9 @@ typedef Signal1 typedef Signal2 PanelClientSignalInt; +typedef Signal3 + PanelClientSignalIntInt; + typedef Signal2 PanelClientSignalString; @@ -92,6 +95,8 @@ class PanelClient::PanelClientImpl PanelClientSignalVoid m_signal_show_preedit_string; PanelClientSignalVoid m_signal_hide_preedit_string; PanelClientSignalStringAttrs m_signal_update_preedit_string; + PanelClientSignalIntInt m_signal_get_surrounding_text; + PanelClientSignalIntInt m_signal_delete_surrounding_text; public: PanelClientImpl () @@ -351,6 +356,22 @@ public: } } break; + case SCIM_TRANS_CMD_GET_SURROUNDING_TEXT: + { + uint32 maxlen_before; + uint32 maxlen_after; + if (recv.get_data (maxlen_before) && recv.get_data (maxlen_after)) + m_signal_get_surrounding_text ((int) context, (int)maxlen_before, (int)maxlen_after); + } + break; + case SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT: + { + uint32 offset; + uint32 len; + if (recv.get_data (offset) && recv.get_data (len)) + m_signal_delete_surrounding_text ((int) context, (int)offset, (int)len); + } + break; default: break; } @@ -478,6 +499,14 @@ public: m_send_trans.put_data ((uint32) cursor_pos); } } + void update_surrounding_text (int icid, const WideString &str, int cursor) + { + if (m_send_refcount > 0 && m_current_icid == icid) { + m_send_trans.put_command (ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT); + m_send_trans.put_data (utf8_wcstombs (str)); + m_send_trans.put_data ((uint32) cursor); + } + } void show_preedit_string (int icid) { if (m_send_refcount > 0 && m_current_icid == icid) @@ -629,6 +658,8 @@ public: m_signal_show_preedit_string.reset(); m_signal_hide_preedit_string.reset(); m_signal_update_preedit_string.reset(); + m_signal_get_surrounding_text.reset(); + m_signal_delete_surrounding_text.reset(); } Connection signal_connect_reload_config (PanelClientSlotVoid *slot) @@ -724,6 +755,17 @@ public: { return m_signal_update_preedit_string.connect (slot); } + + Connection signal_connect_get_surrounding_text (PanelClientSlotIntInt *slot) + { + return m_signal_get_surrounding_text.connect (slot); + } + + Connection signal_connect_delete_surrounding_text (PanelClientSlotIntInt *slot) + { + return m_signal_delete_surrounding_text.connect (slot); + } + private: void launch_panel (const String &config, const String &display) const { @@ -840,6 +882,11 @@ PanelClient::update_cursor_position (int icid, int cursor_pos) m_impl->update_cursor_position (icid, cursor_pos); } void +PanelClient::update_surrounding_text (int icid, const WideString &str, int cursor) +{ + m_impl->update_surrounding_text (icid, str, cursor); +} +void PanelClient::show_preedit_string (int icid) { m_impl->show_preedit_string (icid); @@ -1064,6 +1111,17 @@ PanelClient::signal_connect_update_preedit_string (PanelClientSlotString return m_impl->signal_connect_update_preedit_string (slot); } +Connection +PanelClient::signal_connect_get_surrounding_text (PanelClientSlotIntInt *slot) +{ + return m_impl->signal_connect_get_surrounding_text (slot); +} + +Connection +PanelClient::signal_connect_delete_surrounding_text (PanelClientSlotIntInt *slot) +{ + return m_impl->signal_connect_delete_surrounding_text (slot); +} } /* namespace scim */ diff --git a/ism/src/scim_panel_client.h b/ism/src/scim_panel_client.h index 8193f15..dafbcc8 100644 --- a/ism/src/scim_panel_client.h +++ b/ism/src/scim_panel_client.h @@ -52,6 +52,9 @@ typedef Slot1 typedef Slot2 PanelClientSlotInt; +typedef Slot3 + PanelClientSlotIntInt; + typedef Slot2 PanelClientSlotString; @@ -175,6 +178,7 @@ public: void update_factory_info (int icid, const PanelFactoryInfo &info); void update_spot_location (int icid, int x, int y, int top_y); void update_cursor_position (int icid, int cursor_pos); + void update_surrounding_text (int icid, const WideString &str, int cursor); void show_preedit_string (int icid); void show_aux_string (int icid); void show_lookup_table (int icid); @@ -353,9 +357,41 @@ public: */ Connection signal_connect_update_keyboard_ise (PanelClientSlotVoid *slot); + /** + * @brief Signal: show preedit string + * + * slot prototype: void show_preedit_string (int context); + */ Connection signal_connect_show_preedit_string (PanelClientSlotVoid *slot); + + /** + * @brief Signal: hide preedit string + * + * slot prototype: void hide_preedit_string (int context); + */ Connection signal_connect_hide_preedit_string (PanelClientSlotVoid *slot); + + /** + * @brief Signal: update preedit string + * + * slot prototype: void update_preedit_string (int context, const WideString &str, const AttributeList &attrs); + */ Connection signal_connect_update_preedit_string (PanelClientSlotStringAttrs *slot); + + /** + * @brief Signal: Request to get surrounding text + * + * slot prototype: void get_surrounding text (int context, int maxlen_before, int maxlen_after); + */ + Connection signal_connect_get_surrounding_text (PanelClientSlotIntInt *slot); + + /** + * @brief Signal: Delete surrounding text + * + * slot prototype: void delete_surrounding text (int context, int offset, int len); + */ + Connection signal_connect_delete_surrounding_text (PanelClientSlotIntInt *slot); + /** @} */ }; diff --git a/ism/src/scim_trans_commands.h b/ism/src/scim_trans_commands.h index 13b0891..d85604e 100644 --- a/ism/src/scim_trans_commands.h +++ b/ism/src/scim_trans_commands.h @@ -563,6 +563,7 @@ const int SCIM_TRANS_CMD_RELOAD_CONFIG = 314; const int SCIM_TRANS_CMD_UPDATE_SCREEN = 400; const int SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION = 401; const int ISM_TRANS_CMD_UPDATE_CURSOR_POSITION = 402; +const int ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT = 403; //Privately used by panel. const int SCIM_TRANS_CMD_PANEL_EXIT = 500; diff --git a/releasenote.txt b/releasenote.txt index 1ffa540..07f7fb4 100644 --- a/releasenote.txt +++ b/releasenote.txt @@ -1,3 +1,6 @@ -ISF 2.3.4821 : - 1. Initial Release +ISF 2.3.5009 : + 1. Tizen beta Release + +ISF 2.3.4821 : + 1. Tizen alpha Release -- 2.7.4