summaryrefslogtreecommitdiff
path: root/src/modules/ecore_imf
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-11-07 11:21:27 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-11-09 11:43:59 +0000
commitb279ff77ccfa4d41262af07de2e4581f1aac3b7e (patch)
tree149e4b1979bd65ca278d71d5823571c6d03dde39 /src/modules/ecore_imf
parentb4f9021e55a6d5fa4a78474c3a505b1170d08132 (diff)
downloadefl-b279ff77ccfa4d41262af07de2e4581f1aac3b7e.tar.gz
ecore imf modules - check ecore x display state beofre doing x things
using an uninitted x display is not good/useful so ... don't do it. leads to crashes.
Diffstat (limited to 'src/modules/ecore_imf')
-rw-r--r--src/modules/ecore_imf/ibus/ibus_imcontext.c9
-rw-r--r--src/modules/ecore_imf/scim/scim_imcontext.cpp7
-rw-r--r--src/modules/ecore_imf/xim/ecore_imf_xim.c62
3 files changed, 52 insertions, 26 deletions
diff --git a/src/modules/ecore_imf/ibus/ibus_imcontext.c b/src/modules/ecore_imf/ibus/ibus_imcontext.c
index 753f3b76ca..4521e52a65 100644
--- a/src/modules/ecore_imf/ibus/ibus_imcontext.c
+++ b/src/modules/ecore_imf/ibus/ibus_imcontext.c
@@ -103,6 +103,8 @@ _ecore_imf_ibus_window_to_screen_geometry_get(Ecore_X_Window client_win,
int win_x, win_y;
int sum_x = 0, sum_y = 0;
+ if (!ecore_x_display_get()) goto end;
+
root_window = ecore_x_window_root_get(client_win);
win = client_win;
@@ -114,6 +116,7 @@ _ecore_imf_ibus_window_to_screen_geometry_get(Ecore_X_Window client_win,
win = ecore_x_window_parent_get(win);
}
+end:
if (x)
*x = sum_x;
if (y)
@@ -171,6 +174,7 @@ _ecore_imf_ibus_key_event_put(int keysym, int keycode, int state)
Window winFocus = 0;
int revert = RevertToParent;
+ if (!ecore_x_display_get()) return;
XGetInputFocus(ecore_x_display_get(), &winFocus, &revert);
XKeyEvent event;
@@ -393,6 +397,7 @@ ecore_imf_context_ibus_filter_event(Ecore_IMF_Context *ctx,
IBusIMContext *ibusimcontext = (IBusIMContext*)ecore_imf_context_data_get(ctx);
EINA_SAFETY_ON_NULL_RETURN_VAL(ibusimcontext, EINA_FALSE);
+ if (!ecore_x_display_get()) return EINA_FALSE;
if (type != ECORE_IMF_EVENT_KEY_UP && type != ECORE_IMF_EVENT_KEY_DOWN)
return EINA_FALSE;
@@ -744,7 +749,7 @@ static XKeyEvent _ecore_imf_ibus_x_key_event_generate(Window win,
event.display = display;
event.window = win;
- event.root = ecore_x_window_root_get(win);
+ event.root = display ? ecore_x_window_root_get(win) : 0;
event.subwindow = None;
event.time = 0;
event.x = 1;
@@ -754,7 +759,7 @@ static XKeyEvent _ecore_imf_ibus_x_key_event_generate(Window win,
event.same_screen = EINA_TRUE;
if (keycode == -1)
{
- event.keycode = XKeysymToKeycode(display, keysym);
+ event.keycode = display ? XKeysymToKeycode(display, keysym) : 0;
event.state = 0;
}
else
diff --git a/src/modules/ecore_imf/scim/scim_imcontext.cpp b/src/modules/ecore_imf/scim/scim_imcontext.cpp
index fcdb2088b5..404f880d17 100644
--- a/src/modules/ecore_imf/scim/scim_imcontext.cpp
+++ b/src/modules/ecore_imf/scim/scim_imcontext.cpp
@@ -386,6 +386,8 @@ window_to_screen_geometry_get(Ecore_X_Window client_win, int *x, int *y)
int win_x, win_y;
int sum_x = 0, sum_y = 0;
+ if (!ecore_x_display_get()) goto end;
+
root_window = ecore_x_window_root_get(client_win);
win = client_win;
@@ -397,6 +399,7 @@ window_to_screen_geometry_get(Ecore_X_Window client_win, int *x, int *y)
win = ecore_x_window_parent_get(win);
}
+end:
if (x)
*x = sum_x;
if (y)
@@ -1316,6 +1319,7 @@ isf_imf_context_input_panel_show(Ecore_IMF_Context *ctx)
EINA_SAFETY_ON_NULL_RETURN(context_scim);
EINA_SAFETY_ON_NULL_RETURN(context_scim->impl);
+ if (!ecore_x_display_get()) return;
ecore_x_e_virtual_keyboard_state_set
(context_scim->impl->client_window, ECORE_X_VIRTUAL_KEYBOARD_STATE_ON);
}
@@ -1329,6 +1333,7 @@ isf_imf_context_input_panel_hide(Ecore_IMF_Context *ctx)
EINA_SAFETY_ON_NULL_RETURN(context_scim);
EINA_SAFETY_ON_NULL_RETURN(context_scim->impl);
+ if (!ecore_x_display_get()) return;
ecore_x_e_virtual_keyboard_state_set
(context_scim->impl->client_window, ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF);
}
@@ -1459,6 +1464,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 (!ecore_x_display_get()) return;
if (key.is_key_press())
ecore_x_test_fake_key_press(key.get_key_string().c_str());
}
@@ -2663,6 +2669,7 @@ slot_beep(IMEngineInstanceBase *si)
EcoreIMFContextISF *ic = static_cast<EcoreIMFContextISF *>(si->get_frontend_data());
EINA_SAFETY_ON_NULL_RETURN(ic);
+ if (!ecore_x_display_get()) return;
if (_focused_ic == ic)
ecore_x_bell(0);
}
diff --git a/src/modules/ecore_imf/xim/ecore_imf_xim.c b/src/modules/ecore_imf/xim/ecore_imf_xim.c
index 30129a5274..606a793058 100644
--- a/src/modules/ecore_imf/xim/ecore_imf_xim.c
+++ b/src/modules/ecore_imf/xim/ecore_imf_xim.c
@@ -172,19 +172,23 @@ _ecore_imf_context_xim_del(Ecore_IMF_Context *ctx)
{
Ecore_X_Display *dsp;
dsp = ecore_x_display_get();
- XUnregisterIMInstantiateCallback(dsp,
- NULL, NULL, NULL,
- _ecore_imf_xim_instantiate_cb,
- (XPointer)imf_context_data->im_info);
+ if (dsp)
+ XUnregisterIMInstantiateCallback(dsp,
+ NULL, NULL, NULL,
+ _ecore_imf_xim_instantiate_cb,
+ (XPointer)imf_context_data->im_info);
}
else if (imf_context_data->im_info->im)
{
- XIMCallback im_destroy_callback;
- im_destroy_callback.client_data = NULL;
- im_destroy_callback.callback = NULL;
- XSetIMValues(imf_context_data->im_info->im,
- XNDestroyCallback, &im_destroy_callback,
- NULL);
+ if (ecore_x_display_get())
+ {
+ XIMCallback im_destroy_callback;
+ im_destroy_callback.client_data = NULL;
+ im_destroy_callback.callback = NULL;
+ XSetIMValues(imf_context_data->im_info->im,
+ XNDestroyCallback, &im_destroy_callback,
+ NULL);
+ }
}
}
@@ -481,6 +485,7 @@ _ecore_imf_context_xim_input_panel_show(Ecore_IMF_Context *ctx)
DBG("ctx=%p, imf_context_data=%p", ctx, imf_context_data);
EINA_SAFETY_ON_NULL_RETURN(imf_context_data);
+ if (!ecore_x_display_get()) return;
ecore_x_e_virtual_keyboard_state_set
(imf_context_data->win, ECORE_X_VIRTUAL_KEYBOARD_STATE_ON);
}
@@ -492,6 +497,7 @@ _ecore_imf_context_xim_input_panel_hide(Ecore_IMF_Context *ctx)
DBG("ctx=%p, imf_context_data=%p", ctx, imf_context_data);
EINA_SAFETY_ON_NULL_RETURN(imf_context_data);
+ if (!ecore_x_display_get()) return;
ecore_x_e_virtual_keyboard_state_set
(imf_context_data->win, ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF);
}
@@ -595,15 +601,18 @@ _ecore_imf_context_xim_filter_event(Ecore_IMF_Context *ctx,
xev.send_event = 0;
xev.display = dsp;
xev.window = win;
- xev.root = ecore_x_window_root_get(win);
+ xev.root = dsp ? ecore_x_window_root_get(win) : 0;
xev.subwindow = win;
xev.time = ev->timestamp;
xev.x = xev.x_root = 0;
xev.y = xev.y_root = 0;
xev.state = 0;
- xev.state |= _ecore_x_event_reverse_modifiers(ev->modifiers);
- xev.state |= _ecore_x_event_reverse_locks(ev->locks);
- xev.keycode = _ecore_imf_xim_keycode_get(dsp, ev->keyname);
+ if (dsp)
+ {
+ xev.state |= _ecore_x_event_reverse_modifiers(ev->modifiers);
+ xev.state |= _ecore_x_event_reverse_locks(ev->locks);
+ xev.keycode = _ecore_imf_xim_keycode_get(dsp, ev->keyname);
+ }
xev.same_screen = True;
if (ic)
@@ -791,7 +800,8 @@ _ecore_imf_xim_shutdown(void)
XIM_Im_Info *info = open_ims->data;
Ecore_X_Display *display = ecore_x_display_get();
- _ecore_imf_xim_info_im_shutdown(display, EINA_FALSE, info);
+ if (display)
+ _ecore_imf_xim_info_im_shutdown(display, EINA_FALSE, info);
}
if (_ecore_imf_xim_log_dom >= 0)
@@ -1103,6 +1113,7 @@ _ecore_imf_xim_ic_get(Ecore_IMF_Context *ctx)
imf_context_data = ecore_imf_context_data_get(ctx);
EINA_SAFETY_ON_NULL_RETURN_VAL(imf_context_data, NULL);
+ if (!ecore_x_display_get()) return NULL;
ic = imf_context_data->ic;
if (!ic)
{
@@ -1341,17 +1352,20 @@ _ecore_imf_xim_info_im_init(XIM_Im_Info *info)
if (!XSetLocaleModifiers(""))
WRN("Unable to set locale modifiers with XSetLocaleModifiers()");
dsp = ecore_x_display_get();
- info->im = XOpenIM(dsp, NULL, NULL, NULL);
- if (!info->im)
+ if (dsp)
{
- XRegisterIMInstantiateCallback(dsp,
- NULL, NULL, NULL,
- _ecore_imf_xim_instantiate_cb,
- (XPointer)info);
- info->reconnecting = EINA_TRUE;
- return;
+ info->im = XOpenIM(dsp, NULL, NULL, NULL);
+ if (!info->im)
+ {
+ XRegisterIMInstantiateCallback(dsp,
+ NULL, NULL, NULL,
+ _ecore_imf_xim_instantiate_cb,
+ (XPointer)info);
+ info->reconnecting = EINA_TRUE;
+ return;
+ }
+ _ecore_imf_xim_im_setup(info);
}
- _ecore_imf_xim_im_setup(info);
}
}