Merge lp:~3v1n0/unity/session-view-close-by-escape-key into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3203
Proposed branch: lp:~3v1n0/unity/session-view-close-by-escape-key
Merge into: lp:unity
Diff against target: 72 lines (+23/-3)
3 files modified
shutdown/SessionView.cpp (+2/-1)
tests/test_unity_window_view.cpp (+15/-2)
unity-shared/UnityWindowView.cpp (+6/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/session-view-close-by-escape-key
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Andrea Azzarone (community) Approve
Review via email: mp+152489@code.launchpad.net

Commit message

UnityWindowView: Close a window also on escape key

Description of the change

A closable UnityWindowView can now be closed by Escape key... Shutdown view will be happy for this! ;)

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
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/SessionView.cpp'
2--- shutdown/SessionView.cpp 2013-03-08 18:23:59 +0000
3+++ shutdown/SessionView.cpp 2013-03-08 19:56:22 +0000
4@@ -296,7 +296,8 @@
5 {
6 nux::InputArea* focused = nux::GetWindowCompositor().GetKeyFocusArea();
7
8- if (!focused || !focused->IsMouseInside())
9+ // Let's reset the focused area if we're in keyboard-navigation mode.
10+ if (focused && focused->IsChildOf(buttons_layout_) && !focused->IsMouseInside())
11 return this;
12 }
13
14
15=== modified file 'tests/test_unity_window_view.cpp'
16--- tests/test_unity_window_view.cpp 2013-03-07 17:34:29 +0000
17+++ tests/test_unity_window_view.cpp 2013-03-08 19:56:22 +0000
18@@ -125,7 +125,6 @@
19 TEST_F(TestUnityWindowView, WindowManagerCloseKeyRequestsClose)
20 {
21 view.closable = true;
22- ASSERT_NE(view.close_button_, nullptr);
23
24 auto& close_key = WindowManager::Default().close_window_key;
25 close_key = std::make_pair(nux::KEY_MODIFIER_ALT, g_random_int());
26@@ -140,7 +139,6 @@
27 TEST_F(TestUnityWindowView, WindowManagerCloseKeyRequestsCloseWithCaps)
28 {
29 view.closable = true;
30- ASSERT_NE(view.close_button_, nullptr);
31
32 auto& close_key = WindowManager::Default().close_window_key;
33 close_key = std::make_pair(nux::KEY_MODIFIER_ALT, g_random_int());
34@@ -153,6 +151,21 @@
35 EXPECT_TRUE(close_requested);
36 }
37
38+TEST_F(TestUnityWindowView, EscapeKeyRequestsClose)
39+{
40+ view.closable = true;
41+
42+ bool close_requested = false;
43+ view.request_close.connect([&close_requested] { close_requested = true; });
44+
45+ view.FindKeyFocusArea(nux::NUX_KEYDOWN, NUX_VK_ESCAPE, 0);
46+ EXPECT_TRUE(close_requested);
47+
48+ close_requested = false;
49+ view.closable = false;
50+ EXPECT_FALSE(close_requested);
51+}
52+
53 TEST_F(TestUnityWindowView, QueueDrawsOnCloseTextureUpdate)
54 {
55 view.closable = true;
56
57=== modified file 'unity-shared/UnityWindowView.cpp'
58--- unity-shared/UnityWindowView.cpp 2013-03-04 18:35:57 +0000
59+++ unity-shared/UnityWindowView.cpp 2013-03-08 19:56:22 +0000
60@@ -94,6 +94,12 @@
61 request_close.emit();
62 return nullptr;
63 }
64+
65+ if (key_code == NUX_VK_ESCAPE)
66+ {
67+ request_close.emit();
68+ return nullptr;
69+ }
70 }
71
72 return View::FindKeyFocusArea(etype, key_code, modifiers);