Merge lp:~vbkaisetsu/unity/bug957927 into lp:unity

Proposed by Koichi Akabe
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 2229
Proposed branch: lp:~vbkaisetsu/unity/bug957927
Merge into: lp:unity
Diff against target: 279 lines (+110/-27)
8 files modified
plugins/unityshell/src/DashView.cpp (+2/-2)
plugins/unityshell/src/HudView.cpp (+23/-25)
plugins/unityshell/src/HudView.h (+1/-0)
plugins/unityshell/src/IMTextEntry.cpp (+5/-0)
plugins/unityshell/src/IMTextEntry.h (+1/-0)
plugins/unityshell/src/SearchBar.cpp (+6/-0)
plugins/unityshell/src/SearchBar.h (+2/-0)
tests/autopilot/autopilot/tests/test_ibus.py (+70/-0)
To merge this branch: bzr merge lp:~vbkaisetsu/unity/bug957927
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
Gord Allott (community) Approve
Alex Launi (community) Needs Fixing
Review via email: mp+98057@code.launchpad.net

Commit message

Ensures hud ignores key presses once ibus is active

Description of the change

I fixed bug #957927
Please merge this branch.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Hi Koichi, thanks for your patch.
However, you need to sign the Canonical Contributor Agreement to get it merged.

Revision history for this message
Koichi Akabe (vbkaisetsu) wrote :

Hi,
Thank you for your information.
I sent the CCA on the internet just now.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ok, the agreement is there.
So, I guess we need to wait the nux branch to be merged.

Revision history for this message
Alex Launi (alexlauni) wrote :

This needs a test. It should be very simple to write an autopilot test to ensure that this does not regress. Please ping me, or anyone else on irc if you need help with autopilot testing.

review: Needs Fixing
Revision history for this message
Koichi Akabe (vbkaisetsu) wrote :

Hi Alex,
I added autopilot codes for ibus-anthy and ibus-pinyin. But I didn't add for ibus-hangul because it commits hangul on input components.

Please review it.

Revision history for this message
Gord Allott (gordallott) wrote :

+1 here

review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

This needs to be merged with trunk, other than that it's fine.

Revision history for this message
Koichi Akabe (vbkaisetsu) wrote :

It has many changes, but I think it was merged correctly.

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

