Nux

Merge lp:~brandontschaefer/nux/xim-preedit-support into lp:nux

Proposed by Brandon Schaefer
Status: Merged
Approved by: Christopher Townsend
Approved revision: 840
Merged at revision: 833
Proposed branch: lp:~brandontschaefer/nux/xim-preedit-support
Merge into: lp:nux
Diff against target: 1203 lines (+584/-103)
17 files modified
Nux/MainLoopGLib.cpp (+7/-4)
Nux/Makefile.am (+8/-3)
Nux/TextEntry.cpp (+31/-2)
Nux/TextEntry.h (+5/-0)
Nux/WindowThread.cpp (+37/-1)
Nux/WindowThread.h (+15/-0)
Nux/XICClient.cpp (+226/-20)
Nux/XICClient.h (+25/-3)
Nux/XIMCallbacks.cpp (+189/-0)
Nux/XIMController.cpp (+14/-5)
Nux/XIMController.h (+3/-1)
NuxGraphics/GraphicsDisplayX11.cpp (+10/-45)
NuxGraphics/GraphicsDisplayX11.h (+2/-6)
NuxGraphics/Makefile.am (+2/-6)
NuxGraphics/XInputWindow.cpp (+0/-5)
configure.ac (+2/-2)
debian/changelog (+8/-0)
To merge this branch: bzr merge lp:~brandontschaefer/nux/xim-preedit-support
Reviewer Review Type Date Requested Status
Christopher Townsend Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+199569@code.launchpad.net

Commit message

Adds preedit support to XIM. Such as preedit rendering in the TextEntry.

Move XIM support from GraphicsDisplayX11 to WindowThread.

Description of the change

Add preedit support to XIM.

Had to move XIM support from GraphicsDisplayX11 to WindowThread

This should land when this branch lands:
https://code.launchpad.net/~brandontschaefer/unity/libnux-bump/+merge/200334

To post a comment you must log in.
834. By Brandon Schaefer

* Don't need that header

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:834
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~brandontschaefer/nux/xim-preedit-support/+merge/199569/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/nux-ci/97/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/nux-trusty-amd64-ci/19/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/nux-trusty-armhf-ci/19
    FAILURE: http://jenkins.qa.ubuntu.com/job/nux-trusty-i386-ci/19/console

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/nux-ci/97/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Couple of things right off the bat.

1. Need a commit message :)
2. Is there a bug associated with this work?
3. How do you test this? What is the old behavior and what am I expecting with this change?

Thanks!

review: Needs Information
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Hey Chris,

So there are some AP tests in unity. The old bevaior should be the same, ie. type in the an IM and text gets commited. Whats changed is they style, now preedit gets rendered to the TextEntry while the user types in they IM. Some IMs such as fctix doesn't support it by default (for some reason). So to test it out you'll need to go into:

$HOME/.config/fcitx/conf/fcitx-xim.config

Then set:
UseOnTheSpotStyle=True

835. By Brandon Schaefer

[ Brandon Schaefer ]
Add XIM preedit support

Update the deb change log

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

If $XMODIFIERS is blank, I get a seg fault crash. I don't think is default, but I'm sure it will happen.

Also,

839 +//#include "Nux.h"
840 +//#include "TextEntry.h"
841 +

needs to be removed since it's commented out.

review: Needs Fixing
836. By Brandon Schaefer

* Fix a crash when XMOD was blank. We need to make sure we are passing in a NULL
  name if we don't have any callbacks!

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Fixed issue, I was passing in XNPreeditAttributes and XNStatusAttributes to XCreateIC even when p_list and s_list was NULL. If they were NULL I can't pass in XNPreeditAttributes, instead it should also pass in a NULL name, so it doesn't try to access a NULL list.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

I think the Nux version should be bumped to 4.0.5. As I mentioned in https://code.launchpad.net/~brandontschaefer/unity/libnux-bump/+merge/200334/comments/465544, the Nux version built in the daily-ppa is already greater than the version you have proposed here.

review: Needs Fixing
837. By Brandon Schaefer

* Bump to 4.0.5

838. By Brandon Schaefer

[ Brandon Schaefer ]
* Add XIM preedit support
* Bump version to 4.0.5

Update changelog

839. By Brandon Schaefer

* Add missing space

840. By Brandon Schaefer

