summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorgeequlim <geequlim@gmail.com>2017-06-25 23:50:45 +0800
committergeequlim <geequlim@gmail.com>2017-07-11 18:36:20 +0800
commit7358766ff69e064d8a31b18c54e3c1e22e303cb6 (patch)
treee68eeea815da389c2fc36c878a745135499824c6 /platform
parenta5d500f0233913fe7622434225c5dc73ebaccd1e (diff)
IME window follow the input cursor.
Abstruct set_ime_position to OS class. Update ime position for LineEdit and TextEdit.
Diffstat (limited to 'platform')
-rw-r--r--platform/x11/os_x11.cpp21
-rw-r--r--platform/x11/os_x11.h2
2 files changed, 9 insertions, 14 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 790182794e..4aca1468b1 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -508,22 +508,17 @@ void OS_X11::xim_destroy_callback(::XIM im, ::XPointer client_data,
os->xic = NULL;
}
-void OS_X11::set_ime_position(short x, short y) {
+void OS_X11::set_ime_position(const Point2 &p_pos) {
- if (!xic) {
+ if (!xic)
return;
- }
+
::XPoint spot;
- spot.x = x;
- spot.y = y;
- XVaNestedList preedit_attr = XVaCreateNestedList(0,
- XNSpotLocation, &spot,
- NULL);
- XSetICValues(xic,
- XNPreeditAttributes, preedit_attr,
- NULL);
+ spot.x = short(p_pos.x);
+ spot.y = short(p_pos.y);
+ XVaNestedList preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
+ XSetICValues(xic, XNPreeditAttributes, preedit_attr, NULL);
XFree(preedit_attr);
- return;
}
void OS_X11::finalize() {
@@ -1489,7 +1484,7 @@ void OS_X11::process_xevents() {
case ConfigureNotify:
if (xic) {
// Not portable.
- set_ime_position(0, 1);
+ set_ime_position(Point2(0, 1));
}
/* call resizeGLScene only if our window-size changed */
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 39c512b6bd..12e4bbb086 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -115,7 +115,6 @@ class OS_X11 : public OS_Unix {
::XIMStyle xim_style;
static void xim_destroy_callback(::XIM im, ::XPointer client_data,
::XPointer call_data);
- void set_ime_position(short x, short y);
Point2i last_mouse_pos;
bool last_mouse_pos_valid;
@@ -253,6 +252,7 @@ public:
virtual void set_borderless_window(int p_borderless);
virtual bool get_borderless_window();
+ virtual void set_ime_position(const Point2 &p_pos);
virtual void move_window_to_foreground();
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");