Looks good to me. +1.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/DashView.cpp'
2--- plugins/unityshell/src/DashView.cpp 2012-03-30 11:40:10 +0000
3+++ plugins/unityshell/src/DashView.cpp 2012-04-04 13:26:27 +0000
4@@ -806,7 +806,7 @@
5 // DashView::KeyNavIteration.
6 nux::InputArea* focus_area = nux::GetWindowCompositor().GetKeyFocusArea();
7
8- if (key_symbol == nux::NUX_KEYDOWN)
9+ if (key_symbol == nux::NUX_KEYDOWN && !search_bar_->im_preedit)
10 {
11 std::list<nux::Area*> tabs;
12 for (auto category : active_lens_view_->categories())
13@@ -881,7 +881,7 @@
14 }
15 }
16
17- if (direction == KEY_NAV_NONE || search_bar_->im_active)
18+ if (direction == KEY_NAV_NONE || search_bar_->im_preedit)
19 {
20 // then send the event to the search entry
21 return search_bar_->text_entry();
22
23=== modified file 'plugins/unityshell/src/HudView.cpp'
24--- plugins/unityshell/src/HudView.cpp 2012-04-01 00:45:53 +0000
25+++ plugins/unityshell/src/HudView.cpp 2012-04-04 13:26:27 +0000
26@@ -66,7 +66,6 @@
27 , timeline_need_more_draw_(false)
28 , selected_button_(0)
29 , show_embedded_icon_(true)
30- , activated_signal_sent_(false)
31 {
32 renderer_.SetOwner(this);
33 renderer_.need_redraw.connect([this] () {
34@@ -81,11 +80,7 @@
35 SetupViews();
36 search_bar_->key_down.connect (sigc::mem_fun (this, &View::OnKeyDown));
37
38- search_bar_->activated.connect ([&]()
39- {
40- if (!activated_signal_sent_)
41- search_activated.emit(search_bar_->search_string);
42- });
43+ search_bar_->activated.connect (sigc::mem_fun (this, &View::OnSearchbarActivated));
44
45 search_bar_->text_entry()->SetLoseKeyFocusOnKeyNavDirectionUp(false);
46 search_bar_->text_entry()->SetLoseKeyFocusOnKeyNavDirectionDown(false);
47@@ -500,6 +495,25 @@
48 return false;
49 }
50
51+void View::OnSearchbarActivated()
52+{
53+ // The "Enter" key has been received and the text entry has the key focus.
54+ // If one of the button has the fake_focus, we get it to emit the query_activated signal.
55+ if (!buttons_.empty())
56+ {
57+ std::list<HudButton::Ptr>::iterator it;
58+ for(it = buttons_.begin(); it != buttons_.end(); ++it)
59+ {
60+ if ((*it)->fake_focused)
61+ {
62+ query_activated.emit((*it)->GetQuery());
63+ return;
64+ }
65+ }
66+ }
67+ search_activated.emit(search_bar_->search_string);
68+}
69+
70 nux::Area* View::FindKeyFocusArea(unsigned int event_type,
71 unsigned long x11_key_code,
72 unsigned long special_keys_state)
73@@ -556,7 +570,7 @@
74 return NULL;
75 }
76
77- if (search_bar_->text_entry()->HasKeyFocus())
78+ if (search_bar_->text_entry()->HasKeyFocus() && !search_bar_->im_preedit)
79 {
80 if (direction == nux::KEY_NAV_NONE ||
81 direction == nux::KEY_NAV_UP ||
82@@ -622,27 +636,11 @@
83
84 if (event_type == nux::NUX_KEYDOWN && direction == nux::KEY_NAV_ENTER)
85 {
86- activated_signal_sent_ = false;
87- // The "Enter" key has been received and the text entry has the key focus.
88- // If one of the button has the fake_focus, we get it to emit the query_activated signal.
89- if (!buttons_.empty())
90- {
91- std::list<HudButton::Ptr>::iterator it;
92- for(it = buttons_.begin(); it != buttons_.end(); ++it)
93- {
94- if ((*it)->fake_focused)
95- {
96- query_activated.emit((*it)->GetQuery());
97- activated_signal_sent_ = true;
98- }
99- }
100- }
101-
102 // We still choose the text_entry as the receiver of the key focus.
103 return search_bar_->text_entry();
104 }
105 }
106- else if (direction == nux::KEY_NAV_NONE)
107+ else if (direction == nux::KEY_NAV_NONE || search_bar_->im_preedit)
108 {
109 return search_bar_->text_entry();
110 }
111@@ -650,7 +648,7 @@
112 {
113 return next_object_to_key_focus_area_->FindKeyFocusArea(event_type, x11_key_code, special_keys_state);
114 }
115- return NULL;
116+ return search_bar_->text_entry();
117 }
118
119 }
120
121=== modified file 'plugins/unityshell/src/HudView.h'
122--- plugins/unityshell/src/HudView.h 2012-04-01 00:00:45 +0000
123+++ plugins/unityshell/src/HudView.h 2012-04-04 13:26:27 +0000
124@@ -82,6 +82,7 @@
125 void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
126 void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw);
127 bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character);
128+ void OnSearchbarActivated();
129 bool AcceptKeyNavFocus();
130 nux::Geometry GetBestFitGeometry(nux::Geometry const& for_geo);
131
132
133=== modified file 'plugins/unityshell/src/IMTextEntry.cpp'
134--- plugins/unityshell/src/IMTextEntry.cpp 2012-03-14 06:24:18 +0000
135+++ plugins/unityshell/src/IMTextEntry.cpp 2012-04-04 13:26:27 +0000
136@@ -151,4 +151,9 @@
137 Paste(true);
138 }
139 }
140+
141+bool IMTextEntry::im_preedit()
142+{
143+ return !preedit_.empty();
144+}
145 }
146
147=== modified file 'plugins/unityshell/src/IMTextEntry.h'
148--- plugins/unityshell/src/IMTextEntry.h 2012-03-14 06:24:18 +0000
149+++ plugins/unityshell/src/IMTextEntry.h 2012-04-04 13:26:27 +0000
150@@ -39,6 +39,7 @@
151 NUX_DECLARE_OBJECT_TYPE(IMTextEntry, nux::TextEntry);
152 public:
153 IMTextEntry();
154+ bool im_preedit();
155
156 private:
157 bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
158
159=== modified file 'plugins/unityshell/src/SearchBar.cpp'
160--- plugins/unityshell/src/SearchBar.cpp 2012-03-27 15:20:51 +0000
161+++ plugins/unityshell/src/SearchBar.cpp 2012-04-04 13:26:27 +0000
162@@ -272,6 +272,7 @@
163 search_string.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_search_string));
164 search_string.SetSetterFunction(sigc::mem_fun(this, &SearchBar::set_search_string));
165 im_active.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_im_active));
166+ im_preedit.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_im_preedit));
167 showing_filters.changed.connect(sigc::mem_fun(this, &SearchBar::OnShowingFiltersChanged));
168 can_refine_search.changed.connect([&] (bool can_refine)
169 {
170@@ -596,6 +597,11 @@
171 return pango_entry_->im_active();
172 }
173
174+bool SearchBar::get_im_preedit() const
175+{
176+ return pango_entry_->im_preedit();
177+}
178+
179 //
180 // Highlight
181 //
182
183=== modified file 'plugins/unityshell/src/SearchBar.h'
184--- plugins/unityshell/src/SearchBar.h 2012-03-27 15:09:26 +0000
185+++ plugins/unityshell/src/SearchBar.h 2012-04-04 13:26:27 +0000
186@@ -69,6 +69,7 @@
187 nux::Property<bool> showing_filters;
188 nux::Property<bool> can_refine_search;
189 nux::ROProperty<bool> im_active;
190+ nux::ROProperty<bool> im_preedit;
191
192 sigc::signal<void> activated;
193 sigc::signal<void, std::string const&> search_changed;
194@@ -96,6 +97,7 @@
195 std::string get_search_string() const;
196 bool set_search_string(std::string const& string);
197 bool get_im_active() const;
198+ bool get_im_preedit() const;
199 bool show_filter_hint_;
200
201 static gboolean OnLiveSearchTimeout(SearchBar* self);
202
203=== modified file 'tests/autopilot/autopilot/tests/test_ibus.py'
204--- tests/autopilot/autopilot/tests/test_ibus.py 2012-04-02 20:18:58 +0000
205+++ tests/autopilot/autopilot/tests/test_ibus.py 2012-04-04 13:26:27 +0000
206@@ -161,3 +161,73 @@
207 self.hud.ensure_hidden()
208
209 self.assertEqual(self.result, hud_search_string)
210+
211+
212+class IBusTestsPinyinIgnore(IBusTests):
213+ """Tests for ignoring key events while the Pinyin input engine is active."""
214+
215+ def test_ignore_key_events_on_dash(self):
216+ self.activate_input_engine_or_skip("pinyin")
217+ self.dash.ensure_visible()
218+ sleep(0.5)
219+ self.activate_ibus()
220+ sleep(0.5)
221+ self.keyboard.type("cipan")
222+ self.keyboard.press_and_release("Tab")
223+ self.keyboard.type(" ")
224+ dash_search_string = self.dash.get_searchbar().search_string
225+ self.deactivate_ibus()
226+ self.dash.ensure_hidden()
227+
228+ self.assertNotEqual(" ", dash_search_string)
229+
230+ def test_ignore_key_events_on_hud(self):
231+ self.activate_input_engine_or_skip("pinyin")
232+ self.hud.ensure_visible()
233+ sleep(0.5)
234+ self.keyboard.type("a")
235+ self.activate_ibus()
236+ sleep(0.5)
237+ self.keyboard.type("riqi")
238+ old_selected = self.hud.selected_button
239+ self.keyboard.press_and_release("Down")
240+ new_selected = self.hud.selected_button
241+ self.deactivate_ibus()
242+ self.hud.ensure_hidden()
243+
244+ self.assertEqual(old_selected, new_selected)
245+
246+
247+class IBusTestsAnthyIgnore(IBusTests):
248+ """Tests for ignoring key events while the Anthy input engine is active."""
249+
250+ def test_ignore_key_events_on_dash(self):
251+ self.activate_input_engine_or_skip("anthy")
252+ self.dash.ensure_visible()
253+ sleep(0.5)
254+ self.activate_ibus()
255+ sleep(0.5)
256+ self.keyboard.type("shisutemu ")
257+ self.keyboard.press_and_release("Tab")
258+ self.keyboard.press_and_release("Ctrl+j")
259+ dash_search_string = self.dash.get_searchbar().search_string
260+ self.deactivate_ibus()
261+ self.dash.ensure_hidden()
262+
263+ self.assertNotEqual("", dash_search_string)
264+
265+ def test_ignore_key_events_on_hud(self):
266+ self.activate_input_engine_or_skip("anthy")
267+ self.hud.ensure_visible()
268+ sleep(0.5)
269+ self.keyboard.type("a")
270+ self.activate_ibus()
271+ sleep(0.5)
272+ self.keyboard.type("hiduke")
273+ old_selected = self.hud.selected_button
274+ self.keyboard.press_and_release("Down")
275+ new_selected = self.hud.selected_button
276+ self.deactivate_ibus()
277+ self.hud.ensure_hidden()
278+
279+ self.assertEqual(old_selected, new_selected)