* Back to 1

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Great, this all looks good now!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Nux/MainLoopGLib.cpp'
--- Nux/MainLoopGLib.cpp 2013-11-06 13:56:07 +0000
+++ Nux/MainLoopGLib.cpp 2014-01-03 16:37:28 +0000
@@ -43,6 +43,11 @@
43 unsigned int id;43 unsigned int id;
44 } TimeoutData;44 } TimeoutData;
4545
46 Event GetSystemEvent(WindowThread* window_thread)
47 {
48 return window_thread->GetNextEvent();
49 }
50
46 gboolean nux_timeout_dispatch(gpointer user_data)51 gboolean nux_timeout_dispatch(gpointer user_data)
47 {52 {
48 bool repeat = false;53 bool repeat = false;
@@ -59,8 +64,7 @@
59 }64 }
60 else65 else
61 {66 {
62 Event event;67 Event event = GetSystemEvent(dd->window_thread);
63 dd->window_thread->GetGraphicsDisplay().GetSystemEvent(&event);
64 return_code = dd->window_thread->ProcessEvent(event);68 return_code = dd->window_thread->ProcessEvent(event);
65 }69 }
6670
@@ -128,8 +132,7 @@
128 nux_glib_threads_lock();132 nux_glib_threads_lock();
129 WindowThread *window_thread = NUX_STATIC_CAST(WindowThread *, user_data);133 WindowThread *window_thread = NUX_STATIC_CAST(WindowThread *, user_data);
130134
131 Event event;135 Event event = GetSystemEvent(window_thread);
132 window_thread->GetGraphicsDisplay().GetSystemEvent(&event);
133 unsigned int return_code = window_thread->ProcessEvent(event);136 unsigned int return_code = window_thread->ProcessEvent(event);
134137
135 if (return_code == 0 && !window_thread->IsEmbeddedWindow())138 if (return_code == 0 && !window_thread->IsEmbeddedWindow())
136139
=== modified file 'Nux/Makefile.am'
--- Nux/Makefile.am 2013-04-18 13:28:09 +0000
+++ Nux/Makefile.am 2014-01-03 16:37:28 +0000
@@ -129,7 +129,10 @@
129129
130if USE_X11130if USE_X11
131source_cpp += \131source_cpp += \
132 $(srcdir)/InputMethodIBus.cpp132 $(srcdir)/InputMethodIBus.cpp \
133 $(srcdir)/XICClient.cpp \
134 $(srcdir)/XIMCallbacks.cpp \
135 $(srcdir)/XIMController.cpp
133endif136endif
134137
135if HAVE_GEIS138if HAVE_GEIS
@@ -243,8 +246,10 @@
243endif246endif
244247
245if USE_X11248if USE_X11
246source_cpp += \249source_h += \
247 $(srcdir)/InputMethodIBus.h250 $(srcdir)/InputMethodIBus.h \
251 $(srcdir)/XICClient.h \
252 $(srcdir)/XIMController.h
248endif253endif
249254
250if HAVE_GEIS255if HAVE_GEIS
251256
=== modified file 'Nux/TextEntry.cpp'
--- Nux/TextEntry.cpp 2013-11-04 14:59:20 +0000
+++ Nux/TextEntry.cpp 2014-01-03 16:37:28 +0000
@@ -884,7 +884,7 @@
884 need_im_reset_ = true;884 need_im_reset_ = true;
885#if defined(USE_X11)885#if defined(USE_X11)
886 ime_->Focus();886 ime_->Focus();
887 nux::GetWindowThread()->GetGraphicsDisplay().XICFocus();887 nux::GetWindowThread()->XICFocus(this);
888#endif888#endif
889 //gtk_im_context_focus_in(im_context_);889 //gtk_im_context_focus_in(im_context_);
890 //UpdateIMCursorLocation();890 //UpdateIMCursorLocation();
@@ -907,7 +907,7 @@
907 need_im_reset_ = true;907 need_im_reset_ = true;
908#if defined(USE_X11)908#if defined(USE_X11)
909 ime_->Blur();909 ime_->Blur();
910 nux::GetWindowThread()->GetGraphicsDisplay().XICUnFocus();910 nux::GetWindowThread()->XICUnFocus();
911#endif911#endif
912 //gtk_im_context_focus_out(im_context_);912 //gtk_im_context_focus_out(im_context_);
913 }913 }
@@ -1033,6 +1033,35 @@
1033 }1033 }
1034 }1034 }
10351035
1036 void TextEntry::PreeditStarted()
1037 {
1038 ime_active_ = true;
1039 }
1040
1041 void TextEntry::UpdatePreedit(std::string const& preedit, int cursor)
1042 {
1043 preedit_ = preedit;
1044 preedit_cursor_ = cursor;
1045 QueueRefresh(true, true);
1046 }
1047
1048 void TextEntry::UpdatePreeditAttribs(PangoAttrList* list)
1049 {
1050 if (preedit_attrs_)
1051 {
1052 pango_attr_list_unref(preedit_attrs_);
1053 preedit_attrs_ = NULL;
1054 }
1055
1056 preedit_attrs_ = list;
1057 }
1058
1059 void TextEntry::ClearPreedit()
1060 {
1061 ResetPreedit();
1062 QueueRefresh(true, true);
1063 }
1064
1036 void TextEntry::DrawText(CairoGraphics *canvas)1065 void TextEntry::DrawText(CairoGraphics *canvas)
1037 {1066 {
1038 PangoLayout *layout = EnsureLayout();1067 PangoLayout *layout = EnsureLayout();
10391068
=== modified file 'Nux/TextEntry.h'
--- Nux/TextEntry.h 2013-11-04 14:59:20 +0000
+++ Nux/TextEntry.h 2014-01-03 16:37:28 +0000
@@ -227,6 +227,11 @@
227 bool PasswordMode() const;227 bool PasswordMode() const;
228 std::string GetPasswordChar();228 std::string GetPasswordChar();
229229
230 void PreeditStarted();
231 void UpdatePreedit(std::string const& preedit, int cursor);
232 void UpdatePreeditAttribs(PangoAttrList* list);
233 void ClearPreedit();
234
230 protected:235 protected:
231 bool _block_focus; // used to selectively ignore focus keyevents236 bool _block_focus; // used to selectively ignore focus keyevents
232237
233238
=== modified file 'Nux/WindowThread.cpp'
--- Nux/WindowThread.cpp 2013-11-07 11:53:10 +0000
+++ Nux/WindowThread.cpp 2014-01-03 16:37:28 +0000
@@ -118,6 +118,7 @@
118 WindowThread::~WindowThread()118 WindowThread::~WindowThread()
119 {119 {
120#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))120#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
121 xim_controller_.reset();
121 CleanupGlibLoop();122 CleanupGlibLoop();
122#endif123#endif
123124
@@ -521,6 +522,24 @@
521522
522 extern EventToNameStruct EventToName[];523 extern EventToNameStruct EventToName[];
523524
525 Event WindowThread::GetNextEvent()
526 {
527 Event event;
528 graphics_display_->GetSystemEvent(&event);
529
530#if defined(NUX_OS_LINUX) && defined(USE_X11)
531 // Make sure the current xic is synced up with the current event window
532 if ((event.type == KeyPress || event.type == KeyRelease) &&
533 event.x11_window && xim_controller_->GetCurrentWindow() != event.x11_window)
534 {
535 xim_controller_->SetFocusedWindow(event.x11_window);
536 graphics_display_->SetCurrentXIC(xim_controller_->GetXIC());
537 }
538#endif
539
540 return event;
541 }
542
524#if (!defined(NUX_OS_LINUX) && !defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) || defined(NUX_DISABLE_GLIB_LOOP)543#if (!defined(NUX_OS_LINUX) && !defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) || defined(NUX_DISABLE_GLIB_LOOP)
525#ifdef NUX_GESTURES_SUPPORT544#ifdef NUX_GESTURES_SUPPORT
526 Event *WindowThread::FetchNextEvent()545 Event *WindowThread::FetchNextEvent()
@@ -1148,6 +1167,8 @@
1148 timer_manager_ = new TimerHandler(this);1167 timer_manager_ = new TimerHandler(this);
1149 window_compositor_ = new WindowCompositor(this);1168 window_compositor_ = new WindowCompositor(this);
11501169
1170 xim_controller_ = std::make_shared<XIMController>(graphics_display_->GetX11Display());
1171
1151 SetThreadState(THREADRUNNING);1172 SetThreadState(THREADRUNNING);
1152 thread_ctor_called_ = true;1173 thread_ctor_called_ = true;
1153 return true;1174 return true;
@@ -1245,7 +1266,7 @@
1245 x11display_ = XOpenDisplay(NULL);1266 x11display_ = XOpenDisplay(NULL);
1246 ownx11display_ = true;1267 ownx11display_ = true;
1247 }1268 }
1248 1269
1249 graphics_display_ = gGLWindowManager.CreateFromForeignWindow(x11display_, X11Window, OpenGLContext);1270 graphics_display_ = gGLWindowManager.CreateFromForeignWindow(x11display_, X11Window, OpenGLContext);
12501271
1251 if (graphics_display_ == 0)1272 if (graphics_display_ == 0)
@@ -1264,6 +1285,8 @@
1264 timer_manager_ = new TimerHandler(this);1285 timer_manager_ = new TimerHandler(this);
1265 window_compositor_ = new WindowCompositor(this);1286 window_compositor_ = new WindowCompositor(this);
12661287
1288 xim_controller_ = std::make_shared<XIMController>(graphics_display_->GetX11Display());
1289
1267 SetThreadState(THREADRUNNING);1290 SetThreadState(THREADRUNNING);
1268 thread_ctor_called_ = true;1291 thread_ctor_called_ = true;
12691292
@@ -1776,6 +1799,19 @@
1776 _external_fds.erase (it);1799 _external_fds.erase (it);
1777 }1800 }
1778 }1801 }
1802#if defined(NUX_OS_LINUX) && defined(USE_X11)
1803 void WindowThread::XICFocus(TextEntry* text_entry)
1804 {
1805 xim_controller_->FocusInXIC();
1806 xim_controller_->SetCurrentTextEntry(text_entry);
1807 graphics_display_->SetCurrentXIC(xim_controller_->GetXIC());
1808 }
1809
1810 void WindowThread::XICUnFocus()
1811 {
1812 xim_controller_->FocusOutXIC();
1813 }
1814#endif
17791815
1780 GraphicsDisplay& WindowThread::GetGraphicsDisplay() const1816 GraphicsDisplay& WindowThread::GetGraphicsDisplay() const
1781 {1817 {
17821818
=== modified file 'Nux/WindowThread.h'
--- Nux/WindowThread.h 2013-10-30 23:26:54 +0000
+++ Nux/WindowThread.h 2014-01-03 16:37:28 +0000
@@ -29,6 +29,10 @@
29#include "GeisAdapter.h"29#include "GeisAdapter.h"
30#endif30#endif
3131
32#if defined(NUX_OS_LINUX) && defined(USE_X11)
33#include "XIMController.h"
34#endif
35
32namespace nux36namespace nux
33{37{
3438
@@ -358,6 +362,8 @@
358362
359 std::vector<Geometry> GetPresentationListGeometries() const;363 std::vector<Geometry> GetPresentationListGeometries() const;
360364
365 Event GetNextEvent();
366
361#ifdef NUX_GESTURES_SUPPORT367#ifdef NUX_GESTURES_SUPPORT
362 /*!368 /*!
363 Simple wrapper for ProcessEvent for connection with GeisAdapter::event_ready369 Simple wrapper for ProcessEvent for connection with GeisAdapter::event_ready
@@ -371,6 +377,11 @@
371 void WatchFdForEvents(int fd, const FdWatchCallback &);377 void WatchFdForEvents(int fd, const FdWatchCallback &);
372 void UnwatchFd(int fd);378 void UnwatchFd(int fd);
373379
380#if defined(NUX_OS_LINUX) && defined(USE_X11)
381 void XICFocus(TextEntry* text_entry);
382 void XICUnFocus();
383#endif
384
374 protected:385 protected:
375386
376 /*!387 /*!
@@ -709,6 +720,10 @@
709 std::unique_ptr<GeisAdapter> geis_adapter_;720 std::unique_ptr<GeisAdapter> geis_adapter_;
710#endif721#endif
711722
723#if defined(NUX_OS_LINUX) && defined(USE_X11)
724 std::shared_ptr<XIMController> xim_controller_;
725#endif
726
712 /*!727 /*!
713 Add a timeout and return the timeout index.728 Add a timeout and return the timeout index.
714 This function is used internally by Nux.729 This function is used internally by Nux.
715730
=== renamed file 'NuxGraphics/XICClient.cpp' => 'Nux/XICClient.cpp'
--- NuxGraphics/XICClient.cpp 2013-07-18 00:09:46 +0000
+++ Nux/XICClient.cpp 2014-01-03 16:37:28 +0000
@@ -1,5 +1,5 @@
1/*1/*
2* Copyright 2012 Inalogic® Inc.2* Copyright 2012-2013 Inalogic® Inc.
3*3*
4* This program is free software: you can redistribute it and/or modify it4* This program is free software: you can redistribute it and/or modify it
5* under the terms of the GNU Lesser General Public License, as5* under the terms of the GNU Lesser General Public License, as
@@ -21,54 +21,260 @@
2121
22#include "XICClient.h"22#include "XICClient.h"
2323
24#include "NuxCore/Logger.h"
25
26DECLARE_LOGGER(logger, "xic.client");
27
28using namespace std;
29
24namespace nux30namespace nux
25{31{
2632
33int const FEEDBACK_MASK = (XIMUnderline | XIMReverse);
34
27XICClient::XICClient()35XICClient::XICClient()
28 : xic_(NULL)36 : xic_(nullptr)
29 , xim_style_(0)37 , xim_style_(0)
30 , focused_(false)38 , focused_(false)
31{39{
32}40}
3341
34void XICClient::ResetXIC(XIM xim, Window window)42void XICClient::ResetXIC(XIM xim, Window window, Display* display)
35{43{
36 if (!xim_style_)44 if (!xim_style_)
37 SetupXIMStyle(xim);45 SetupXIMStyle(xim);
3846
39 SetupXIC(xim, window);47 SetupXIC(xim, window, display);
40}48}
4149
42void XICClient::SetupXIC(XIM xim, Window window)50void XICClient::SetCurrentTextEntry(TextEntry* text_entry)
51{
52 text_entry_ = text_entry;
53}
54
55static int preedit_caret_callback(XIC xic,
56 XPointer clientdata,
57 XIMPreeditCaretCallbackStruct* call_data)
58{
59 return 0;
60}
61
62static int status_start_callback(XIC xic,
63 XPointer clientdata,
64 XIMPreeditDrawCallbackStruct* call_data)
65{
66 return 0;
67}
68
69static void status_draw_callback(XIC xic,
70 XPointer clientdata,
71 XPointer* call_data)
72{
73}
74
75static void status_done_callback(XIC xic,
76 XPointer clientdata,
77 XPointer* call_data)
78{
79}
80
81XVaNestedList XICClient::GetPreeditCallbacks()
82{
83 preedit_start_cb_.callback = (XIMProc)XICClient::PreeditStartCallback;
84 preedit_start_cb_.client_data = nullptr;
85
86 preedit_done_cb_.callback = (XIMProc)XICClient::PreeditDoneCallback;
87 preedit_done_cb_.client_data = (XPointer)text_entry_;
88
89 preedit_draw_cb_.callback = (XIMProc)XICClient::PreeditDrawCallback;
90 preedit_draw_cb_.client_data = (XPointer)text_entry_;
91
92 preedit_caret_cb_.callback = (XIMProc)preedit_caret_callback;
93 preedit_caret_cb_.client_data = nullptr;
94
95 XVaNestedList p_list = nullptr;
96 p_list = XVaCreateNestedList(0,
97 XNPreeditStartCallback, &preedit_start_cb_,
98 XNPreeditDoneCallback, &preedit_done_cb_,
99 XNPreeditDrawCallback, &preedit_draw_cb_,
100 XNPreeditCaretCallback, &preedit_caret_cb_,
101 nullptr);
102
103 return p_list;
104}
105
106XVaNestedList XICClient::GetStatusCallbacks()
107{
108 status_start_cb_.callback = (XIMProc)status_start_callback;
109 status_start_cb_.client_data = nullptr;
110
111 status_done_cb_.callback = (XIMProc)status_done_callback;
112 status_done_cb_.client_data = nullptr;
113
114 status_draw_cb_.callback = (XIMProc)status_draw_callback;
115 status_draw_cb_.client_data = nullptr;
116
117 XVaNestedList s_list = nullptr;
118 s_list = XVaCreateNestedList(0,
119 XNStatusStartCallback, &status_start_callback,
120 XNStatusDoneCallback, &status_done_callback,
121 XNStatusDrawCallback, &status_draw_callback,
122 nullptr);
123
124 return s_list;
125}
126
127XIMStyle XICClient::FilterXIMStyle()
128{
129 XIMStyle style = 0;
130
131 if (xim_style_ & XIMPreeditCallbacks)
132 {
133 style |= XIMPreeditCallbacks;
134 }
135 else if (xim_style_ & XIMPreeditNone)
136 {
137 style |= XIMPreeditNone;
138 }
139 else
140 {
141 style |= XIMPreeditNothing;
142 }
143
144 if (xim_style_ & XIMStatusCallbacks)
145 {
146 style |= XIMStatusCallbacks;
147 }
148 else if (xim_style_ & XIMStatusNone)
149 {
150 style |= XIMStatusNone;
151 }
152 else
153 {
154 style |= XIMStatusNothing;
155 }
156
157 return style;
158}
159
160void XICClient::SetupXIC(XIM xim, Window window, Display* display)
43{161{
44 if (xic_)162 if (xic_)
45 DestroyXIC();163 DestroyXIC();
46164
47 xic_ = XCreateIC(xim, XNInputStyle, xim_style_, XNClientWindow, window, XNFocusWindow, window, NULL);165 XIMStyle style = FilterXIMStyle();
166
167 const char* p_name = nullptr;
168 XVaNestedList p_list = nullptr;
169 if (style & XIMPreeditCallbacks)
170 {
171 p_list = GetPreeditCallbacks();
172 p_name = XNPreeditAttributes;
173 }
174
175 const char* s_name = nullptr;
176 XVaNestedList s_list = nullptr;
177 if (style & XIMStatusCallbacks)
178 {
179 s_list = GetStatusCallbacks();
180 s_name = XNStatusAttributes;
181 }
182
183 xic_ = XCreateIC(xim, XNInputStyle, style,
184 XNClientWindow, window,
185 p_name, p_list,
186 s_name, s_list,
187 nullptr);
188
189 if (p_list)
190 XFree(p_list);
191 if (s_list)
192 XFree(s_list);
193
194 xim_style_ = style;
195}
196
197XIMStyle ChooseBetterStyle(XIMStyle style1, XIMStyle style2)
198{
199 XIMStyle s,t;
200 XIMStyle preedit = XIMPreeditArea | XIMPreeditCallbacks |
201 XIMPreeditPosition | XIMPreeditNothing | XIMPreeditNone;
202
203 XIMStyle status = XIMStatusArea | XIMStatusCallbacks |
204 XIMStatusNothing | XIMStatusNone;
205
206 if (style1 == 0)
207 return style2;
208
209 if (style2 == 0)
210 return style1;
211
212 if ((style1 & (preedit | status)) == (style2 & (preedit | status)))
213 return style1;
214
215 s = style1 & preedit;
216 t = style2 & preedit;
217 if (s != t)
218 {
219 if (s | t | XIMPreeditCallbacks)
220 return (s == XIMPreeditCallbacks) ? style1 : style2;
221 else if (s | t | XIMPreeditPosition)
222 return (s == XIMPreeditPosition) ? style1 : style2;
223 else if (s | t | XIMPreeditArea)
224 return (s == XIMPreeditArea) ? style1 : style2;
225 else if (s | t | XIMPreeditNothing)
226 return (s == XIMPreeditNothing) ? style1 : style2;
227 else if (s | t | XIMPreeditNone)
228 return (s == XIMPreeditNone) ? style1 : style2;
229 }
230 else
231 {
232 s = style1 & status;
233 t = style2 & status;
234
235 if (s | t | XIMStatusCallbacks)
236 return (s == XIMStatusCallbacks) ? style1 : style2;
237 else if (s | t | XIMStatusArea)
238 return (s == XIMStatusArea) ? style1 : style2;
239 else if (s | t | XIMStatusNothing)
240 return (s == XIMStatusNothing) ? style1 : style2;
241 else if (s | t | XIMStatusNone)
242 return (s == XIMStatusNone) ? style1 : style2;
243 }
48}244}
49245
50void XICClient::SetupXIMStyle(XIM xim)246void XICClient::SetupXIMStyle(XIM xim)
51{247{
52 int i;248 int i;
53 XIMStyles *xim_styles = NULL;249 XIMStyles *xim_styles = nullptr;
54 XIMStyle root_style = (XIMPreeditNothing|XIMStatusNothing);250 XIMStyle prefered_style = XIMPreeditCallbacks | XIMStatusCallbacks;
55251
56 XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL);252 XGetIMValues(xim, XNQueryInputStyle, &xim_styles, nullptr);
57253
254 XIMStyle best = 0, style = 0;
58 for (i = 0; i < xim_styles->count_styles; ++i)255 for (i = 0; i < xim_styles->count_styles; ++i)
59 if (xim_styles->supported_styles[i] == root_style)256 {
257 style = xim_styles->supported_styles[i];
258
259 if ((style & prefered_style) == style)
260 {
261 best = ChooseBetterStyle(style, best);
60 break;262 break;
263 }
264 else
265 {
266 best = ChooseBetterStyle(style, best);
267 }
268 }
61269
62 if (i >= xim_styles->count_styles)270 xim_style_ = best;
63 xim_style_ = 0;
64 xim_style_ = root_style;
65271
66 XFree(xim_styles);272 XFree(xim_styles);
67}273}
68274
69bool XICClient::HasXIC() const275bool XICClient::HasXIC() const
70{276{
71 return xic_ != NULL;277 return xic_ != nullptr;
72}278}
73279
74XIC XICClient::GetXIC() const280XIC XICClient::GetXIC() const
@@ -78,7 +284,7 @@
78284
79void XICClient::Reinitialize()285void XICClient::Reinitialize()
80{286{
81 xic_ = NULL;287 xic_ = nullptr;
82 xim_style_ = 0;288 xim_style_ = 0;
83 focused_ = false;289 focused_ = false;
84}290}
@@ -111,7 +317,7 @@
111 if (xic_)317 if (xic_)
112 {318 {
113 XDestroyIC(xic_);319 XDestroyIC(xic_);
114 xic_ = NULL;320 xic_ = nullptr;
115 }321 }
116}322}
117323
118324
=== renamed file 'NuxGraphics/XICClient.h' => 'Nux/XICClient.h'
--- NuxGraphics/XICClient.h 2012-11-27 19:30:57 +0000
+++ Nux/XICClient.h 2014-01-03 16:37:28 +0000
@@ -1,5 +1,5 @@
1/*1/*
2* Copyright 2012 Inalogic® Inc.2* Copyright 2012-2013 Inalogic® Inc.
3*3*
4* This program is free software: you can redistribute it and/or modify it4* This program is free software: you can redistribute it and/or modify it
5* under the terms of the GNU Lesser General Public License, as5* under the terms of the GNU Lesser General Public License, as
@@ -27,13 +27,15 @@
2727
28namespace nux28namespace nux
29{29{
30 class TextEntry;
3031
31class XICClient32class XICClient
32{33{
33public:34public:
34 XICClient();35 XICClient();
3536
36 void ResetXIC(XIM xim, Window window);37 void ResetXIC(XIM xim, Window window, Display* display);
38 void SetCurrentTextEntry(TextEntry* text_entry_);
3739
38 bool HasXIC() const;40 bool HasXIC() const;
39 XIC GetXIC() const;41 XIC GetXIC() const;
@@ -46,12 +48,32 @@
4648
47 void DestroyXIC();49 void DestroyXIC();
48private:50private:
49 void SetupXIC(XIM xim, Window window);51 void SetupXIC(XIM xim, Window window, Display* display);
50 void SetupXIMStyle(XIM xim);52 void SetupXIMStyle(XIM xim);
5153
54 XVaNestedList GetPreeditCallbacks();
55 XVaNestedList GetStatusCallbacks();
56 XIMStyle FilterXIMStyle();
57
58 static int PreeditStartCallback(XIC xic, XPointer clientdata, XPointer data);
59 static int PreeditDoneCallback(XIC xic, XPointer clientdata, XPointer data);
60
61 static int PreeditDrawCallback(XIC xic, XPointer clientdata,
62 XIMPreeditDrawCallbackStruct* call_data);
63
64 TextEntry* text_entry_;
52 XIC xic_;65 XIC xic_;
53 XIMStyle xim_style_;66 XIMStyle xim_style_;
5467
68 XIMCallback preedit_start_cb_;
69 XIMCallback preedit_done_cb_;
70 XIMCallback preedit_draw_cb_;
71 XIMCallback preedit_caret_cb_;
72
73 XIMCallback status_start_cb_;
74 XIMCallback status_done_cb_;
75 XIMCallback status_draw_cb_;
76
55 bool focused_;77 bool focused_;
56};78};
5779
5880
=== added file 'Nux/XIMCallbacks.cpp'
--- Nux/XIMCallbacks.cpp 1970-01-01 00:00:00 +0000
+++ Nux/XIMCallbacks.cpp 2014-01-03 16:37:28 +0000
@@ -0,0 +1,189 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright 2013 Inalogic® Inc.
4 *
5 * This program is free software: you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License, as
7 * published by the Free Software Foundation; either version 2.1 or 3.0
8 * of the License.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranties of
12 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
13 * PURPOSE. See the applicable version of the GNU Lesser General Public
14 * License for more details.
15 *
16 * You should have received a copy of both the GNU Lesser General Public
17 * License along with this program. If not, see <http://www.gnu.org/licenses/>
18 *
19 * Authored by: Brandon Schaefer
20 *
21 */
22
23
24#include "Nux.h"
25#include "TextEntry.h"
26#include "XICClient.h"
27
28#include <string>
29
30#include "NuxCore/Logger.h"
31
32DECLARE_LOGGER(logger, "xim.callbacks");
33
34using namespace std;
35
36namespace nux
37{
38
39int const FEEDBACK_MASK = (XIMUnderline | XIMReverse);
40
41int XICClient::PreeditStartCallback(XIC xic,
42 XPointer clientdata,
43 XPointer call_data)
44{
45 TextEntry* text_entry = (TextEntry*)clientdata;
46 if (text_entry)
47 {
48 text_entry->PreeditStarted();
49 }
50
51 return 0;
52}
53
54int XICClient::PreeditDoneCallback(XIC xic,
55 XPointer clientdata,
56 XPointer call_data)
57{
58 TextEntry* text_entry = (TextEntry*)clientdata;
59 if (text_entry)
60 {
61 text_entry->ClearPreedit();
62 }
63
64 return 0;
65}
66
67void add_feedback_attr(PangoAttrList* attrs,
68 char const* str,
69 XIMFeedback feedback,
70 int start,
71 int end)
72{
73 PangoAttribute* attr;
74
75 int start_index = g_utf8_offset_to_pointer(str, start) - str;
76 int end_index = g_utf8_offset_to_pointer(str, end) - str;
77
78 if (feedback & XIMUnderline)
79 {
80 attr = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
81 attr->start_index = start_index;
82 attr->end_index = end_index;
83
84 pango_attr_list_insert (attrs, attr);
85 }
86
87 if (feedback & XIMReverse)
88 {
89 attr = pango_attr_foreground_new(0xFFFF, 0xFFFF, 0xFFFF);
90 attr->start_index = start_index;
91 attr->end_index = end_index;
92
93 pango_attr_list_insert (attrs, attr);
94
95 attr = pango_attr_background_new(0x0, 0x0, 0x0);
96
97 attr->start_index = start_index;
98 attr->end_index = end_index;
99
100 pango_attr_list_insert (attrs, attr);
101 }
102
103 if (feedback & ~FEEDBACK_MASK)
104 {
105 LOG_WARN(logger) << "Unrenderer feedback: " << (feedback & ~FEEDBACK_MASK);
106 }
107}
108
109void feedback_to_pango_list(PangoAttrList** attrs,
110 char const* str,
111 int nfeedbacks,
112 XIMFeedback* feedbacks)
113{
114 XIMFeedback last_feedback = 0;
115 int start = -1;
116 int i = 0;
117
118 if (attrs)
119 {
120 *attrs = pango_attr_list_new();
121
122 for (i = 0; i < nfeedbacks; ++i)
123 {
124 XIMFeedback new_feedback = (feedbacks[i] & FEEDBACK_MASK);
125 if (new_feedback != last_feedback)
126 {
127 last_feedback = new_feedback;
128 start = i;
129 }
130 else
131 {
132 PangoAttribute* attr;
133
134 int start_index = g_utf8_offset_to_pointer(str, start) - str;
135 int end_index = g_utf8_offset_to_pointer(str, i) - str;
136
137 attr = pango_attr_foreground_new(0x0, 0x0, 0x0);
138 attr->start_index = start_index;
139 attr->end_index = end_index;
140
141 pango_attr_list_insert (*attrs, attr);
142
143 attr = pango_attr_background_new(0xFFFF, 0xFFFF, 0xFFFF);
144
145 attr->start_index = start_index;
146 attr->end_index = end_index;
147
148 pango_attr_list_insert (*attrs, attr);
149 }
150 }
151
152 if (start >= 0)
153 add_feedback_attr(*attrs, str, last_feedback, start, i);
154 }
155}
156
157int XICClient::PreeditDrawCallback(XIC xic,
158 XPointer clientdata,
159 XIMPreeditDrawCallbackStruct* call_data)
160{
161 TextEntry* text_entry = (TextEntry*)clientdata;
162
163 if (call_data->text && text_entry)
164 {
165 string preedit;
166
167 // TODO Actually handle this correctly...
168 if (call_data->text->encoding_is_wchar)
169 {
170 preedit = string("");
171 }
172 else
173 {
174 preedit = string(call_data->text->string.multi_byte);
175 }
176
177 PangoAttrList* preedit_attr;
178 feedback_to_pango_list(&preedit_attr, preedit.c_str(),
179 call_data->text->length,
180 call_data->text->feedback);
181
182 text_entry->UpdatePreeditAttribs(preedit_attr);
183 text_entry->UpdatePreedit(preedit, call_data->caret);
184 }
185
186 return 0;
187}
188
189}
0190
=== renamed file 'NuxGraphics/XIMController.cpp' => 'Nux/XIMController.cpp'
--- NuxGraphics/XIMController.cpp 2013-10-10 23:36:28 +0000
+++ Nux/XIMController.cpp 2014-01-03 16:37:28 +0000
@@ -1,5 +1,5 @@
1/*1/*
2* Copyright 2012 Inalogic® Inc.2* Copyright 2012-2013 Inalogic® Inc.
3*3*
4* This program is free software: you can redistribute it and/or modify it4* This program is free software: you can redistribute it and/or modify it
5* under the terms of the GNU Lesser General Public License, as5* under the terms of the GNU Lesser General Public License, as
@@ -32,7 +32,7 @@
32XIMController::XIMController(Display* display)32XIMController::XIMController(Display* display)
33 : display_(display)33 : display_(display)
34 , window_(0)34 , window_(0)
35 , xim_(NULL)35 , xim_(nullptr)
36{36{
37 InitXIMCallback();37 InitXIMCallback();
38}38}
@@ -51,7 +51,15 @@
51 window_ = window;51 window_ = window;
5252
53 if (xim_)53 if (xim_)
54 xic_client_.ResetXIC(xim_, window);54 xic_client_.ResetXIC(xim_, window, display_);
55}
56
57void XIMController::SetCurrentTextEntry(TextEntry* text_entry)
58{
59 xic_client_.SetCurrentTextEntry(text_entry);
60
61 if (xim_)
62 xic_client_.ResetXIC(xim_, window_, display_);
55}63}
5664
57void XIMController::RemoveFocusedWindow()65void XIMController::RemoveFocusedWindow()
@@ -78,7 +86,7 @@
78void XIMController::FocusOutXIC()86void XIMController::FocusOutXIC()
79{87{
80 xic_client_.FocusOutXIC();88 xic_client_.FocusOutXIC();
81 xic_client_.DestroyXIC();89 xic_client_.SetCurrentTextEntry(nullptr);
82}90}
8391
84Window XIMController::GetCurrentWindow() const92Window XIMController::GetCurrentWindow() const
@@ -131,12 +139,13 @@
131void XIMController::SetupXIM()139void XIMController::SetupXIM()
132{140{
133 xim_ = XOpenIM(display_, NULL, NULL, NULL);141 xim_ = XOpenIM(display_, NULL, NULL, NULL);
142
134 if (xim_)143 if (xim_)
135 {144 {
136 SetupXIMDestroyedCallback();145 SetupXIMDestroyedCallback();
137146
138 if (window_)147 if (window_)
139 xic_client_.ResetXIC(xim_, window_);148 xic_client_.ResetXIC(xim_, window_, display_);
140149
141 XUnregisterIMInstantiateCallback (display_, NULL, NULL, NULL,150 XUnregisterIMInstantiateCallback (display_, NULL, NULL, NULL,
142 XIMController::SetupXIMClientCallback,151 XIMController::SetupXIMClientCallback,
143152
=== renamed file 'NuxGraphics/XIMController.h' => 'Nux/XIMController.h'
--- NuxGraphics/XIMController.h 2013-10-10 23:36:28 +0000
+++ Nux/XIMController.h 2014-01-03 16:37:28 +0000
@@ -1,5 +1,5 @@
1/*1/*
2* Copyright 2012 Inalogic® Inc.2* Copyright 2012-2013 Inalogic® Inc.
3*3*
4* This program is free software: you can redistribute it and/or modify it4* This program is free software: you can redistribute it and/or modify it
5* under the terms of the GNU Lesser General Public License, as5* under the terms of the GNU Lesser General Public License, as
@@ -29,6 +29,7 @@
2929
30namespace nux30namespace nux
31{31{
32 class TextEntry;
3233
33class XIMController34class XIMController
34{35{
@@ -37,6 +38,7 @@
37 ~XIMController();38 ~XIMController();
3839
39 void SetFocusedWindow(Window window);40 void SetFocusedWindow(Window window);
41 void SetCurrentTextEntry(TextEntry* text_entry_);
40 void RemoveFocusedWindow();42 void RemoveFocusedWindow();
4143
42 bool IsXICValid() const;44 bool IsXICValid() const;
4345
=== modified file 'NuxGraphics/GraphicsDisplayX11.cpp'
--- NuxGraphics/GraphicsDisplayX11.cpp 2013-10-11 13:07:50 +0000
+++ NuxGraphics/GraphicsDisplayX11.cpp 2014-01-03 16:37:28 +0000
@@ -108,6 +108,7 @@
108 , m_X11Screen(0)108 , m_X11Screen(0)
109 , m_X11Window(0)109 , m_X11Window(0)
110 , m_X11VisualInfo(NULL)110 , m_X11VisualInfo(NULL)
111 , m_current_xic(NULL)
111 , parent_window_(0)112 , parent_window_(0)
112 , m_GLCtx(NULL)113 , m_GLCtx(NULL)
113#ifndef NUX_OPENGLES_20114#ifndef NUX_OPENGLES_20
@@ -172,9 +173,6 @@
172 NUX_SAFE_DELETE( m_GraphicsContext );173 NUX_SAFE_DELETE( m_GraphicsContext );
173 NUX_SAFE_DELETE( m_DeviceFactory );174 NUX_SAFE_DELETE( m_DeviceFactory );
174175
175 // The XIM Controller needs to clean up before ~GraphicsDisplayX11
176 m_xim_controller.reset();
177
178 if (m_CreatedFromForeignWindow == false)176 if (m_CreatedFromForeignWindow == false)
179 {177 {
180 DestroyOpenGLWindow();178 DestroyOpenGLWindow();
@@ -258,16 +256,6 @@
258 }256 }
259#endif257#endif
260258
261 void GraphicsDisplay::XICFocus()
262 {
263 m_xim_controller->FocusInXIC();
264 }
265
266 void GraphicsDisplay::XICUnFocus()
267 {
268 m_xim_controller->FocusOutXIC();
269 }
270
271 // TODO: change windowWidth, windowHeight, to window_size;259 // TODO: change windowWidth, windowHeight, to window_size;
272 static NCriticalSection CreateOpenGLWindow_CriticalSection;260 static NCriticalSection CreateOpenGLWindow_CriticalSection;
273 bool GraphicsDisplay::CreateOpenGLWindow(const char* window_title,261 bool GraphicsDisplay::CreateOpenGLWindow(const char* window_title,
@@ -659,16 +647,6 @@
659 //XMapRaised(m_X11Display, m_X11Window);647 //XMapRaised(m_X11Display, m_X11Window);
660 }648 }
661649
662 m_xim_controller = std::make_shared<XIMController>(m_X11Display);
663 m_xim_controller->SetFocusedWindow(m_X11Window);
664
665 if (m_xim_controller->IsXICValid())
666 {
667 long im_event_mask=0;
668 XGetICValues(m_xim_controller->GetXIC(), XNFilterEvents, &im_event_mask, NULL);
669 m_X11Attr.event_mask |= im_event_mask;
670 }
671
672#ifndef NUX_OPENGLES_20650#ifndef NUX_OPENGLES_20
673 if (_has_glx_13)651 if (_has_glx_13)
674 {652 {
@@ -778,8 +756,6 @@
778756
779 gfx_interface_created_ = true;757 gfx_interface_created_ = true;
780758
781 m_xim_controller = std::make_shared<XIMController>(m_X11Display);
782
783 // m_DeviceFactory = new GpuDevice(viewport_size_.GetWidth(), viewport_size_.GetHeight(), BITFMT_R8G8B8A8);759 // m_DeviceFactory = new GpuDevice(viewport_size_.GetWidth(), viewport_size_.GetHeight(), BITFMT_R8G8B8A8);
784 m_DeviceFactory = new GpuDevice(viewport_size_.width, viewport_size_.height, BITFMT_R8G8B8A8,760 m_DeviceFactory = new GpuDevice(viewport_size_.width, viewport_size_.height, BITFMT_R8G8B8A8,
785 m_X11Display,761 m_X11Display,
@@ -811,14 +787,9 @@
811 return m_DeviceFactory;787 return m_DeviceFactory;
812 }788 }
813789
814 void GraphicsDisplay::SetFocusedWindowForXIMController(Window window)790 void GraphicsDisplay::SetCurrentXIC(XIC xic)
815 {791 {
816 m_xim_controller->SetFocusedWindow(window);792 m_current_xic = xic;
817 }
818
819 void GraphicsDisplay::RemoveFocusedWindowForXIMController()
820 {
821 m_xim_controller->RemoveFocusedWindow();
822 }793 }
823794
824 int GraphicsDisplay::GetGlXMajor() const795 int GraphicsDisplay::GetGlXMajor() const
@@ -1359,14 +1330,10 @@
1359 bool bProcessEvent = true;1330 bool bProcessEvent = true;
1360 XNextEvent(m_X11Display, &xevent);1331 XNextEvent(m_X11Display, &xevent);
13611332
1362 if ((xevent.type == KeyPress || xevent.type == KeyRelease) &&
1363 m_xim_controller->GetCurrentWindow() != xevent.xkey.window)
1364 {
1365 m_xim_controller->SetFocusedWindow(xevent.xkey.window);
1366 }
1367
1368 if (XFilterEvent(&xevent, None) == True)1333 if (XFilterEvent(&xevent, None) == True)
1334 {
1369 return true;1335 return true;
1336 }
13701337
1371 if (!_event_filters.empty())1338 if (!_event_filters.empty())
1372 {1339 {
@@ -1687,7 +1654,6 @@
1687 m_pEvent->virtual_code = 0;1654 m_pEvent->virtual_code = 0;
1688 //nuxDebugMsg("[GraphicsDisplay::ProcessXEvents]: FocusIn event.");1655 //nuxDebugMsg("[GraphicsDisplay::ProcessXEvents]: FocusIn event.");
16891656
1690 m_xim_controller->FocusInXIC();
1691 break;1657 break;
1692 }1658 }
16931659
@@ -1704,7 +1670,6 @@
1704 m_pEvent->virtual_code = 0;1670 m_pEvent->virtual_code = 0;
1705 //nuxDebugMsg("[GraphicsDisplay::ProcessXEvents]: FocusOut event.");1671 //nuxDebugMsg("[GraphicsDisplay::ProcessXEvents]: FocusOut event.");
17061672
1707 m_xim_controller->FocusOutXIC();
1708 break;1673 break;
1709 }1674 }
17101675
@@ -1731,20 +1696,20 @@
1731 (keysym == NUX_VK_ESCAPE))1696 (keysym == NUX_VK_ESCAPE))
1732 {1697 {
1733 //temporary fix for TextEntry widget: filter some keys1698 //temporary fix for TextEntry widget: filter some keys
1734 skip = true;1699 skip = true;
1735 }1700 }
17361701
1737 if (!skip)1702 if (!skip)
1738 {1703 {
1739 int num_char_stored = 0;1704 int num_char_stored = 0;
17401705
1741 if (m_xim_controller->IsXICValid())1706 if (m_current_xic)
1742 {1707 {
1743 delete[] m_pEvent->dtext;1708 delete[] m_pEvent->dtext;
1744 m_pEvent->dtext = nullptr;1709 m_pEvent->dtext = nullptr;
1745 Status status;1710 Status status;
17461711
1747 num_char_stored = XmbLookupString(m_xim_controller->GetXIC(), &xevent.xkey, nullptr,1712 num_char_stored = XmbLookupString(m_current_xic, &xevent.xkey, nullptr,
1748 0, (KeySym*) &m_pEvent->x11_keysym, &status);1713 0, (KeySym*) &m_pEvent->x11_keysym, &status);
17491714
1750 if (status == XLookupKeySym)1715 if (status == XLookupKeySym)
@@ -1755,7 +1720,7 @@
1755 {1720 {
1756 int buf_len = num_char_stored + 1;1721 int buf_len = num_char_stored + 1;
1757 m_pEvent->dtext = new char[buf_len];1722 m_pEvent->dtext = new char[buf_len];
1758 num_char_stored = XmbLookupString(m_xim_controller->GetXIC(), &xevent.xkey, m_pEvent->dtext,1723 num_char_stored = XmbLookupString(m_current_xic, &xevent.xkey, m_pEvent->dtext,
1759 buf_len, (KeySym*) &m_pEvent->x11_keysym, nullptr);1724 buf_len, (KeySym*) &m_pEvent->x11_keysym, nullptr);
17601725
1761 m_pEvent->dtext[num_char_stored] = 0;1726 m_pEvent->dtext[num_char_stored] = 0;
17621727
=== modified file 'NuxGraphics/GraphicsDisplayX11.h'
--- NuxGraphics/GraphicsDisplayX11.h 2012-12-17 19:04:50 +0000
+++ NuxGraphics/GraphicsDisplayX11.h 2014-01-03 16:37:28 +0000
@@ -27,7 +27,6 @@
27#include "GLTimer.h"27#include "GLTimer.h"
28#include "GLDeviceObjects.h"28#include "GLDeviceObjects.h"
29#include "GLRenderStates.h"29#include "GLRenderStates.h"
30#include "XIMController.h"
3130
32/* Xlib.h is the default header that is included and has the core functionallity */31/* Xlib.h is the default header that is included and has the core functionallity */
33#include <X11/Xlib.h>32#include <X11/Xlib.h>
@@ -85,7 +84,7 @@
85 Window m_X11Window;84 Window m_X11Window;
86 XVisualInfo *m_X11VisualInfo;85 XVisualInfo *m_X11VisualInfo;
8786
88 std::shared_ptr<XIMController> m_xim_controller;87 XIC m_current_xic;
8988
90 int parent_window_;89 int parent_window_;
91#ifndef NUX_OPENGLES_2090#ifndef NUX_OPENGLES_20
@@ -286,8 +285,7 @@
286285
287 GpuDevice* GetGpuDevice() const;286 GpuDevice* GetGpuDevice() const;
288287
289 void SetFocusedWindowForXIMController(Window window);288 void SetCurrentXIC(XIC xic);
290 void RemoveFocusedWindowForXIMController();
291289
292 // Dialog290 // Dialog
293 /*bool StartOpenFileDialog(FileDialogOption& fdo);291 /*bool StartOpenFileDialog(FileDialogOption& fdo);
@@ -348,8 +346,6 @@
348346
349 void * KeyboardGrabData() { return _global_keyboard_grab_data; }347 void * KeyboardGrabData() { return _global_keyboard_grab_data; }
350 void * PointerGrabData() { return _global_pointer_grab_data; }348 void * PointerGrabData() { return _global_pointer_grab_data; }
351 void XICFocus();
352 void XICUnFocus();
353349
354 private:350 private:
355 void InitGlobalGrabWindow();351 void InitGlobalGrabWindow();
356352
=== modified file 'NuxGraphics/Makefile.am'
--- NuxGraphics/Makefile.am 2012-12-05 19:22:13 +0000
+++ NuxGraphics/Makefile.am 2014-01-03 16:37:28 +0000
@@ -93,9 +93,7 @@
93source_h += \93source_h += \
94 $(srcdir)/GraphicsDisplayX11.h \94 $(srcdir)/GraphicsDisplayX11.h \
95 $(srcdir)/VirtualKeyCodesX11.h \95 $(srcdir)/VirtualKeyCodesX11.h \
96 $(srcdir)/XInputWindow.h \96 $(srcdir)/XInputWindow.h
97 $(srcdir)/XICClient.h \
98 $(srcdir)/XIMController.h
99endif97endif
10098
101if !NUX_OPENGLES_2099if !NUX_OPENGLES_20
@@ -170,9 +168,7 @@
170if USE_X11168if USE_X11
171source_cpp += \169source_cpp += \
172 $(srcdir)/GraphicsDisplayX11.cpp \170 $(srcdir)/GraphicsDisplayX11.cpp \
173 $(srcdir)/XInputWindow.cpp \171 $(srcdir)/XInputWindow.cpp
174 $(srcdir)/XICClient.cpp \
175 $(srcdir)/XIMController.cpp
176endif172endif
177173
178if !NUX_OPENGLES_20174if !NUX_OPENGLES_20
179175
=== modified file 'NuxGraphics/XInputWindow.cpp'
--- NuxGraphics/XInputWindow.cpp 2013-07-18 23:07:45 +0000
+++ NuxGraphics/XInputWindow.cpp 2014-01-03 16:37:28 +0000
@@ -22,7 +22,6 @@
22#include "XInputWindow.h"22#include "XInputWindow.h"
23#include "GraphicsDisplayX11.h"23#include "GraphicsDisplayX11.h"
24#include "GLThread.h"24#include "GLThread.h"
25#include "XIMController.h"
2625
27namespace nux26namespace nux
28{27{
@@ -396,8 +395,6 @@
396395
397 void XInputWindow::Hide()396 void XInputWindow::Hide()
398 {397 {
399 GetGraphicsDisplay()->RemoveFocusedWindowForXIMController();
400
401 XMoveResizeWindow(display_, window_,398 XMoveResizeWindow(display_, window_,
402 -100 - geometry_.width,399 -100 - geometry_.width,
403 -100 - geometry_.height,400 -100 - geometry_.height,
@@ -408,8 +405,6 @@
408405
409 void XInputWindow::Show()406 void XInputWindow::Show()
410 {407 {
411 GetGraphicsDisplay()->SetFocusedWindowForXIMController(window_);
412
413 shown_ = true;408 shown_ = true;
414 if (!mapped_)409 if (!mapped_)
415 {410 {
416411
=== modified file 'configure.ac'
--- configure.ac 2013-10-29 22:13:58 +0000
+++ configure.ac 2014-01-03 16:37:28 +0000
@@ -15,7 +15,7 @@
15# 15#
16m4_define([nux_major_version], [4])16m4_define([nux_major_version], [4])
17m4_define([nux_minor_version], [0])17m4_define([nux_minor_version], [0])
18m4_define([nux_micro_version], [4])18m4_define([nux_micro_version], [5])
1919
20m4_define([nux_api_version], [4.0])20m4_define([nux_api_version], [4.0])
21# Increase the number (to the current date) everytime you propose a branch that breaks the API or ABI21# Increase the number (to the current date) everytime you propose a branch that breaks the API or ABI
@@ -23,7 +23,7 @@
23# e.g.: december 5th, 2011 is: 2011120523# e.g.: december 5th, 2011 is: 20111205
24# To make more than one API change in a day, add a number to the date. Like 20111205.xx24# To make more than one API change in a day, add a number to the date. Like 20111205.xx
2525
26m4_define([nux_abi_version], [20131029.0])26m4_define([nux_abi_version], [20131203.0])
27m4_define([nux_version],27m4_define([nux_version],
28 [nux_major_version.nux_minor_version.nux_micro_version])28 [nux_major_version.nux_minor_version.nux_micro_version])
2929
3030
=== modified file 'debian/changelog'
--- debian/changelog 2013-10-29 22:13:58 +0000
+++ debian/changelog 2014-01-03 16:37:28 +0000
@@ -1,3 +1,11 @@
1nux (4.0.5-0ubuntu1) UNRELEASED; urgency=low
2
3 [ Brandon Schaefer ]
4 * Add XIM preedit support
5 * Bump version to 4.0.5
6
7 -- Brandon Schaefer <brandon.schaefer@canonical.com> Fri, 03 Jan 2014 08:31:35 -0800
8
1nux (4.0.4-0ubuntu1) UNRELEASED; urgency=low9nux (4.0.4-0ubuntu1) UNRELEASED; urgency=low
210
3 [ Sam Spilsbury ]11 [ Sam Spilsbury ]

Subscribers

People subscribed via source and target branches