Merge lp:~3v1n0/unity/session-keyselect-default-button into lp:unity

Proposed by Marco Trevisan (Treviño) on 2013-03-19
Status: Merged
Approved by: Andrea Azzarone on 2013-03-19
Approved revision: 3239
Merged at revision: 3236
Proposed branch: lp:~3v1n0/unity/session-keyselect-default-button
Merge into: lp:unity
Prerequisite: lp:~3v1n0/unity/session-shutdown-buttons-reorder
Diff against target: 119 lines (+13/-2)
5 files modified
shutdown/SessionController.cpp (+1/-1)
shutdown/SessionView.cpp (+5/-0)
shutdown/SessionView.h (+2/-0)
tests/test_session_controller.cpp (+1/-1)
tests/test_session_view.cpp (+4/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/session-keyselect-default-button
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve on 2013-03-19
Andrea Azzarone (community) 2013-03-19 Approve on 2013-03-19
Review via email: mp+154135@code.launchpad.net

Commit message

SessionController: set the view's default action button as key-focus area on init

Description of the change

Adding a new parameter to the SessionView that defines the area to be key-focused on initialization.
And this will be the logout-button on logout and the shutdown-button on shutdown.

New tests added.

To post a comment you must log in.
Andrea Azzarone (azzar1) :
review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'shutdown/SessionController.cpp'
2--- shutdown/SessionController.cpp 2013-03-07 22:42:29 +0000
3+++ shutdown/SessionController.cpp 2013-03-19 16:19:27 +0000
4@@ -107,7 +107,7 @@
5 view_window_->ShowWindow(true);
6 view_window_->PushToFront();
7 view_window_->SetInputFocus();
8- nux::GetWindowCompositor().SetKeyFocusArea(view_.GetPointer());
9+ nux::GetWindowCompositor().SetKeyFocusArea(view_->key_focus_area());
10
11 if (fade_animator_.CurrentState() == na::Animation::State::Running)
12 {
13
14=== modified file 'shutdown/SessionView.cpp'
15--- shutdown/SessionView.cpp 2013-03-19 16:19:27 +0000
16+++ shutdown/SessionView.cpp 2013-03-19 16:19:27 +0000
17@@ -47,7 +47,9 @@
18
19 View::View(Manager::Ptr const& manager)
20 : mode(Mode::FULL)
21+ , key_focus_area([this] { return key_focus_area_; })
22 , manager_(manager)
23+ , key_focus_area_(this)
24 {
25 closable = true;
26 auto main_layout = new nux::VLayout();
27@@ -170,6 +172,7 @@
28 {
29 debug::Introspectable::RemoveAllChildren();
30 buttons_layout_->Clear();
31+ key_focus_area_ = this;
32
33 if (mode() == Mode::LOGOUT)
34 {
35@@ -179,6 +182,7 @@
36
37 button = new Button(Button::Action::LOGOUT, NUX_TRACKER_LOCATION);
38 button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Logout));
39+ key_focus_area_ = button;
40 AddButton(button);
41 }
42 else
43@@ -212,6 +216,7 @@
44
45 button = new Button(Button::Action::SHUTDOWN, NUX_TRACKER_LOCATION);
46 button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Shutdown));
47+ key_focus_area_ = (mode() == Mode::SHUTDOWN) ? button : key_focus_area_;
48 AddButton(button);
49 }
50 else if (mode() == Mode::FULL)
51
52=== modified file 'shutdown/SessionView.h'
53--- shutdown/SessionView.h 2013-03-07 19:26:40 +0000
54+++ shutdown/SessionView.h 2013-03-19 16:19:27 +0000
55@@ -50,6 +50,7 @@
56
57 nux::Property<Mode> mode;
58 nux::Property<bool> have_inhibitors;
59+ nux::ROProperty<nux::InputArea*> key_focus_area;
60
61 sigc::signal<void> request_hide;
62
63@@ -76,6 +77,7 @@
64 StaticCairoText* title_;
65 StaticCairoText* subtitle_;
66 nux::HLayout* buttons_layout_;
67+ nux::InputArea* key_focus_area_;
68 };
69
70 } // namespace session
71
72=== modified file 'tests/test_session_controller.cpp'
73--- tests/test_session_controller.cpp 2013-03-07 22:42:29 +0000
74+++ tests/test_session_controller.cpp 2013-03-19 16:19:27 +0000
75@@ -70,7 +70,7 @@
76 controller.Show(GetParam());
77 EXPECT_TRUE(controller.Visible());
78 EXPECT_EQ(controller.view_->mode(), GetParam());
79- EXPECT_EQ(nux::GetWindowCompositor().GetKeyFocusArea(), controller.view_.GetPointer());
80+ EXPECT_EQ(nux::GetWindowCompositor().GetKeyFocusArea(), controller.view_->key_focus_area());
81 EXPECT_TRUE(controller.view_->live_background());
82 }
83
84
85=== modified file 'tests/test_session_view.cpp'
86--- tests/test_session_view.cpp 2013-03-19 16:19:27 +0000
87+++ tests/test_session_view.cpp 2013-03-19 16:19:27 +0000
88@@ -101,6 +101,7 @@
89 EXPECT_TRUE(view.closable());
90 EXPECT_FALSE(view.have_inhibitors());
91 EXPECT_EQ(view.mode(), View::Mode::FULL);
92+ EXPECT_EQ(view.key_focus_area(), &view);
93 }
94
95 TEST_F(TestSessionView, RequestCloseOnBoundingAreaClick)
96@@ -149,6 +150,7 @@
97 EXPECT_EQ(view.GetButtonPosition(Button::Action::HIBERNATE), 2);
98 EXPECT_EQ(view.GetButtonPosition(Button::Action::REBOOT), 3);
99 EXPECT_EQ(view.GetButtonPosition(Button::Action::SHUTDOWN), 4);
100+ EXPECT_EQ(view.key_focus_area(), &view);
101
102 ON_CALL(*manager, CanShutdown()).WillByDefault(testing::Return(false));
103 view.mode.changed.emit(View::Mode::FULL);
104@@ -176,6 +178,7 @@
105 EXPECT_EQ(view.GetButtons().size(), 2);
106 EXPECT_EQ(view.GetButtonPosition(Button::Action::REBOOT), 0);
107 EXPECT_EQ(view.GetButtonPosition(Button::Action::SHUTDOWN), 1);
108+ EXPECT_EQ(view.key_focus_area(), view.GetButtonByAction(Button::Action::SHUTDOWN));
109 }
110
111 TEST_F(TestSessionView, LogoutModeButtons)
112@@ -185,6 +188,7 @@
113 EXPECT_EQ(view.GetButtons().size(), 2);
114 EXPECT_EQ(view.GetButtonPosition(Button::Action::LOCK), 0);
115 EXPECT_EQ(view.GetButtonPosition(Button::Action::LOGOUT), 1);
116+ EXPECT_EQ(view.key_focus_area(), view.GetButtonByAction(Button::Action::LOGOUT));
117 }
118
119 TEST_F(TestSessionView, FullModeTitle)