Merge lp:~sil2100/unity/fix_987156_2 into lp:unity

Proposed by Łukasz Zemczak
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 2386
Proposed branch: lp:~sil2100/unity/fix_987156_2
Merge into: lp:unity
Diff against target: 90 lines (+53/-2)
3 files modified
launcher/SwitcherController.cpp (+3/-2)
manual-tests/Switcher.txt (+39/-0)
tests/test_switcher_controller.cpp (+11/-0)
To merge this branch: bzr merge lp:~sil2100/unity/fix_987156_2
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+108360@code.launchpad.net

Commit message

Don't show the switcher window during constructing the view. Wait for the ShowView timeout.

Description of the change

Problem description:

Both alt+tab and alt+keyabovetab, during a quick-tap, should not show the switcher but just switch to the nearest application window (as defined). The alt+keyabovetab though suffers from a problem of showing a partial creation of the switcher on most quick taps of the combination.
This is a result of the idle timer preparing the whole view before the switcher timeout. The view and switcher window is created earlier and the SwitcherView renders the model detail-mode window previews right after the idle timer constructs it.

The fix:

Since the idle timer is a way of making the switcher loading faster, we cannot remove it. But we can move the ShowWindow() call of the switcher window to the switcher timeout (from ConstructView() to ShowView()). The ShowWindow() call from Nux is a fast function that does not do much computation, so calling it during the idle timer does not have much optimization value. By making the window appear only when the view should be shown, we are not loosing anything, while we are making sure that the switcher will not appear by accident before ShowView() is called.

Test coverage:

The fix is accompanied with a GMock test (for testing if ShowView() is called) and two manual-test testing the behavior of alt+keyabovetab. So the modifications should be well tested.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/SwitcherController.cpp'
2--- launcher/SwitcherController.cpp 2012-05-07 19:52:54 +0000
3+++ launcher/SwitcherController.cpp 2012-06-01 15:12:24 +0000
4@@ -190,8 +190,10 @@
5
6 ConstructView();
7
8- if (view_window_)
9+ if (view_window_) {
10+ view_window_->ShowWindow(true);
11 view_window_->SetOpacity(1.0f);
12+ }
13 }
14
15 void Controller::ConstructWindow()
16@@ -238,7 +240,6 @@
17 main_layout_->AddView(view_.GetPointer(), 1);
18 view_window_->SetGeometry(workarea_);
19 view_window_->SetOpacity(0.0f);
20- view_window_->ShowWindow(true);
21 }
22
23 void Controller::SetWorkspace(nux::Geometry geo, int monitor)
24
25=== modified file 'manual-tests/Switcher.txt'
26--- manual-tests/Switcher.txt 2012-04-18 07:40:40 +0000
27+++ manual-tests/Switcher.txt 2012-06-01 15:12:24 +0000
28@@ -56,3 +56,42 @@
29
30 Outcome
31 The title of the newly created window should be "显示桌面" and *not* "显示桌...".
32+
33+
34+Alt+keyabovetab switching
35+------------------------------
36+This test ensures that alt+keyabovetab switching windows of the application
37+works as it should.
38+
39+Setup:
40+#. Have a few windows of one application open (e.g. 3 terminal windows).
41+
42+Action:
43+#. Focus one of the opened application windows.
44+#. Press Alt+keyabovetab (the ~ key on the US and PL keyboard).
45+#. Keep the Alt key pressed.
46+
47+Outcome
48+ The switcher should appear with the detail view for the given application
49+ (e.g. the terminal), with all terminal applications for the workspace
50+ visible. The switcher should look normally.
51+
52+
53+Fast alt+keyabovetab switching
54+------------------------------
55+This test ensures that doing a fast tap does not result in any 'flickering' of
56+the switcher window. The switcher should not appear during a quick tap, just
57+during longer alt+keyabovetab presses.
58+
59+Setup:
60+#. Have a few windows of one application open (e.g. 3 terminal windows)
61+
62+Action:
63+#. Focus one of the opened application windows.
64+#. Quickly tap Alt+keyabovetab (meaning only tap once, do not hold)
65+#. Repeat at least a few times
66+
67+Outcome
68+ On every quick tap, the focus should switch to the next same-application
69+ type window. During that switch the switcher should not appear, not even
70+ for a brief moment (if done fast enough). No 'flickering' of the switcher.
71
72=== modified file 'tests/test_switcher_controller.cpp'
73--- tests/test_switcher_controller.cpp 2012-03-27 18:53:21 +0000
74+++ tests/test_switcher_controller.cpp 2012-06-01 15:12:24 +0000
75@@ -156,4 +156,15 @@
76 EXPECT_TRUE(unity::TimeUtil::TimeDelta(&controller.detail_timespec_, &current) >= 1000);
77 }
78
79+TEST(TestSwitcherController, ShowSwitcher)
80+{
81+ MockSwitcherController controller;
82+ std::vector<unity::launcher::AbstractLauncherIcon::Ptr> results;
83+
84+ controller.Show(ShowMode::ALL, SortMode::LAUNCHER_ORDER, false, results);
85+
86+ Utils::WaitUntil(controller.view_shown_, 2);
87+ ASSERT_TRUE(controller.view_shown_);
88+}
89+
90 }