static bool _scim_initialized = false;
static int _instance_count = 0;
-static int _context_count = 0;
static IMEngineFactoryPointer _fallback_factory;
static IMEngineInstancePointer _fallback_instance;
}
static void
-autoperiod_insert (WSCContextISF *ctx)
+autoperiod_insert (WSCContextISF *wsc_ctx)
{
char *plain_str = NULL;
int cursor_pos = 0;
if (autoperiod_allow == EINA_FALSE)
return;
- if (!ctx) return;
+ if (!wsc_ctx) return;
- Ecore_IMF_Input_Panel_Layout layout = wsc_context_input_panel_layout_get (ctx->ctx);
+ Ecore_IMF_Input_Panel_Layout layout = wsc_context_input_panel_layout_get (wsc_ctx);
if (layout != ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL)
return;
if ((ecore_time_get () - space_key_time) > DOUBLE_SPACE_INTERVAL)
goto done;
- wsc_context_surrounding_get (ctx->ctx, &plain_str, &cursor_pos);
+ wsc_context_surrounding_get (wsc_ctx, &plain_str, &cursor_pos);
if (!plain_str) goto done;
// Convert string from UTF-8 to unicode
if (check_space_symbol (ustr[cursor_pos-1]) &&
!(iswpunct (ustr[cursor_pos-2]) || check_space_symbol (ustr[cursor_pos-2]))) {
- wsc_context_delete_surrounding (ctx->ctx, -1, 1);
+ wsc_context_delete_surrounding (wsc_ctx, -1, 1);
if (input_lang == INPUT_LANG_OTHER) {
fullstop_mark = strdup (".");
fullstop_mark = strdup (utf8_wcstombs (wstr).c_str ());
}
- wsc_context_commit_string (ctx->ctx, fullstop_mark);
+ wsc_context_commit_string (wsc_ctx, fullstop_mark);
if (fullstop_mark) {
free (fullstop_mark);
}
static Eina_Bool
-analyze_surrounding_text (WSCContextISF *ctx)
+analyze_surrounding_text (WSCContextISF *wsc_ctx)
{
char *plain_str = NULL;
Eina_Unicode puncs[] = {'\n','.', '!', '?', 0x00BF /* ¿ */, 0x00A1 /* ¡ */,
const int punc_num = sizeof (puncs) / sizeof (puncs[0]);
WSCContextISF *context_scim;
- if (!ctx) return EINA_FALSE;
- context_scim = ctx;
+ if (!wsc_ctx) return EINA_FALSE;
+ context_scim = wsc_ctx;
if (!context_scim || !context_scim->impl) return EINA_FALSE;
switch (context_scim->impl->autocapital_type) {
if (context_scim->impl->preedit_updating)
return EINA_FALSE;
- wsc_context_surrounding_get (ctx->ctx, &plain_str, &cursor_pos);
+ wsc_context_surrounding_get (wsc_ctx, &plain_str, &cursor_pos);
if (!plain_str) goto done;
if (cursor_pos == 0) {
}
Eina_Bool
-caps_mode_check (WSCContextISF *ctx, Eina_Bool force, Eina_Bool noti)
+caps_mode_check (WSCContextISF *wsc_ctx, Eina_Bool force, Eina_Bool noti)
{
Eina_Bool uppercase;
WSCContextISF *context_scim;
if (get_keyboard_mode () == TOOLBAR_KEYBOARD_MODE) return EINA_FALSE;
- if (!ctx) return EINA_FALSE;
- context_scim = ctx;
+ if (!wsc_ctx) return EINA_FALSE;
+ context_scim = wsc_ctx;
if (!context_scim || !context_scim->impl)
return EINA_FALSE;
if (context_scim->impl->next_shift_status == SHIFT_MODE_LOCK) return EINA_TRUE;
- Ecore_IMF_Input_Panel_Layout layout = wsc_context_input_panel_layout_get (ctx->ctx);
+ Ecore_IMF_Input_Panel_Layout layout = wsc_context_input_panel_layout_get (wsc_ctx);
if (layout != ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL)
return EINA_FALSE;
// Check autocapital type
- if (wsc_context_input_panel_caps_lock_mode_get (ctx->ctx)) {
+ if (wsc_context_input_panel_caps_lock_mode_get (wsc_ctx)) {
uppercase = EINA_TRUE;
} else {
if (autocap_allow == EINA_FALSE)
return EINA_FALSE;
- if (analyze_surrounding_text (ctx)) {
+ if (analyze_surrounding_text (wsc_ctx)) {
uppercase = EINA_TRUE;
} else {
uppercase = EINA_FALSE;
if (force) {
context_scim->impl->next_shift_status = uppercase ? SHIFT_MODE_ON : SHIFT_MODE_OFF;
if (noti)
- isf_wsc_context_input_panel_caps_mode_set (ctx, uppercase);
+ isf_wsc_context_input_panel_caps_mode_set (wsc_ctx, uppercase);
} else {
if (context_scim->impl->next_shift_status != (uppercase ? SHIFT_MODE_ON : SHIFT_MODE_OFF)) {
context_scim->impl->next_shift_status = uppercase ? SHIFT_MODE_ON : SHIFT_MODE_OFF;
if (noti)
- isf_wsc_context_input_panel_caps_mode_set (ctx, uppercase);
+ isf_wsc_context_input_panel_caps_mode_set (wsc_ctx, uppercase);
}
}
get_input_language ();
}
-void context_scim_imdata_get (WSCContextISF *ctx, void* data, int* length)
+void context_scim_imdata_get (WSCContextISF *wsc_ctx, void* data, int* length)
{
- WSCContextISF *context_scim = ctx;
+ WSCContextISF *context_scim = wsc_ctx;
SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
}
void
-imengine_layout_set (WSCContextISF *ctx, Ecore_IMF_Input_Panel_Layout layout)
+imengine_layout_set (WSCContextISF *wsc_ctx, Ecore_IMF_Input_Panel_Layout layout)
{
- WSCContextISF *context_scim = ctx;
+ WSCContextISF *context_scim = wsc_ctx;
if (context_scim && context_scim->impl && context_scim->impl->si && context_scim == _focused_ic) {
_panel_client.prepare (context_scim->id);
}
/* Public functions */
-WSCContextISF *
-isf_wsc_context_new (void)
+void
+isf_wsc_context_init (void)
{
SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
int val;
- WSCContextISF *context_scim = new WSCContextISF;
- if (context_scim == NULL) {
- std::cerr << "memory allocation failed in " << __FUNCTION__ << "\n";
- return NULL;
- }
-
- if (_context_count == 0) {
- _context_count = getpid () % 50000;
- }
- context_scim->id = _context_count++;
-
if (!_scim_initialized) {
ecore_wl_init (NULL);
initialize ();
vconf_notify_key_changed (VCONFKEY_ISF_INPUT_LANGUAGE, input_language_changed_cb, NULL);
}
-
- return context_scim;
}
void
}
void
-isf_wsc_context_add (WSCContextISF *ctx)
+isf_wsc_context_add (WSCContextISF *wsc_ctx)
{
SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
- WSCContextISF *context_scim = ctx;
+ WSCContextISF *context_scim = wsc_ctx;
if (!context_scim) return;
}
void
-isf_wsc_context_del (WSCContextISF *ctx)
+isf_wsc_context_del (WSCContextISF *wsc_ctx)
{
SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
if (!_ic_list) return;
- WSCContextISF *context_scim = ctx;
+ WSCContextISF *context_scim = wsc_ctx;
if (context_scim) {
if (context_scim->id != _ic_list->id) {
if (context_scim == _focused_ic)
_focused_ic = 0;
- if (context_scim) {
- delete context_scim;
- context_scim = 0;
- }
}
void
-isf_wsc_context_focus_in (WSCContextISF *ctx)
+isf_wsc_context_focus_in (WSCContextISF *wsc_ctx)
{
- WSCContextISF *context_scim = ctx;
+ WSCContextISF *context_scim = wsc_ctx;
if (!context_scim)
return;
return;
}
SCIM_DEBUG_FRONTEND(1) << "Focus out previous IC first: " << _focused_ic->id << "\n";
- if (_focused_ic->ctx)
- isf_wsc_context_focus_out (_focused_ic);
+ isf_wsc_context_focus_out (_focused_ic);
}
if (_change_keyboard_mode_by_focus_move) {
//if h/w keyboard mode, keyboard mode will be changed to s/w mode when the entry get the focus.
LOGD ("Keyboard mode is changed H/W->S/W because of focus_in.\n");
- isf_wsc_context_set_keyboard_mode (ctx, TOOLBAR_HELPER_MODE);
+ isf_wsc_context_set_keyboard_mode (wsc_ctx, TOOLBAR_HELPER_MODE);
}
bool need_cap = false;
// _panel_client.hide_aux_string (context_scim->id);
// _panel_client.hide_lookup_table (context_scim->id);
context_scim->impl->si->focus_in ();
- context_scim->impl->si->set_layout (wsc_context_input_panel_layout_get (ctx->ctx));
+ context_scim->impl->si->set_layout (wsc_context_input_panel_layout_get (wsc_ctx));
context_scim->impl->si->set_prediction_allow (context_scim->impl->prediction_allow);
if (context_scim->impl->imdata)
context_scim->impl->si->set_imdata ((const char *)context_scim->impl->imdata, context_scim->impl->imdata_size);
_panel_client.get_active_helper_option (&_active_helper_option);
_panel_client.send ();
- if (caps_mode_check (ctx, EINA_FALSE, EINA_TRUE) == EINA_FALSE) {
+ if (caps_mode_check (wsc_ctx, EINA_FALSE, EINA_TRUE) == EINA_FALSE) {
context_scim->impl->next_shift_status = 0;
}
}
}
- LOGD ("ctx : %p\n", ctx);
+ LOGD ("ctx : %p\n", wsc_ctx);
}
void
-isf_wsc_context_focus_out (WSCContextISF *ctx)
+isf_wsc_context_focus_out (WSCContextISF *wsc_ctx)
{
- WSCContextISF *context_scim = ctx;
+ WSCContextISF *context_scim = wsc_ctx;
if (!context_scim) return;
if (context_scim && context_scim->impl && context_scim == _focused_ic) {
- LOGD ("ctx : %p\n", ctx);
+ LOGD ("ctx : %p\n", wsc_ctx);
if (context_scim->impl->need_commit_preedit) {
_hide_preedit_string (context_scim->id, false);
- wsc_context_commit_preedit_string (context_scim->ctx);
+ wsc_context_commit_preedit_string (context_scim);
_panel_client.prepare (context_scim->id);
_panel_client.reset_input_context (context_scim->id);
_panel_client.send ();
}
void
-isf_wsc_context_reset (WSCContextISF *ctx)
+isf_wsc_context_reset (WSCContextISF *wsc_ctx)
{
SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
- WSCContextISF *context_scim = ctx;
+ WSCContextISF *context_scim = wsc_ctx;
if (context_scim && context_scim->impl && context_scim == _focused_ic) {
if (context_scim->impl->si) {
if (context_scim->impl->need_commit_preedit) {
_hide_preedit_string (context_scim->id, false);
- wsc_context_commit_preedit_string (context_scim->ctx);
+ wsc_context_commit_preedit_string (context_scim);
}
}
}
void
-isf_wsc_context_cursor_position_set (WSCContextISF *ctx, int cursor_pos)
+isf_wsc_context_cursor_position_set (WSCContextISF *wsc_ctx, int cursor_pos)
{
SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
- WSCContextISF *context_scim = ctx;
+ WSCContextISF *context_scim = wsc_ctx;
if (context_scim && context_scim->impl && context_scim == _focused_ic) {
if (context_scim->impl->cursor_pos != cursor_pos) {
- LOGD ("ctx : %p, cursor pos : %d\n", ctx, cursor_pos);
+ LOGD ("ctx : %p, cursor pos : %d\n", wsc_ctx, cursor_pos);
context_scim->impl->cursor_pos = cursor_pos;
- caps_mode_check (ctx, EINA_FALSE, EINA_TRUE);
+ caps_mode_check (wsc_ctx, EINA_FALSE, EINA_TRUE);
if (context_scim->impl->preedit_updating)
return;
}
void
-isf_wsc_context_preedit_string_get (WSCContextISF *ctx, char** str, int *cursor_pos)
+isf_wsc_context_preedit_string_get (WSCContextISF *wsc_ctx, char** str, int *cursor_pos)
{
SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
- WSCContextISF *context_scim = ctx;
+ WSCContextISF *context_scim = wsc_ctx;
if (context_scim && context_scim->impl && context_scim->impl->is_on) {
String mbs = utf8_wcstombs (context_scim->impl->preedit_string);
}
void
-isf_wsc_context_prediction_allow_set (WSCContextISF* ctx, Eina_Bool prediction)
+isf_wsc_context_prediction_allow_set (WSCContextISF* wsc_ctx, Eina_Bool prediction)
{
SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " = " << (prediction == EINA_TRUE ? "true" : "false") << "...\n";
- WSCContextISF *context_scim = ctx;
+ WSCContextISF *context_scim = wsc_ctx;
if (context_scim && context_scim->impl && context_scim->impl->prediction_allow != prediction) {
context_scim->impl->prediction_allow = prediction;
- set_prediction_allow (ctx, prediction);
+ set_prediction_allow (wsc_ctx, prediction);
}
}
Eina_Bool
-isf_wsc_context_prediction_allow_get (WSCContextISF* ctx)
+isf_wsc_context_prediction_allow_get (WSCContextISF* wsc_ctx)
{
SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
- WSCContextISF *context_scim = ctx;
+ WSCContextISF *context_scim = wsc_ctx;
Eina_Bool ret = EINA_FALSE;
if (context_scim && context_scim->impl) {
}
void
-isf_wsc_context_autocapital_type_set (WSCContextISF* ctx, Ecore_IMF_Autocapital_Type autocapital_type)
+isf_wsc_context_autocapital_type_set (WSCContextISF* wsc_ctx, Ecore_IMF_Autocapital_Type autocapital_type)
{
SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << " = " << autocapital_type << "...\n";
- WSCContextISF *context_scim = ctx;
+ WSCContextISF *context_scim = wsc_ctx;
if (context_scim && context_scim->impl && context_scim->impl->autocapital_type != autocapital_type) {
context_scim->impl->autocapital_type = autocapital_type;
if (context_scim->impl->si && context_scim == _focused_ic) {
- LOGD ("ctx : %p. set autocapital type : %d\n", ctx, autocapital_type);
+ LOGD ("ctx : %p. set autocapital type : %d\n", wsc_ctx, autocapital_type);
_panel_client.prepare (context_scim->id);
context_scim->impl->si->set_autocapital_type (autocapital_type);
_panel_client.send ();
}
}
+#ifdef _TV
static
bool is_number_key(const char *str)
{
else
return true;
}
+#endif
void
-isf_wsc_context_filter_key_event (struct weescim *wsc,
+isf_wsc_context_filter_key_event (WSCContextISF* wsc_ctx,
uint32_t serial,
uint32_t timestamp, uint32_t keycode, uint32_t symcode,
char *keyname,
{
SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
- if (!wsc) return;
+ if (!wsc_ctx) return;
Eina_Bool ret = EINA_FALSE;
- KeyEvent key(symcode, wsc->modifiers);
+ KeyEvent key(symcode, wsc_ctx->modifiers);
bool ignore_key = filter_keys (keyname, SCIM_CONFIG_HOTKEYS_FRONTEND_IGNORE_KEY);
if (state == WL_KEYBOARD_KEY_STATE_RELEASED) {
&& key.code != 0xFF69) {
/* XF86back, Cancel (Power + Volume down) key */
#endif
- isf_wsc_context_set_keyboard_mode (wsc->wsc_ctx, TOOLBAR_KEYBOARD_MODE);
+ isf_wsc_context_set_keyboard_mode (wsc_ctx, TOOLBAR_KEYBOARD_MODE);
ISF_SAVE_LOG ("Changed keyboard mode from S/W to H/W (code: %x, name: %s)\n", key.code, keyname);
LOGD ("Hardware keyboard mode, active helper option: %d\n", _active_helper_option);
}
}
if (!ignore_key) {
- _panel_client.prepare (wsc->wsc_ctx->id);
+ _panel_client.prepare (wsc_ctx->id);
ret = EINA_TRUE;
- if (!filter_hotkeys (wsc->wsc_ctx, key)) {
+ if (!filter_hotkeys (wsc_ctx, key)) {
if (!_focused_ic || !_focused_ic->impl || !_focused_ic->impl->is_on) {
ret = EINA_FALSE;
#ifdef _TV
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
if (key.code == SCIM_KEY_space ||
key.code == SCIM_KEY_KP_Space)
- autoperiod_insert (wsc->wsc_ctx);
+ autoperiod_insert (wsc_ctx);
}
}
}
}
if (ret == EINA_FALSE) {
- send_wl_key_event (wsc->wsc_ctx, key, false);
+ send_wl_key_event (wsc_ctx, key, false);
}
}
static void
-wsc_commit_preedit (weescim *ctx)
+wsc_commit_preedit (WSCContextISF* wsc_ctx)
{
char *surrounding_text;
- if (!ctx || !ctx->preedit_str ||
- strlen (ctx->preedit_str) == 0)
+ if (!wsc_ctx || !wsc_ctx->preedit_str ||
+ strlen (wsc_ctx->preedit_str) == 0)
return;
- wl_input_method_context_cursor_position (ctx->im_ctx,
+ wl_input_method_context_cursor_position (wsc_ctx->im_ctx,
0, 0);
- wl_input_method_context_commit_string (ctx->im_ctx,
- ctx->serial,
- ctx->preedit_str);
+ wl_input_method_context_commit_string (wsc_ctx->im_ctx,
+ wsc_ctx->serial,
+ wsc_ctx->preedit_str);
- if (ctx->surrounding_text) {
- surrounding_text = insert_text (ctx->surrounding_text,
- ctx->surrounding_cursor,
- ctx->preedit_str);
+ if (wsc_ctx->surrounding_text) {
+ surrounding_text = insert_text (wsc_ctx->surrounding_text,
+ wsc_ctx->surrounding_cursor,
+ wsc_ctx->preedit_str);
- free (ctx->surrounding_text);
- ctx->surrounding_text = surrounding_text;
- ctx->surrounding_cursor += strlen (ctx->preedit_str);
+ free (wsc_ctx->surrounding_text);
+ wsc_ctx->surrounding_text = surrounding_text;
+ wsc_ctx->surrounding_cursor += strlen (wsc_ctx->preedit_str);
} else {
- ctx->surrounding_text = strdup (ctx->preedit_str);
- ctx->surrounding_cursor = strlen (ctx->preedit_str);
+ wsc_ctx->surrounding_text = strdup (wsc_ctx->preedit_str);
+ wsc_ctx->surrounding_cursor = strlen (wsc_ctx->preedit_str);
}
- if (ctx->preedit_str)
- free (ctx->preedit_str);
+ if (wsc_ctx->preedit_str)
+ free (wsc_ctx->preedit_str);
- ctx->preedit_str = strdup ("");
+ wsc_ctx->preedit_str = strdup ("");
}
static void
-wsc_send_preedit (weescim *ctx, int32_t cursor)
+wsc_send_preedit (WSCContextISF* wsc_ctx, int32_t cursor)
{
- if (!ctx) return;
+ if (!wsc_ctx) return;
- uint32_t index = strlen (ctx->preedit_str);
+ uint32_t index = strlen (wsc_ctx->preedit_str);
- if (ctx->preedit_style)
- wl_input_method_context_preedit_styling (ctx->im_ctx,
+ if (wsc_ctx->preedit_style)
+ wl_input_method_context_preedit_styling (wsc_ctx->im_ctx,
0,
- strlen (ctx->preedit_str),
- ctx->preedit_style);
+ strlen (wsc_ctx->preedit_str),
+ wsc_ctx->preedit_style);
if (cursor > 0)
index = cursor;
- wl_input_method_context_preedit_cursor (ctx->im_ctx, index);
- wl_input_method_context_preedit_string (ctx->im_ctx,
- ctx->serial,
- ctx->preedit_str,
- ctx->preedit_str);
+ wl_input_method_context_preedit_cursor (wsc_ctx->im_ctx, index);
+ wl_input_method_context_preedit_string (wsc_ctx->im_ctx,
+ wsc_ctx->serial,
+ wsc_ctx->preedit_str,
+ wsc_ctx->preedit_str);
}
-bool wsc_context_surrounding_get (weescim *ctx, char **text, int *cursor_pos)
+bool wsc_context_surrounding_get (WSCContextISF *wsc_ctx, char **text, int *cursor_pos)
{
- if (!ctx)
+ if (!wsc_ctx)
return false;
if (text) {
- if (ctx->surrounding_text)
- *text = strdup (ctx->surrounding_text);
+ if (wsc_ctx->surrounding_text)
+ *text = strdup (wsc_ctx->surrounding_text);
else
*text = strdup ("");
}
if (cursor_pos)
- *cursor_pos = ctx->surrounding_cursor;
+ *cursor_pos = wsc_ctx->surrounding_cursor;
return true;
}
-Ecore_IMF_Input_Panel_Layout wsc_context_input_panel_layout_get (weescim *ctx)
+Ecore_IMF_Input_Panel_Layout wsc_context_input_panel_layout_get (WSCContextISF *wsc_ctx)
{
Ecore_IMF_Input_Panel_Layout layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
- if (!ctx)
+ if (!wsc_ctx)
return layout;
- switch (ctx->content_purpose) {
+ switch (wsc_ctx->content_purpose) {
case WL_TEXT_INPUT_CONTENT_PURPOSE_DIGITS:
case WL_TEXT_INPUT_CONTENT_PURPOSE_DIGITS_SIGNED:
case WL_TEXT_INPUT_CONTENT_PURPOSE_DIGITS_DECIMAL:
return layout;
}
-int wsc_context_input_panel_layout_variation_get (weescim *ctx)
+int wsc_context_input_panel_layout_variation_get (WSCContextISF *wsc_ctx)
{
int layout_variation = 0;
- if (!ctx)
+ if (!wsc_ctx)
return layout_variation;
- switch (ctx->content_purpose) {
+ switch (wsc_ctx->content_purpose) {
case WL_TEXT_INPUT_CONTENT_PURPOSE_DIGITS:
layout_variation = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY_VARIATION_NORMAL;
break;
return layout_variation;
}
-Ecore_IMF_Autocapital_Type wsc_context_autocapital_type_get (weescim *ctx)
+Ecore_IMF_Autocapital_Type wsc_context_autocapital_type_get (WSCContextISF *wsc_ctx)
{
Ecore_IMF_Autocapital_Type autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_NONE;
- if (!ctx)
+ if (!wsc_ctx)
return autocapital_type;
- if (ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_AUTO_CAPITALIZATION)
+ if (wsc_ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_AUTO_CAPITALIZATION)
autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE;
- else if (ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_WORD_CAPITALIZATION)
+ else if (wsc_ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_WORD_CAPITALIZATION)
autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_WORD;
- else if (ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_UPPERCASE)
+ else if (wsc_ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_UPPERCASE)
autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER;
else
autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_NONE;
return autocapital_type;
}
-bool wsc_context_input_panel_caps_lock_mode_get (weescim *ctx)
+bool wsc_context_input_panel_caps_lock_mode_get (WSCContextISF *wsc_ctx)
{
- if (!ctx)
+ if (!wsc_ctx)
return false;
- if (ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_UPPERCASE)
+ if (wsc_ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_UPPERCASE)
return true;
return false;
}
-Ecore_IMF_Input_Panel_Lang wsc_context_input_panel_language_get (weescim *ctx)
+Ecore_IMF_Input_Panel_Lang wsc_context_input_panel_language_get (WSCContextISF *wsc_ctx)
{
Ecore_IMF_Input_Panel_Lang language = ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC;
- if (!ctx)
+ if (!wsc_ctx)
return language;
- if (ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_LATIN)
+ if (wsc_ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_LATIN)
language = ECORE_IMF_INPUT_PANEL_LANG_ALPHABET;
else
language = ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC;
return language;
}
-bool wsc_context_input_panel_password_mode_get (weescim *ctx)
+bool wsc_context_input_panel_password_mode_get (WSCContextISF *wsc_ctx)
{
- if (ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_PASSWORD)
+ if (wsc_ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_PASSWORD)
return true;
- if (wsc_context_input_panel_layout_get (ctx) == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD)
+ if (wsc_context_input_panel_layout_get (wsc_ctx) == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD)
return true;
return false;
}
-Ecore_IMF_Input_Hints wsc_context_input_hint_get (weescim *ctx)
+Ecore_IMF_Input_Hints wsc_context_input_hint_get (WSCContextISF *wsc_ctx)
{
int input_hint = ECORE_IMF_INPUT_HINT_NONE;
- if (!ctx)
+ if (!wsc_ctx)
return (Ecore_IMF_Input_Hints)input_hint;
- if (ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_SENSITIVE_DATA)
+ if (wsc_ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_SENSITIVE_DATA)
input_hint |= ECORE_IMF_INPUT_HINT_SENSITIVE_DATA;
else
input_hint &= ~ECORE_IMF_INPUT_HINT_SENSITIVE_DATA;
- if (ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_AUTO_COMPLETION)
+ if (wsc_ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_AUTO_COMPLETION)
input_hint |= ECORE_IMF_INPUT_HINT_AUTO_COMPLETE;
else
input_hint &= ~ECORE_IMF_INPUT_HINT_AUTO_COMPLETE;
return (Ecore_IMF_Input_Hints)input_hint;
}
-Eina_Bool wsc_context_prediction_allow_get (weescim *ctx)
+Eina_Bool wsc_context_prediction_allow_get (WSCContextISF *wsc_ctx)
{
- if (!ctx)
+ if (!wsc_ctx)
return EINA_FALSE;
- if (ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_AUTO_COMPLETION)
+ if (wsc_ctx->content_hint & WL_TEXT_INPUT_CONTENT_HINT_AUTO_COMPLETION)
return EINA_TRUE;
else
return EINA_FALSE;
}
-void wsc_context_delete_surrounding (weescim *ctx, int offset, int len)
+void wsc_context_delete_surrounding (WSCContextISF *wsc_ctx, int offset, int len)
{
- if (!ctx)
+ if (!wsc_ctx)
return;
- wl_input_method_context_delete_surrounding_text (ctx->im_ctx, offset, len);
+ wl_input_method_context_delete_surrounding_text (wsc_ctx->im_ctx, offset, len);
}
-void wsc_context_set_selection (weescim *ctx, int start, int end)
+void wsc_context_set_selection (WSCContextISF *wsc_ctx, int start, int end)
{
- if (!ctx)
+ if (!wsc_ctx)
return;
- wl_input_method_context_selection_region (ctx->im_ctx, ctx->serial, start, end);
+ wl_input_method_context_selection_region (wsc_ctx->im_ctx, wsc_ctx->serial, start, end);
}
-void wsc_context_commit_string (weescim *ctx, const char *str)
+void wsc_context_commit_string (WSCContextISF *wsc_ctx, const char *str)
{
- if (!ctx)
+ if (!wsc_ctx)
return;
- if (ctx->preedit_str) {
- free (ctx->preedit_str);
- ctx->preedit_str = NULL;
+ if (wsc_ctx->preedit_str) {
+ free (wsc_ctx->preedit_str);
+ wsc_ctx->preedit_str = NULL;
}
- ctx->preedit_str = strdup (str);
- wsc_commit_preedit (ctx);
+ wsc_ctx->preedit_str = strdup (str);
+ wsc_commit_preedit (wsc_ctx);
}
-void wsc_context_commit_preedit_string (weescim *ctx)
+void wsc_context_commit_preedit_string (WSCContextISF *wsc_ctx)
{
char *preedit_str = NULL;
int cursor_pos = 0;
- if (!ctx)
+ if (!wsc_ctx)
return;
- if (ctx->wsc_ctx)
- isf_wsc_context_preedit_string_get (ctx->wsc_ctx, &preedit_str, &cursor_pos);
+ isf_wsc_context_preedit_string_get (wsc_ctx, &preedit_str, &cursor_pos);
- if (ctx->preedit_str) {
- free (ctx->preedit_str);
- ctx->preedit_str = NULL;
+ if (wsc_ctx->preedit_str) {
+ free (wsc_ctx->preedit_str);
+ wsc_ctx->preedit_str = NULL;
}
- ctx->preedit_str = preedit_str;
- wsc_commit_preedit (ctx);
+ wsc_ctx->preedit_str = preedit_str;
+ wsc_commit_preedit (wsc_ctx);
}
-void wsc_context_send_preedit_string (weescim *ctx)
+void wsc_context_send_preedit_string (WSCContextISF *wsc_ctx)
{
char *preedit_str = NULL;
int cursor_pos = 0;
- if (!ctx)
+ if (!wsc_ctx)
return;
- if (ctx->wsc_ctx)
- isf_wsc_context_preedit_string_get (ctx->wsc_ctx, &preedit_str, &cursor_pos);
+ isf_wsc_context_preedit_string_get (wsc_ctx, &preedit_str, &cursor_pos);
- if (ctx->preedit_str) {
- free (ctx->preedit_str);
- ctx->preedit_str = NULL;
+ if (wsc_ctx->preedit_str) {
+ free (wsc_ctx->preedit_str);
+ wsc_ctx->preedit_str = NULL;
}
- ctx->preedit_str = preedit_str;
- wsc_send_preedit (ctx, cursor_pos);
+ wsc_ctx->preedit_str = preedit_str;
+ wsc_send_preedit (wsc_ctx, cursor_pos);
}
-void wsc_context_send_key (weescim *ctx, uint32_t keysym, uint32_t modifiers, uint32_t time, bool press)
+void wsc_context_send_key (WSCContextISF *wsc_ctx, uint32_t keysym, uint32_t modifiers, uint32_t time, bool press)
{
- if (!ctx || !ctx->im_ctx)
+ if (!wsc_ctx)
return;
- ctx->modifiers = modifiers;
+ wsc_ctx->modifiers = modifiers;
- wl_input_method_context_keysym (ctx->im_ctx, ctx->serial, time,
- keysym, press ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED, ctx->modifiers);
+ wl_input_method_context_keysym (wsc_ctx->im_ctx, wsc_ctx->serial, time,
+ keysym, press ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED, wsc_ctx->modifiers);
}
static void
KeyEvent _key = key;
if (key.is_key_press () &&
- wsc_context_input_panel_layout_get (ic->ctx) == ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL) {
+ wsc_context_input_panel_layout_get (ic) == ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL) {
if (key.code == SHIFT_MODE_OFF ||
key.code == SHIFT_MODE_ON ||
key.code == SHIFT_MODE_LOCK) {
snprintf (string, sizeof (string), "%c", code);
if (strlen (string) != 0) {
- wsc_context_commit_string(ic->ctx, string);
+ wsc_context_commit_string(ic, string);
caps_mode_check (ic, EINA_FALSE, EINA_TRUE);
}
} else {
if (ic->impl->need_commit_preedit)
_hide_preedit_string (ic->id, false);
- wsc_context_commit_string (ic->ctx, utf8_wcstombs (wstr).c_str ());
+ wsc_context_commit_string (ic, utf8_wcstombs (wstr).c_str ());
}
}
_hide_preedit_string (ic->id, false);
if (wstr.length ()) {
- wsc_context_commit_string (ic->ctx, utf8_wcstombs (wstr).c_str ());
+ wsc_context_commit_string (ic, utf8_wcstombs (wstr).c_str ());
if (!check_valid_ic (ic))
return;
}
ic->impl->need_commit_preedit = false;
}
}
- wsc_context_send_preedit_string (ic->ctx);
+ wsc_context_send_preedit_string (ic);
} else {
_panel_client.prepare (ic->id);
_panel_client.hide_preedit_string (ic->id);
ic->impl->preedit_updating = true;
if (check_valid_ic (ic))
ic->impl->preedit_updating = false;
- wsc_context_send_preedit_string (ic->ctx);
+ wsc_context_send_preedit_string (ic);
} else {
_panel_client.prepare (ic->id);
_panel_client.update_preedit_string (ic->id, str, attrs, caret);
sym = _keyname_to_keysym (key.code, &modifiers);
if (ic)
- wsc_context_send_key (ic->ctx, key.code, modifiers, time, key.is_key_press ());
+ wsc_context_send_key (ic, key.code, modifiers, time, key.is_key_press ());
}
static void
if (check_valid_ic (ic))
ic->impl->preedit_started = false;
}
- wsc_context_send_preedit_string (ic->ctx);
+ wsc_context_send_preedit_string (ic);
} else {
_panel_client.hide_preedit_string (ic->id);
}
ic->impl->preedit_updating = true;
if (check_valid_ic (ic))
ic->impl->preedit_updating = false;
- wsc_context_send_preedit_string (ic->ctx);
+ wsc_context_send_preedit_string (ic);
} else {
_panel_client.update_preedit_string (ic->id, str, attrs, caret);
}
WSCContextISF *ic = static_cast<WSCContextISF *> (si->get_frontend_data ());
- if (ic && ic->ctx) {
+ if (ic) {
if (utf8_wcstombs (str) == String (" ") || utf8_wcstombs (str) == String (" "))
autoperiod_insert (ic);
Eina_Bool auto_capitalized = EINA_FALSE;
if (ic->impl) {
- if (wsc_context_input_panel_layout_get (ic->ctx) == ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL &&
+ if (wsc_context_input_panel_layout_get (ic) == ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL &&
ic->impl->shift_mode_enabled &&
ic->impl->autocapital_type != ECORE_IMF_AUTOCAPITAL_TYPE_NONE &&
get_keyboard_mode () == TOOLBAR_HELPER_MODE) {
converted[0] += 32;
}
- wsc_context_commit_string (ic->ctx, converted);
+ wsc_context_commit_string (ic, converted);
auto_capitalized = EINA_TRUE;
}
}
}
if (!auto_capitalized) {
- wsc_context_commit_string (ic->ctx, utf8_wcstombs (str).c_str ());
+ wsc_context_commit_string (ic, utf8_wcstombs (str).c_str ());
}
}
}
if (ic && ic->impl && _focused_ic == ic) {
char *surrounding = NULL;
int cursor_index;
- if (wsc_context_surrounding_get (_focused_ic->ctx, &surrounding, &cursor_index)) {
+ if (wsc_context_surrounding_get (_focused_ic, &surrounding, &cursor_index)) {
SCIM_DEBUG_FRONTEND(2) << "Surrounding text: " << surrounding <<"\n";
SCIM_DEBUG_FRONTEND(2) << "Cursor Index : " << cursor_index <<"\n";
WSCContextISF *ic = static_cast<WSCContextISF *> (si->get_frontend_data ());
if (ic && _focused_ic == ic) {
- wsc_context_delete_surrounding (_focused_ic->ctx, offset, len);
+ wsc_context_delete_surrounding (_focused_ic, offset, len);
return true;
}
return false;
WSCContextISF *ic = static_cast<WSCContextISF *> (si->get_frontend_data ());
if (_focused_ic && _focused_ic == ic) {
- wsc_context_set_selection (_focused_ic->ctx, start, end);
+ wsc_context_set_selection (_focused_ic, start, end);
return true;
}
return false;
WSCContextISF *ic = static_cast<WSCContextISF *> (si->get_frontend_data ());
if (_focused_ic && _focused_ic == ic) {
- if (_focused_ic->ctx && _focused_ic->ctx->im_ctx)
- wl_input_method_context_private_command (_focused_ic->ctx->im_ctx, _focused_ic->ctx->serial, command.c_str ());
+ if (_focused_ic->im_ctx)
+ wl_input_method_context_private_command (_focused_ic->im_ctx, _focused_ic->serial, command.c_str ());
}
}
SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
if (_focused_ic && _focused_ic->impl) {
- wsc_context_commit_string (_focused_ic->ctx, utf8_wcstombs (str).c_str ());
+ wsc_context_commit_string (_focused_ic, utf8_wcstombs (str).c_str ());
}
}
#include <Ecore.h>
#include <Ecore_IMF.h>
#include <dlog.h>
+#include "scim_stl_map.h"
+
+#if SCIM_USE_STL_EXT_HASH_MAP
+ typedef __gnu_cxx::hash_map <uint32_t, uint32_t, __gnu_cxx::hash <uint32_t> > KeycodeRepository;
+#elif SCIM_USE_STL_HASH_MAP
+ typedef std::hash_map <uint32_t, ClientInfo, std::hash <uint32_t> > KeycodeRepository;
+#else
+ typedef std::map <uint32_t, uint32_t> KeycodeRepository;
+#endif
struct weescim;
typedef struct _WSCContextISF WSCContextISF;
typedef struct _WSCContextISFImpl WSCContextISFImpl;
-typedef void (*keyboard_input_key_handler_t)(struct weescim *wsc,
+typedef void (*keyboard_input_key_handler_t)(WSCContextISF *wsc_ctx,
uint32_t serial,
uint32_t time, uint32_t keycode, uint32_t symcode,
char *keyname,
struct weescim
{
struct wl_input_method *im;
- struct wl_input_method_context *im_ctx;
struct wl_seat *seat;
+
+ WSCContextISF *wsc_ctx;
+};
+
+struct _WSCContextISF {
+ weescim *ctx;
+
struct wl_keyboard *keyboard;
+ struct wl_input_method_context *im_ctx;
struct xkb_context *xkb_context;
xkb_mod_mask_t alt_mask;
xkb_mod_mask_t shift_mask;
+ KeycodeRepository _keysym2keycode;
+
keyboard_input_key_handler_t key_handler;
+
char *surrounding_text;
char *preedit_str;
char *language;
uint32_t return_key_type;
Eina_Bool context_changed;
- Eina_Bool hw_kbd;
Eina_Bool return_key_disabled;
- WSCContextISF *wsc_ctx;
-};
-
-struct _WSCContextISF {
- weescim *ctx;
-
WSCContextISFImpl *impl;
int id; /* Input Context id*/
void get_language(char **language);
int get_panel_client_id ();
-Eina_Bool caps_mode_check (WSCContextISF *ctx, Eina_Bool force, Eina_Bool noti);
+Eina_Bool caps_mode_check (WSCContextISF *wsc_ctx, Eina_Bool force, Eina_Bool noti);
WSCContextISF *get_focused_ic ();
-void context_scim_imdata_get (WSCContextISF *ctx, void* data, int* length);
-void imengine_layout_set (WSCContextISF *ctx, Ecore_IMF_Input_Panel_Layout layout);
-
-void isf_wsc_context_add (WSCContextISF *ctx);
-void isf_wsc_context_del (WSCContextISF *ctx);
-void isf_wsc_context_focus_in (WSCContextISF *ctx);
-void isf_wsc_context_focus_out (WSCContextISF *ctx);
-void isf_wsc_context_reset (WSCContextISF *ctx);
-void isf_wsc_context_cursor_position_set (WSCContextISF *ctx, int cursor_pos);
-void isf_wsc_context_preedit_string_get (WSCContextISF *ctx, char** str, int *cursor_pos);
-void isf_wsc_context_prediction_allow_set (WSCContextISF* ctx, Eina_Bool prediction);
-Eina_Bool isf_wsc_context_prediction_allow_get (WSCContextISF* ctx);
-void isf_wsc_context_autocapital_type_set (WSCContextISF* ctx, Ecore_IMF_Autocapital_Type autocapital_type);
-void isf_wsc_context_filter_key_event (struct weescim *wsc,
+void context_scim_imdata_get (WSCContextISF *wsc_ctx, void* data, int* length);
+void imengine_layout_set (WSCContextISF *wsc_ctx, Ecore_IMF_Input_Panel_Layout layout);
+
+void isf_wsc_context_add (WSCContextISF *wsc_ctx);
+void isf_wsc_context_del (WSCContextISF *wsc_ctx);
+void isf_wsc_context_focus_in (WSCContextISF *wsc_ctx);
+void isf_wsc_context_focus_out (WSCContextISF *wsc_ctx);
+void isf_wsc_context_reset (WSCContextISF *wsc_ctx);
+void isf_wsc_context_cursor_position_set (WSCContextISF *wsc_ctx, int cursor_pos);
+void isf_wsc_context_preedit_string_get (WSCContextISF *wsc_ctx, char** str, int *cursor_pos);
+void isf_wsc_context_prediction_allow_set (WSCContextISF* wsc_ctx, Eina_Bool prediction);
+Eina_Bool isf_wsc_context_prediction_allow_get (WSCContextISF* wsc_ctx);
+void isf_wsc_context_autocapital_type_set (WSCContextISF* wsc_ctx, Ecore_IMF_Autocapital_Type autocapital_type);
+void isf_wsc_context_filter_key_event (WSCContextISF* wsc_ctx,
uint32_t serial,
uint32_t timestamp, uint32_t key, uint32_t unicode,
char *keyname,
enum wl_keyboard_key_state state);
-WSCContextISF* isf_wsc_context_new (void);
+void isf_wsc_context_init (void);
void isf_wsc_context_shutdown (void);
-bool wsc_context_surrounding_get (weescim *ctx, char **text, int *cursor_pos);
-Ecore_IMF_Input_Panel_Layout wsc_context_input_panel_layout_get(weescim *ctx);
-int wsc_context_input_panel_layout_variation_get (weescim *ctx);
-bool wsc_context_input_panel_caps_lock_mode_get(weescim *ctx);
-void wsc_context_delete_surrounding (weescim *ctx, int offset, int len);
-Ecore_IMF_Autocapital_Type wsc_context_autocapital_type_get (weescim *ctx);
-Ecore_IMF_Input_Panel_Lang wsc_context_input_panel_language_get (weescim *ctx);
-bool wsc_context_input_panel_password_mode_get (weescim *ctx);
-Ecore_IMF_Input_Hints wsc_context_input_hint_get (weescim *ctx);
-Eina_Bool wsc_context_prediction_allow_get (weescim *ctx);
-void wsc_context_commit_preedit_string(weescim *ctx);
-void wsc_context_commit_string(weescim *ctx, const char *str);
-void wsc_context_send_preedit_string(weescim *ctx);
-void wsc_context_send_key(weescim *ctx, uint32_t keysym, uint32_t modifiers, uint32_t time, bool press);
+bool wsc_context_surrounding_get (WSCContextISF *wsc_ctx, char **text, int *cursor_pos);
+Ecore_IMF_Input_Panel_Layout wsc_context_input_panel_layout_get(WSCContextISF *wsc_ctx);
+int wsc_context_input_panel_layout_variation_get (WSCContextISF *wsc_ctx);
+bool wsc_context_input_panel_caps_lock_mode_get(WSCContextISF *wsc_ctx);
+void wsc_context_delete_surrounding (WSCContextISF *wsc_ctx, int offset, int len);
+Ecore_IMF_Autocapital_Type wsc_context_autocapital_type_get (WSCContextISF *wsc_ctx);
+Ecore_IMF_Input_Panel_Lang wsc_context_input_panel_language_get (WSCContextISF *wsc_ctx);
+bool wsc_context_input_panel_password_mode_get (WSCContextISF *wsc_ctx);
+Ecore_IMF_Input_Hints wsc_context_input_hint_get (WSCContextISF *wsc_ctx);
+Eina_Bool wsc_context_prediction_allow_get (WSCContextISF *wsc_ctx);
+void wsc_context_commit_preedit_string(WSCContextISF *wsc_ctx);
+void wsc_context_commit_string(WSCContextISF *wsc_ctx, const char *str);
+void wsc_context_send_preedit_string(WSCContextISF *wsc_ctx);
+void wsc_context_send_key(WSCContextISF *wsc_ctx, uint32_t keysym, uint32_t modifiers, uint32_t time, bool press);
#endif /* __ISF_WSC_CONTEXT_H_ */
#include <malloc.h>
#include "scim_private.h"
#include "scim.h"
-#include "scim_stl_map.h"
#if HAVE_VCONF
#include <vconf.h>
#include <vconf-keys.h>
#include <text-client-protocol.h>
#include "isf_wsc_context.h"
#include "isf_wsc_control_ui.h"
-#include "scim_stl_map.h"
using namespace scim;
-#if SCIM_USE_STL_EXT_HASH_MAP
- typedef __gnu_cxx::hash_map <uint32_t, uint32_t, __gnu_cxx::hash <uint32_t> > KeycodeRepository;
-#elif SCIM_USE_STL_HASH_MAP
- typedef std::hash_map <uint32_t, ClientInfo, std::hash <uint32_t> > KeycodeRepository;
-#else
- typedef std::map <uint32_t, uint32_t> KeycodeRepository;
-#endif
-
-static KeycodeRepository _keysym2keycode;
-
/////////////////////////////////////////////////////////////////////////////
// Declaration of macro.
/////////////////////////////////////////////////////////////////////////////
#define LOG_TAG "ISF_WSC_EFL"
static struct weescim _wsc = {0};
+static int _context_count = 0;
+
/////////////////////////////////////////////////////////////////////////////
// Implementation of Wayland Input Method functions.
static void
_wsc_im_ctx_surrounding_text(void *data, struct wl_input_method_context *im_ctx, const char *text, uint32_t cursor, uint32_t anchor)
{
- struct weescim *wsc = (weescim*)data;
- if (!wsc) return;
+ WSCContextISF *wsc_ctx = (WSCContextISF*)data;
+ if (!wsc_ctx) return;
- if (wsc->surrounding_text)
- free (wsc->surrounding_text);
+ if (wsc_ctx->surrounding_text)
+ free (wsc_ctx->surrounding_text);
- wsc->surrounding_text = strdup (text ? text : "");
- wsc->surrounding_cursor = cursor;
+ wsc_ctx->surrounding_text = strdup (text ? text : "");
+ wsc_ctx->surrounding_cursor = cursor;
- isf_wsc_context_cursor_position_set(wsc->wsc_ctx, cursor);
+ isf_wsc_context_cursor_position_set(wsc_ctx, cursor);
LOGD ("text : '%s', cursor : %d\n", text, cursor);
}
static void
_wsc_im_ctx_reset(void *data, struct wl_input_method_context *im_ctx)
{
- struct weescim *wsc = (weescim*)data;
- if (!wsc || !wsc->wsc_ctx) return;
-
- isf_wsc_context_reset(wsc->wsc_ctx);
+ WSCContextISF *wsc_ctx = (WSCContextISF*)data;
+ if (!wsc_ctx) return;
+ isf_wsc_context_reset(wsc_ctx);
}
static void
_wsc_im_ctx_content_type(void *data, struct wl_input_method_context *im_ctx, uint32_t hint, uint32_t purpose)
{
- struct weescim *wsc = (weescim*)data;
+ WSCContextISF *wsc_ctx = (WSCContextISF*)data;
+ if (!wsc_ctx) return;
LOGD ("im_context = %p hint = %d purpose = %d\n", im_ctx, hint, purpose);
- if (!wsc || !wsc->context_changed)
- return;
+ if (!wsc_ctx->context_changed) return;
- wsc->content_hint = hint;
- wsc->content_purpose = purpose;
+ wsc_ctx->content_hint = hint;
+ wsc_ctx->content_purpose = purpose;
- if (wsc->wsc_ctx) {
- isf_wsc_context_input_panel_layout_set (wsc->wsc_ctx,
- wsc_context_input_panel_layout_get (wsc));
+ isf_wsc_context_input_panel_layout_set (wsc_ctx,
+ wsc_context_input_panel_layout_get (wsc_ctx));
- isf_wsc_context_autocapital_type_set (wsc->wsc_ctx, wsc_context_autocapital_type_get(wsc));
+ isf_wsc_context_autocapital_type_set (wsc_ctx, wsc_context_autocapital_type_get(wsc_ctx));
- isf_wsc_context_input_panel_language_set (wsc->wsc_ctx, wsc_context_input_panel_language_get(wsc));
+ isf_wsc_context_input_panel_language_set (wsc_ctx, wsc_context_input_panel_language_get(wsc_ctx));
- caps_mode_check (wsc->wsc_ctx, EINA_TRUE, EINA_TRUE);
+ caps_mode_check (wsc_ctx, EINA_TRUE, EINA_TRUE);
- wsc->context_changed = EINA_FALSE;
- }
+ wsc_ctx->context_changed = EINA_FALSE;
}
static void
_wsc_im_ctx_invoke_action(void *data, struct wl_input_method_context *im_ctx, uint32_t button, uint32_t index)
{
- struct weescim *wsc = (weescim*)data;
- if (!wsc) return;
+ WSCContextISF *wsc_ctx = (WSCContextISF*)data;
+ if (!wsc_ctx) return;
LOGD ("invoke action. button : %d\n", button);
if (button != BTN_LEFT)
return;
- wsc_context_send_preedit_string (wsc);
+ wsc_context_send_preedit_string (wsc_ctx);
}
static void
_wsc_im_ctx_commit_state(void *data, struct wl_input_method_context *im_ctx, uint32_t serial)
{
- struct weescim *wsc = (weescim*)data;
- if (!wsc) return;
+ WSCContextISF *wsc_ctx = (WSCContextISF*)data;
+ if (!wsc_ctx) return;
- wsc->serial = serial;
+ wsc_ctx->serial = serial;
- if (wsc->surrounding_text)
- LOGD ("Surrounding text updated: '%s'\n", wsc->surrounding_text);
+ if (wsc_ctx->surrounding_text)
+ LOGD ("Surrounding text updated: '%s'\n", wsc_ctx->surrounding_text);
- if (wsc->language)
- wl_input_method_context_language (im_ctx, wsc->serial, wsc->language);
+ if (wsc_ctx->language)
+ wl_input_method_context_language (im_ctx, wsc_ctx->serial, wsc_ctx->language);
- wl_input_method_context_text_direction (im_ctx, wsc->serial, wsc->text_direction);
+ wl_input_method_context_text_direction (im_ctx, wsc_ctx->serial, wsc_ctx->text_direction);
}
static void
_wsc_im_ctx_preferred_language(void *data, struct wl_input_method_context *im_ctx, const char *language)
{
- struct weescim *wsc = (weescim*)data;
- if (!wsc) return;
+ WSCContextISF *wsc_ctx = (WSCContextISF*)data;
+ if (!wsc_ctx) return;
- if (language && wsc->language && !strcmp (language, wsc->language))
+ if (language && wsc_ctx->language && !strcmp (language, wsc_ctx->language))
return;
- if (wsc->language) {
- free (wsc->language);
- wsc->language = NULL;
+ if (wsc_ctx->language) {
+ free (wsc_ctx->language);
+ wsc_ctx->language = NULL;
}
if (language) {
- wsc->language = strdup (language);
+ wsc_ctx->language = strdup (language);
LOGD ("Language changed, new: '%s'\n", language);
}
}
static void
_wsc_im_ctx_return_key_type(void *data, struct wl_input_method_context *im_ctx, uint32_t return_key_type)
{
- struct weescim *wsc = (weescim*)data;
+ WSCContextISF *wsc_ctx = (WSCContextISF*)data;
LOGD ("im_context = %p return key type = %d\n", im_ctx, return_key_type);
- if (!wsc || !wsc->wsc_ctx) return;
+ if (!wsc_ctx) return;
- if (wsc->return_key_type != return_key_type) {
- wsc->return_key_type = return_key_type;
- isf_wsc_context_input_panel_return_key_type_set (wsc->wsc_ctx, (Ecore_IMF_Input_Panel_Return_Key_Type)wsc->return_key_type);
+ if (wsc_ctx->return_key_type != return_key_type) {
+ wsc_ctx->return_key_type = return_key_type;
+ isf_wsc_context_input_panel_return_key_type_set (wsc_ctx, (Ecore_IMF_Input_Panel_Return_Key_Type)wsc_ctx->return_key_type);
}
}
static void
_wsc_im_ctx_return_key_disabled(void *data, struct wl_input_method_context *im_ctx, uint32_t disabled)
{
- struct weescim *wsc = (weescim*)data;
+ WSCContextISF *wsc_ctx = (WSCContextISF*)data;
Eina_Bool return_key_disabled = !!disabled;
LOGD ("im_context = %p return key disabled = %d\n", im_ctx, return_key_disabled);
- if (!wsc || !wsc->wsc_ctx) return;
+ if (!wsc_ctx) return;
- if (wsc->return_key_disabled != return_key_disabled) {
- wsc->return_key_disabled = return_key_disabled;
- isf_wsc_context_input_panel_return_key_disabled_set (wsc->wsc_ctx, wsc->return_key_disabled);
+ if (wsc_ctx->return_key_disabled != return_key_disabled) {
+ wsc_ctx->return_key_disabled = return_key_disabled;
+ isf_wsc_context_input_panel_return_key_disabled_set (wsc_ctx, wsc_ctx->return_key_disabled);
}
}
static void
_wsc_im_ctx_input_panel_data(void *data, struct wl_input_method_context *im_ctx, const char *input_panel_data, uint32_t input_panel_data_length)
{
- struct weescim *wsc = (weescim*)data;
+ WSCContextISF *wsc_ctx = (WSCContextISF*)data;
LOGD ("im_context = %p input panel data = %s len = %d\n", im_ctx, input_panel_data, input_panel_data_length);
- if (!wsc || !wsc->wsc_ctx) return;
+ if (!wsc_ctx) return;
- isf_wsc_context_input_panel_imdata_set (wsc->wsc_ctx, (void *)input_panel_data, input_panel_data_length);
+ isf_wsc_context_input_panel_imdata_set (wsc_ctx, (void *)input_panel_data, input_panel_data_length);
}
static const struct wl_input_method_context_listener wsc_im_context_listener = {
};
static void
-_init_keysym2keycode(struct weescim *wsc)
+_init_keysym2keycode(WSCContextISF *wsc_ctx)
{
uint32_t i = 0;
uint32_t code;
uint32_t num_syms;
const xkb_keysym_t *syms;
- if (!wsc || !wsc->state)
+ if (!wsc_ctx || !wsc_ctx->state)
return;
for (i = 0; i < 256; i++) {
code = i + 8;
- num_syms = xkb_key_get_syms(wsc->state, code, &syms);
+ num_syms = xkb_key_get_syms(wsc_ctx->state, code, &syms);
if (num_syms == 1)
- _keysym2keycode[syms[0]] = i;
+ wsc_ctx->_keysym2keycode[syms[0]] = i;
}
}
static void
-_fini_keysym2keycode(struct weescim *wsc)
+_fini_keysym2keycode(WSCContextISF *wsc_ctx)
{
- _keysym2keycode.clear();
+ wsc_ctx->_keysym2keycode.clear();
}
static void
int32_t fd,
uint32_t size)
{
- struct weescim *wsc = (weescim*)data;
+ WSCContextISF *wsc_ctx = (WSCContextISF*)data;
char *map_str;
- if (!wsc) return;
+ if (!wsc_ctx) return;
- _fini_keysym2keycode(wsc);
+ _fini_keysym2keycode(wsc_ctx);
- if (wsc->state) {
- xkb_state_unref(wsc->state);
- wsc->state = NULL;
+ if (wsc_ctx->state) {
+ xkb_state_unref(wsc_ctx->state);
+ wsc_ctx->state = NULL;
}
- if (wsc->keymap) {
- xkb_map_unref(wsc->keymap);
- wsc->keymap = NULL;
+ if (wsc_ctx->keymap) {
+ xkb_map_unref(wsc_ctx->keymap);
+ wsc_ctx->keymap = NULL;
}
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
return;
}
- wsc->keymap =
- xkb_map_new_from_string(wsc->xkb_context,
+ wsc_ctx->keymap =
+ xkb_map_new_from_string(wsc_ctx->xkb_context,
map_str,
XKB_KEYMAP_FORMAT_TEXT_V1,
(xkb_keymap_compile_flags)0);
munmap(map_str, size);
close(fd);
- if (!wsc->keymap) {
+ if (!wsc_ctx->keymap) {
LOGW ("failed to compile keymap\n");
return;
}
- wsc->state = xkb_state_new(wsc->keymap);
- if (!wsc->state) {
+ wsc_ctx->state = xkb_state_new(wsc_ctx->keymap);
+ if (!wsc_ctx->state) {
LOGW ("failed to create XKB state\n");
- xkb_map_unref(wsc->keymap);
+ xkb_map_unref(wsc_ctx->keymap);
return;
}
- wsc->control_mask =
- 1 << xkb_map_mod_get_index(wsc->keymap, "Control");
- wsc->alt_mask =
- 1 << xkb_map_mod_get_index(wsc->keymap, "Mod1");
- wsc->shift_mask =
- 1 << xkb_map_mod_get_index(wsc->keymap, "Shift");
+ wsc_ctx->control_mask =
+ 1 << xkb_map_mod_get_index(wsc_ctx->keymap, "Control");
+ wsc_ctx->alt_mask =
+ 1 << xkb_map_mod_get_index(wsc_ctx->keymap, "Mod1");
+ wsc_ctx->shift_mask =
+ 1 << xkb_map_mod_get_index(wsc_ctx->keymap, "Shift");
LOGW ("create _keysym2keycode\n");
- _init_keysym2keycode(wsc);
+ _init_keysym2keycode(wsc_ctx);
}
static void
uint32_t key,
uint32_t state_w)
{
- struct weescim *wsc = (weescim*)data;
+ WSCContextISF *wsc_ctx = (WSCContextISF*)data;
uint32_t code;
uint32_t num_syms;
const xkb_keysym_t *syms;
char keyname[64] = {0};
enum wl_keyboard_key_state state = (wl_keyboard_key_state)state_w;
- if (!wsc || !wsc->state)
+ if (!wsc_ctx || !wsc_ctx->state)
return;
code = key + 8;
- num_syms = xkb_key_get_syms(wsc->state, code, &syms);
+ num_syms = xkb_key_get_syms(wsc_ctx->state, code, &syms);
sym = XKB_KEY_NoSymbol;
if (num_syms == 1)
xkb_keysym_get_name(sym, keyname, 64);
}
- if (wsc->key_handler)
- (*wsc->key_handler)(wsc, serial, time, code, sym, keyname,
+ if (wsc_ctx->key_handler)
+ (*wsc_ctx->key_handler)(wsc_ctx, serial, time, code, sym, keyname,
state);
}
uint32_t mods_locked,
uint32_t group)
{
- struct weescim *wsc = (weescim*)data;
- struct wl_input_method_context *context = wsc->im_ctx;
+ WSCContextISF *wsc_ctx = (WSCContextISF*)data;
+ struct wl_input_method_context *context = wsc_ctx->im_ctx;
xkb_mod_mask_t mask;
- if (!wsc || !wsc->state)
+ if (!wsc_ctx || !wsc_ctx->state)
return;
- xkb_state_update_mask(wsc->state, mods_depressed,
+ xkb_state_update_mask(wsc_ctx->state, mods_depressed,
mods_latched, mods_locked, 0, 0, group);
- mask = xkb_state_serialize_mods(wsc->state,
+ mask = xkb_state_serialize_mods(wsc_ctx->state,
(xkb_state_component)(XKB_STATE_DEPRESSED | XKB_STATE_LATCHED));
- wsc->modifiers = 0;
- if (mask & wsc->control_mask)
- wsc->modifiers |= SCIM_KEY_ControlMask;
- if (mask & wsc->alt_mask)
- wsc->modifiers |= SCIM_KEY_AltMask;
- if (mask & wsc->shift_mask)
- wsc->modifiers |= SCIM_KEY_ShiftMask;
+ wsc_ctx->modifiers = 0;
+ if (mask & wsc_ctx->control_mask)
+ wsc_ctx->modifiers |= SCIM_KEY_ControlMask;
+ if (mask & wsc_ctx->alt_mask)
+ wsc_ctx->modifiers |= SCIM_KEY_AltMask;
+ if (mask & wsc_ctx->shift_mask)
+ wsc_ctx->modifiers |= SCIM_KEY_ShiftMask;
wl_input_method_context_modifiers(context, serial,
mods_depressed, mods_depressed,
struct weescim *wsc = (weescim*)data;
if (!wsc) return;
- if (wsc->im_ctx)
- wl_input_method_context_destroy (wsc->im_ctx);
+ WSCContextISF *wsc_ctx = new WSCContextISF;
+ if (!wsc_ctx) {
+ return;
+ }
+ wsc_ctx->xkb_context = xkb_context_new((xkb_context_flags)0);
+ if (wsc_ctx->xkb_context == NULL) {
+ LOGW ("Failed to create XKB context\n");
+ delete wsc_ctx;
+ return;
+ }
+ if (_context_count == 0) {
+ _context_count = getpid () % 50000;
+ }
+ wsc_ctx->id = _context_count++;
+ wsc->wsc_ctx = wsc_ctx;
+ wsc_ctx->ctx = wsc;
+ wsc_ctx->state = NULL;
+ wsc_ctx->keymap = NULL;
+ wsc_ctx->surrounding_text = NULL;
+ wsc_ctx->key_handler = isf_wsc_context_filter_key_event;
- if (wsc->preedit_str)
- free (wsc->preedit_str);
+ get_language(&wsc_ctx->language);
- wsc->preedit_str = strdup ("");
- wsc->content_hint = WL_TEXT_INPUT_CONTENT_HINT_NONE;
- wsc->content_purpose = WL_TEXT_INPUT_CONTENT_PURPOSE_NORMAL;
+ wsc_ctx->preedit_str = strdup ("");
+ wsc_ctx->content_hint = WL_TEXT_INPUT_CONTENT_HINT_NONE;
+ wsc_ctx->content_purpose = WL_TEXT_INPUT_CONTENT_PURPOSE_NORMAL;
- if (wsc->language) {
- free (wsc->language);
- wsc->language = NULL;
- }
+ wsc_ctx->im_ctx = im_ctx;
+ wl_input_method_context_add_listener (im_ctx, &wsc_im_context_listener, wsc_ctx);
- if (wsc->surrounding_text) {
- free (wsc->surrounding_text);
- wsc->surrounding_text = NULL;
- }
+ wsc_ctx->keyboard = wl_input_method_context_grab_keyboard(im_ctx);
+ if (wsc_ctx->keyboard)
+ wl_keyboard_add_listener(wsc_ctx->keyboard, &wsc_im_keyboard_listener, wsc_ctx);
- wsc->im_ctx = im_ctx;
- wl_input_method_context_add_listener (im_ctx, &wsc_im_context_listener, wsc);
+ if (wsc_ctx->language)
+ wl_input_method_context_language (im_ctx, wsc_ctx->serial, wsc_ctx->language);
- wsc->keyboard = wl_input_method_context_grab_keyboard(im_ctx);
- if (wsc->keyboard)
- wl_keyboard_add_listener(wsc->keyboard, &wsc_im_keyboard_listener, wsc);
+ wl_input_method_context_text_direction (im_ctx, wsc_ctx->serial, wsc_ctx->text_direction);
- if (wsc->language)
- wl_input_method_context_language (im_ctx, wsc->serial, wsc->language);
+ isf_wsc_context_add (wsc_ctx);
- wl_input_method_context_text_direction (im_ctx, wsc->serial, wsc->text_direction);
+ wsc_ctx->context_changed = EINA_TRUE;
- wsc->context_changed = EINA_TRUE;
- isf_wsc_context_focus_in (wsc->wsc_ctx);
+ isf_wsc_context_focus_in (wsc_ctx);
}
static void
_wsc_im_deactivate(void *data, struct wl_input_method *input_method, struct wl_input_method_context *im_ctx)
{
struct weescim *wsc = (weescim*)data;
- if (!wsc) return;
+ if (!wsc || !wsc->wsc_ctx) return;
+ WSCContextISF *wsc_ctx = wsc->wsc_ctx;
+
+ isf_wsc_context_input_panel_hide (wsc_ctx);
+ isf_wsc_context_focus_out (wsc_ctx);
+
+ if (wsc_ctx->keyboard) {
+ wl_keyboard_destroy (wsc_ctx->keyboard);
+ wsc_ctx->keyboard = NULL;
+ }
+
+ _fini_keysym2keycode (wsc_ctx);
+
+ if (wsc_ctx->state) {
+ xkb_state_unref (wsc_ctx->state);
+ wsc_ctx->state = NULL;
+ }
+
+ if (wsc_ctx->keymap) {
+ xkb_map_unref (wsc_ctx->keymap);
+ wsc_ctx->keymap = NULL;
+ }
- if (wsc->wsc_ctx) {
- isf_wsc_context_input_panel_hide (wsc->wsc_ctx);
- isf_wsc_context_focus_out (wsc->wsc_ctx);
+ if (wsc_ctx->im_ctx) {
+ wl_input_method_context_destroy (wsc_ctx->im_ctx);
+ wsc_ctx->im_ctx = NULL;
}
- if (wsc->im_ctx) {
- wl_input_method_context_destroy(wsc->im_ctx);
- wsc->im_ctx = NULL;
+ if (wsc_ctx->preedit_str) {
+ free (wsc_ctx->preedit_str);
+ wsc_ctx->preedit_str = NULL;
}
+
+ if (wsc_ctx->surrounding_text) {
+ free (wsc_ctx->surrounding_text);
+ wsc_ctx->surrounding_text = NULL;
+ }
+
+ if (wsc_ctx->language) {
+ free (wsc_ctx->language);
+ wsc_ctx->language = NULL;
+ }
+
+ isf_wsc_context_del (wsc_ctx);
+ delete wsc_ctx;
+ wsc->wsc_ctx = NULL;
+
}
static void
_wsc_im_show_input_panel(void *data, struct wl_input_method *input_method, struct wl_input_method_context *im_ctx)
{
struct weescim *wsc = (weescim*)data;
- if (!wsc) return;
+ if (!wsc || !wsc->wsc_ctx) return;
- if (wsc->wsc_ctx)
- isf_wsc_context_input_panel_show (wsc->wsc_ctx);
+ isf_wsc_context_input_panel_show (wsc->wsc_ctx);
}
static void
_wsc_im_hide_input_panel(void *data, struct wl_input_method *input_method, struct wl_input_method_context *im_ctx)
{
struct weescim *wsc = (weescim*)data;
- if (!wsc) return;
+ if (!wsc || !wsc->wsc_ctx) return;
- if (wsc->wsc_ctx)
- isf_wsc_context_input_panel_hide (wsc->wsc_ctx);
+ isf_wsc_context_input_panel_hide (wsc->wsc_ctx);
}
static const struct wl_input_method_listener wsc_im_listener = {
if (!wsc) return;
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD)) {
- wsc->hw_kbd = true;
+
} else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD)) {
- wsc->hw_kbd = false;
+
}
}
if (!wsc) return false;
- wsc->xkb_context = xkb_context_new((xkb_context_flags)0);
- if (wsc->xkb_context == NULL) {
- LOGW ("Failed to create XKB context\n");
- return false;
- }
-
- wsc->key_handler = isf_wsc_context_filter_key_event;
-
- wsc->wsc_ctx = isf_wsc_context_new ();
- if (!wsc->wsc_ctx) return false;
-
- wsc->wsc_ctx->ctx = wsc;
-
- get_language(&wsc->language);
-
if (!(registry = ecore_wl_registry_get()))
return false;
return false;
}
- isf_wsc_context_add (wsc->wsc_ctx);
-
return true;
}
-static void
-_wsc_free (struct weescim *wsc)
-{
- if (!wsc) return;
-
- _fini_keysym2keycode (wsc);
-
- if (wsc->state) {
- xkb_state_unref (wsc->state);
- wsc->state = NULL;
- }
-
- if (wsc->keymap) {
- xkb_map_unref (wsc->keymap);
- wsc->keymap = NULL;
- }
-
- if (wsc->im_ctx) {
- wl_input_method_context_destroy (wsc->im_ctx);
- wsc->im_ctx = NULL;
- }
-
- if (wsc->wsc_ctx) {
- isf_wsc_context_del (wsc->wsc_ctx);
- wsc->wsc_ctx = NULL;
- }
-
- if (wsc->preedit_str) {
- free (wsc->preedit_str);
- wsc->preedit_str = NULL;
- }
-
- if (wsc->surrounding_text) {
- free (wsc->surrounding_text);
- wsc->surrounding_text = NULL;
- }
-
- if (wsc->language) {
- free (wsc->language);
- wsc->language = NULL;
- }
-
- isf_wsc_context_shutdown ();
-}
-
int main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
sleep(1);
+ isf_wsc_context_init ();
+
if (!_wsc_setup (&_wsc)) {
- _wsc_free (&_wsc);
return 0;
}
ecore_main_loop_begin();
- _wsc_free (&_wsc);
+ isf_wsc_context_shutdown ();
return 0;
}