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
=== modified file 'plugins/unityshell/src/DashView.cpp'
--- plugins/unityshell/src/DashView.cpp 2012-03-30 11:40:10 +0000
+++ plugins/unityshell/src/DashView.cpp 2012-04-04 13:26:27 +0000
@@ -806,7 +806,7 @@
806 // DashView::KeyNavIteration.806 // DashView::KeyNavIteration.
807 nux::InputArea* focus_area = nux::GetWindowCompositor().GetKeyFocusArea();807 nux::InputArea* focus_area = nux::GetWindowCompositor().GetKeyFocusArea();
808808
809 if (key_symbol == nux::NUX_KEYDOWN)809 if (key_symbol == nux::NUX_KEYDOWN && !search_bar_->im_preedit)
810 {810 {
811 std::list<nux::Area*> tabs;811 std::list<nux::Area*> tabs;
812 for (auto category : active_lens_view_->categories())812 for (auto category : active_lens_view_->categories())
@@ -881,7 +881,7 @@
881 }881 }
882 }882 }
883883
884 if (direction == KEY_NAV_NONE || search_bar_->im_active)884 if (direction == KEY_NAV_NONE || search_bar_->im_preedit)
885 {885 {
886 // then send the event to the search entry886 // then send the event to the search entry
887 return search_bar_->text_entry();887 return search_bar_->text_entry();
888888
=== modified file 'plugins/unityshell/src/HudView.cpp'
--- plugins/unityshell/src/HudView.cpp 2012-04-01 00:45:53 +0000
+++ plugins/unityshell/src/HudView.cpp 2012-04-04 13:26:27 +0000
@@ -66,7 +66,6 @@
66 , timeline_need_more_draw_(false)66 , timeline_need_more_draw_(false)
67 , selected_button_(0)67 , selected_button_(0)
68 , show_embedded_icon_(true)68 , show_embedded_icon_(true)
69 , activated_signal_sent_(false)
70{69{
71 renderer_.SetOwner(this);70 renderer_.SetOwner(this);
72 renderer_.need_redraw.connect([this] () {71 renderer_.need_redraw.connect([this] () {
@@ -81,11 +80,7 @@
81 SetupViews();80 SetupViews();
82 search_bar_->key_down.connect (sigc::mem_fun (this, &View::OnKeyDown));81 search_bar_->key_down.connect (sigc::mem_fun (this, &View::OnKeyDown));
8382
84 search_bar_->activated.connect ([&]()83 search_bar_->activated.connect (sigc::mem_fun (this, &View::OnSearchbarActivated));
85 {
86 if (!activated_signal_sent_)
87 search_activated.emit(search_bar_->search_string);
88 });
8984
90 search_bar_->text_entry()->SetLoseKeyFocusOnKeyNavDirectionUp(false);85 search_bar_->text_entry()->SetLoseKeyFocusOnKeyNavDirectionUp(false);
91 search_bar_->text_entry()->SetLoseKeyFocusOnKeyNavDirectionDown(false);86 search_bar_->text_entry()->SetLoseKeyFocusOnKeyNavDirectionDown(false);
@@ -500,6 +495,25 @@
500 return false;495 return false;
501}496}
502497
498void View::OnSearchbarActivated()
499{
500 // The "Enter" key has been received and the text entry has the key focus.
501 // If one of the button has the fake_focus, we get it to emit the query_activated signal.
502 if (!buttons_.empty())
503 {
504 std::list<HudButton::Ptr>::iterator it;
505 for(it = buttons_.begin(); it != buttons_.end(); ++it)
506 {
507 if ((*it)->fake_focused)
508 {
509 query_activated.emit((*it)->GetQuery());
510 return;
511 }
512 }
513 }
514 search_activated.emit(search_bar_->search_string);
515}
516
503nux::Area* View::FindKeyFocusArea(unsigned int event_type,517nux::Area* View::FindKeyFocusArea(unsigned int event_type,
504 unsigned long x11_key_code,518 unsigned long x11_key_code,
505 unsigned long special_keys_state)519 unsigned long special_keys_state)
@@ -556,7 +570,7 @@
556 return NULL;570 return NULL;
557 }571 }
558572
559 if (search_bar_->text_entry()->HasKeyFocus())573 if (search_bar_->text_entry()->HasKeyFocus() && !search_bar_->im_preedit)
560 {574 {
561 if (direction == nux::KEY_NAV_NONE ||575 if (direction == nux::KEY_NAV_NONE ||
562 direction == nux::KEY_NAV_UP ||576 direction == nux::KEY_NAV_UP ||
@@ -622,27 +636,11 @@
622636
623 if (event_type == nux::NUX_KEYDOWN && direction == nux::KEY_NAV_ENTER)637 if (event_type == nux::NUX_KEYDOWN && direction == nux::KEY_NAV_ENTER)
624 {638 {
625 activated_signal_sent_ = false;
626 // The "Enter" key has been received and the text entry has the key focus.
627 // If one of the button has the fake_focus, we get it to emit the query_activated signal.
628 if (!buttons_.empty())
629 {
630 std::list<HudButton::Ptr>::iterator it;
631 for(it = buttons_.begin(); it != buttons_.end(); ++it)
632 {
633 if ((*it)->fake_focused)
634 {
635 query_activated.emit((*it)->GetQuery());
636 activated_signal_sent_ = true;
637 }
638 }
639 }
640
641 // We still choose the text_entry as the receiver of the key focus.639 // We still choose the text_entry as the receiver of the key focus.
642 return search_bar_->text_entry();640 return search_bar_->text_entry();
643 }641 }
644 }642 }
645 else if (direction == nux::KEY_NAV_NONE)643 else if (direction == nux::KEY_NAV_NONE || search_bar_->im_preedit)
646 {644 {
647 return search_bar_->text_entry();645 return search_bar_->text_entry();
648 }646 }
@@ -650,7 +648,7 @@
650 {648 {
651 return next_object_to_key_focus_area_->FindKeyFocusArea(event_type, x11_key_code, special_keys_state);649 return next_object_to_key_focus_area_->FindKeyFocusArea(event_type, x11_key_code, special_keys_state);
652 }650 }
653 return NULL;651 return search_bar_->text_entry();
654}652}
655653
656}654}
657655
=== modified file 'plugins/unityshell/src/HudView.h'
--- plugins/unityshell/src/HudView.h 2012-04-01 00:00:45 +0000
+++ plugins/unityshell/src/HudView.h 2012-04-04 13:26:27 +0000
@@ -82,6 +82,7 @@
82 void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);82 void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
83 void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw);83 void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw);
84 bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character);84 bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character);
85 void OnSearchbarActivated();
85 bool AcceptKeyNavFocus();86 bool AcceptKeyNavFocus();
86 nux::Geometry GetBestFitGeometry(nux::Geometry const& for_geo);87 nux::Geometry GetBestFitGeometry(nux::Geometry const& for_geo);
8788
8889
=== modified file 'plugins/unityshell/src/IMTextEntry.cpp'
--- plugins/unityshell/src/IMTextEntry.cpp 2012-03-14 06:24:18 +0000
+++ plugins/unityshell/src/IMTextEntry.cpp 2012-04-04 13:26:27 +0000
@@ -151,4 +151,9 @@
151 Paste(true);151 Paste(true);
152 } 152 }
153}153}
154
155bool IMTextEntry::im_preedit()
156{
157 return !preedit_.empty();
158}
154}159}
155160
=== modified file 'plugins/unityshell/src/IMTextEntry.h'
--- plugins/unityshell/src/IMTextEntry.h 2012-03-14 06:24:18 +0000
+++ plugins/unityshell/src/IMTextEntry.h 2012-04-04 13:26:27 +0000
@@ -39,6 +39,7 @@
39 NUX_DECLARE_OBJECT_TYPE(IMTextEntry, nux::TextEntry);39 NUX_DECLARE_OBJECT_TYPE(IMTextEntry, nux::TextEntry);
40public:40public:
41 IMTextEntry();41 IMTextEntry();
42 bool im_preedit();
4243
43private:44private:
44 bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);45 bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
4546
=== modified file 'plugins/unityshell/src/SearchBar.cpp'
--- plugins/unityshell/src/SearchBar.cpp 2012-03-27 15:20:51 +0000
+++ plugins/unityshell/src/SearchBar.cpp 2012-04-04 13:26:27 +0000
@@ -272,6 +272,7 @@
272 search_string.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_search_string));272 search_string.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_search_string));
273 search_string.SetSetterFunction(sigc::mem_fun(this, &SearchBar::set_search_string));273 search_string.SetSetterFunction(sigc::mem_fun(this, &SearchBar::set_search_string));
274 im_active.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_im_active));274 im_active.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_im_active));
275 im_preedit.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_im_preedit));
275 showing_filters.changed.connect(sigc::mem_fun(this, &SearchBar::OnShowingFiltersChanged));276 showing_filters.changed.connect(sigc::mem_fun(this, &SearchBar::OnShowingFiltersChanged));
276 can_refine_search.changed.connect([&] (bool can_refine)277 can_refine_search.changed.connect([&] (bool can_refine)
277 {278 {
@@ -596,6 +597,11 @@
596 return pango_entry_->im_active();597 return pango_entry_->im_active();
597}598}
598599
600bool SearchBar::get_im_preedit() const
601{
602 return pango_entry_->im_preedit();
603}
604
599//605//
600// Highlight606// Highlight
601//607//
602608
=== modified file 'plugins/unityshell/src/SearchBar.h'
--- plugins/unityshell/src/SearchBar.h 2012-03-27 15:09:26 +0000
+++ plugins/unityshell/src/SearchBar.h 2012-04-04 13:26:27 +0000
@@ -69,6 +69,7 @@
69 nux::Property<bool> showing_filters;69 nux::Property<bool> showing_filters;
70 nux::Property<bool> can_refine_search;70 nux::Property<bool> can_refine_search;
71 nux::ROProperty<bool> im_active;71 nux::ROProperty<bool> im_active;
72 nux::ROProperty<bool> im_preedit;
7273
73 sigc::signal<void> activated;74 sigc::signal<void> activated;
74 sigc::signal<void, std::string const&> search_changed;75 sigc::signal<void, std::string const&> search_changed;
@@ -96,6 +97,7 @@
96 std::string get_search_string() const;97 std::string get_search_string() const;
97 bool set_search_string(std::string const& string);98 bool set_search_string(std::string const& string);
98 bool get_im_active() const;99 bool get_im_active() const;
100 bool get_im_preedit() const;
99 bool show_filter_hint_;101 bool show_filter_hint_;
100102
101 static gboolean OnLiveSearchTimeout(SearchBar* self);103 static gboolean OnLiveSearchTimeout(SearchBar* self);
102104
=== modified file 'tests/autopilot/autopilot/tests/test_ibus.py'
--- tests/autopilot/autopilot/tests/test_ibus.py 2012-04-02 20:18:58 +0000
+++ tests/autopilot/autopilot/tests/test_ibus.py 2012-04-04 13:26:27 +0000
@@ -161,3 +161,73 @@
161 self.hud.ensure_hidden()161 self.hud.ensure_hidden()
162162
163 self.assertEqual(self.result, hud_search_string)163 self.assertEqual(self.result, hud_search_string)
164
165
166class IBusTestsPinyinIgnore(IBusTests):
167 """Tests for ignoring key events while the Pinyin input engine is active."""
168
169 def test_ignore_key_events_on_dash(self):
170 self.activate_input_engine_or_skip("pinyin")
171 self.dash.ensure_visible()
172 sleep(0.5)
173 self.activate_ibus()
174 sleep(0.5)
175 self.keyboard.type("cipan")
176 self.keyboard.press_and_release("Tab")
177 self.keyboard.type(" ")
178 dash_search_string = self.dash.get_searchbar().search_string
179 self.deactivate_ibus()
180 self.dash.ensure_hidden()
181
182 self.assertNotEqual(" ", dash_search_string)
183
184 def test_ignore_key_events_on_hud(self):
185 self.activate_input_engine_or_skip("pinyin")
186 self.hud.ensure_visible()
187 sleep(0.5)
188 self.keyboard.type("a")
189 self.activate_ibus()
190 sleep(0.5)
191 self.keyboard.type("riqi")
192 old_selected = self.hud.selected_button
193 self.keyboard.press_and_release("Down")
194 new_selected = self.hud.selected_button
195 self.deactivate_ibus()
196 self.hud.ensure_hidden()
197
198 self.assertEqual(old_selected, new_selected)
199
200
201class IBusTestsAnthyIgnore(IBusTests):
202 """Tests for ignoring key events while the Anthy input engine is active."""
203
204 def test_ignore_key_events_on_dash(self):
205 self.activate_input_engine_or_skip("anthy")
206 self.dash.ensure_visible()
207 sleep(0.5)
208 self.activate_ibus()
209 sleep(0.5)
210 self.keyboard.type("shisutemu ")
211 self.keyboard.press_and_release("Tab")
212 self.keyboard.press_and_release("Ctrl+j")
213 dash_search_string = self.dash.get_searchbar().search_string
214 self.deactivate_ibus()
215 self.dash.ensure_hidden()
216
217 self.assertNotEqual("", dash_search_string)
218
219 def test_ignore_key_events_on_hud(self):
220 self.activate_input_engine_or_skip("anthy")
221 self.hud.ensure_visible()
222 sleep(0.5)
223 self.keyboard.type("a")
224 self.activate_ibus()
225 sleep(0.5)
226 self.keyboard.type("hiduke")
227 old_selected = self.hud.selected_button
228 self.keyboard.press_and_release("Down")
229 new_selected = self.hud.selected_button
230 self.deactivate_ibus()
231 self.hud.ensure_hidden()
232
233 self.assertEqual(old_selected, new_selected)