Merge lp:~sil2100/unity/fix_alt_tab_horrors_6.0 into lp:unity/6.0

Proposed by Łukasz Zemczak
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 2792
Proposed branch: lp:~sil2100/unity/fix_alt_tab_horrors_6.0
Merge into: lp:unity/6.0
Diff against target: 82 lines (+35/-1)
3 files modified
launcher/SwitcherController.cpp (+8/-1)
launcher/SwitcherController.h (+2/-0)
tests/autopilot/unity/tests/test_switcher.py (+25/-0)
To merge this branch: bzr merge lp:~sil2100/unity/fix_alt_tab_horrors_6.0
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+132159@code.launchpad.net

Commit message

Cherry-picked rev 2870 from lp:unity:
A workaround fix for Alt+TAB picking up wrong window when used on a application group. The check for Quirk::ACTIVE is not valid right now due to the fact we're making the switcher window active prior to display (this is done this way to fix some other bugs). So a workaround is to save the last active window prior to this action and use this during the checks. It fixes a very annoying bug.

Description of the change

- Problem

When tapping Alt+Tab not-too-fast (not doing a quick-tap) when having 2 same application windows, the focus doesn't change to the next window of the application, but stays on the currently active window. It should switch to the next window, just as it does for a quick tap.

- Fix

It's actually fixed with a workaround. The bug appeared actually because we're focusing the switcher window when the switcher is being shown (therefore fixing a few other bugs). But because of this, the Quirk::ACTIVE is on the switcher window, not on the last active window. Because fixing it the right way would probably need more thinking, this is a quick workaround fix.
What we're doing is: we save the last focused/active window before showing the switcher, and using this one as a reference for switching.

- Tests

Covered by 2 autopilot tests.

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) :
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-09-28 13:24:37 +0000
3+++ launcher/SwitcherController.cpp 2012-10-30 16:14:24 +0000
4@@ -94,6 +94,11 @@
5
6 SelectFirstItem();
7
8+ // XXX: Workaround for a problem related to Alt+TAB which is needed since the
9+ // switcher is set as the active window (LP: #1071298)
10+ if (model_->Selection()->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE))
11+ last_active_selection_ = model_->Selection();
12+
13 visible_ = true;
14
15 if (timeout_length > 0)
16@@ -239,7 +244,7 @@
17 }
18 else
19 {
20- if (selection->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE) &&
21+ if (selection == last_active_selection_ &&
22 !model_->DetailXids().empty ())
23 {
24 selection->Activate(ActionArg (ActionArg::SWITCHER, 0, model_->DetailXids()[0]));
25@@ -274,6 +279,8 @@
26
27 ubus_manager_.SendMessage(UBUS_SWITCHER_SHOWN, g_variant_new("(bi)", false, monitor_));
28
29+ last_active_selection_ = nullptr;
30+
31 view_.Release();
32 }
33
34
35=== modified file 'launcher/SwitcherController.h'
36--- launcher/SwitcherController.h 2012-09-28 13:24:37 +0000
37+++ launcher/SwitcherController.h 2012-10-30 16:14:24 +0000
38@@ -138,6 +138,8 @@
39 nux::Color bg_color_;
40 DetailMode detail_mode_;
41
42+ launcher::AbstractLauncherIcon::Ptr last_active_selection_;
43+
44 UBusManager ubus_manager_;
45 glib::SourceManager sources_;
46 };
47
48=== modified file 'tests/autopilot/unity/tests/test_switcher.py'
49--- tests/autopilot/unity/tests/test_switcher.py 2012-10-12 12:57:35 +0000
50+++ tests/autopilot/unity/tests/test_switcher.py 2012-10-30 16:14:24 +0000
51@@ -246,6 +246,31 @@
52 self.assertProperty(calc_win, is_focused=True)
53 self.assertVisibleWindowStack([calc_win, char_win1])
54
55+ def test_switcher_rises_next_window_of_same_application(self):
56+ """Tests if alt+tab invoked normally switches to the next application
57+ window of the same type.
58+
59+ """
60+ char_win1, char_win2 = self.start_applications("Character Map", "Character Map")
61+ self.assertVisibleWindowStack([char_win2, char_win1])
62+
63+ self.keybinding("switcher/reveal_normal")
64+ self.assertProperty(char_win1, is_focused=True)
65+
66+ def test_switcher_rises_other_application(self):
67+ """Tests if alt+tab invoked normally switches correctly to the other
68+ application window when the last focused application had 2 windows
69+
70+ """
71+ char_win1, char_win2, calc_win = self.start_applications("Character Map", "Character Map", "Calculator")
72+ self.assertVisibleWindowStack([calc_win, char_win2, char_win1])
73+
74+ self.keybinding("switcher/reveal_normal")
75+ self.assertProperty(char_win2, is_focused=True)
76+
77+ self.keybinding("switcher/reveal_normal")
78+ self.assertProperty(calc_win, is_focused=True)
79+
80
81 class SwitcherDetailsTests(SwitcherTestCase):
82 """Test the details mode for the switcher."""

Subscribers

People subscribed via source and target branches