Merge lp:~3v1n0/unity/quick-alt+tab-fixes.stable into lp:unity/4.0

Proposed by Marco Trevisan (Treviño)
Status: Work in progress
Proposed branch: lp:~3v1n0/unity/quick-alt+tab-fixes.stable
Merge into: lp:unity/4.0
Diff against target: 199 lines (+82/-36)
5 files modified
manual-tests/QuickAltTab.txt (+17/-0)
plugins/unityshell/src/BamfLauncherIcon.cpp (+12/-2)
plugins/unityshell/src/PluginAdapter.cpp (+44/-31)
plugins/unityshell/src/SwitcherController.cpp (+8/-3)
plugins/unityshell/src/WindowManager.h (+1/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/quick-alt+tab-fixes.stable
Reviewer Review Type Date Requested Status
Sam Spilsbury (community) Needs Fixing
Review via email: mp+85585@code.launchpad.net

Description of the change

Make the quick Alt+Tab more consistent.

The quick Alt+Tab should be handled in a different way according to bug #861250, so I've made it possible by making the SwitcherController to use the ActionArg button member to define the type of the switch that has been performed (I've made this not to add an extra member to the class, but this can be changed if you want the code to be more clean).
Then the activated BamfLauncherIcon redirects this information to the PluginAdapter's FocusWindowGroup that now when called with the FocusVisibility::OnlyVisibleOnTop visibility option, just brings to focus the first window that is on top of the stack (for the given application).

A manual test is included.

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

163 + /* Instead of defining a new type of ActionArg we only use the "button"
164 + * ActionArg value to indicate to the view if we're performing a quick
165 + * switch or not. */
166 + unsigned int is_quick = (view_window_ && view_window_->IsVisible()) ? 0 : 1;
167 +
168 if (model_->detail_selection)
169 {
170 - selection->Activate(ActionArg(ActionArg::SWITCHER, 0, model_->DetailSelectionWindow ()));
171 + selection->Activate(ActionArg(ActionArg::SWITCHER, is_quick, model_->DetailSelectionWindow ()));
172 }
173 else
174 {
175 if (selection->GetQuirk (AbstractLauncherIcon::QUIRK_ACTIVE) &&
176 !model_->DetailXids().empty ())
177 {
178 - selection->Activate(ActionArg (ActionArg::SWITCHER, 0, model_->DetailXids()[0]));
179 + selection->Activate(ActionArg (ActionArg::SWITCHER, is_quick, model_->DetailXids()[0]));
180 }
181 else
182 {
183 - selection->Activate(ActionArg(ActionArg::SWITCHER, 0));
184 + selection->Activate(ActionArg(ActionArg::SWITCHER, is_quick));
185 }
186 }

is_quick is confusing here.

I say drop the boolean parameter and have

enum class RaiseBehaviour
{
    RaiseActive,
    RaiseAll
}

review: Needs Fixing
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Thanks for the review, however I don't know if this is still wanted.
I need to ask design.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Any updates?

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

I had a talk with design, but I don't get exactly what they want on this side...
I think I can delay it to after the feature freeze.

Unmerged revisions

1721. By Marco Trevisan (Treviño)

Make the quick Alt+Tab more consistent.

The quick Alt+Tab should be handled in a different way according to
bug #861250, so I've made it possible by making the SwitcherController
to use the ActionArg button member to define the type of the switch that
has been performed (I've made this not to add an extra member to the class).
Then the activated BamfLauncherIcon redirects this information to the
PluginAdapter's FocusWindowGroup that now when called with the
FocusVisibility::OnlyVisibleOnTop visibility option, just brings to
focus the first window that is on top of the stack (for the given
application).

A manual test is included.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'manual-tests'
2=== added file 'manual-tests/QuickAltTab.txt'
3--- manual-tests/QuickAltTab.txt 1970-01-01 00:00:00 +0000
4+++ manual-tests/QuickAltTab.txt 2011-12-14 02:19:28 +0000
5@@ -0,0 +1,17 @@
6+Quick Alt+Tab
7+-------------
8+This test shows how the alt+tab works when pressed quickly
9+
10+#. Start on a clean screen
11+#. Open two windows of the same application (i.e. gnome-terminal)
12+#. Open another window of another application (i.e. gedit)
13+#. Focus a gnome-terminal window
14+#. Quickly press Alt+Tab
15+#. The gedit window should be now on focus
16+#. Press again Alt+Tab
17+
18+Outcome
19+ The gnome-terminal window that had been in focus before should be brought to
20+ focus again. The second gnome-terminal window should below the gnome-terminal
21+ and gedit windows. The same should happen if the gnome-terminal windows are
22+ in different workspaces.
23
24=== modified file 'plugins/unityshell/src/BamfLauncherIcon.cpp'
25--- plugins/unityshell/src/BamfLauncherIcon.cpp 2011-10-14 11:11:27 +0000
26+++ plugins/unityshell/src/BamfLauncherIcon.cpp 2011-12-14 02:19:28 +0000
27@@ -625,8 +625,18 @@
28 }
29 }
30 else
31- WindowManager::Default()->FocusWindowGroup(windows,
32- WindowManager::FocusVisibility::OnlyVisible);
33+ {
34+ if (arg.button == 0)
35+ {
36+ WindowManager::Default()->FocusWindowGroup(windows,
37+ WindowManager::FocusVisibility::OnlyVisible);
38+ }
39+ else
40+ {
41+ WindowManager::Default()->FocusWindowGroup(windows,
42+ WindowManager::FocusVisibility::OnlyVisibleOnTop);
43+ }
44+ }
45 }
46
47 bool BamfLauncherIcon::Spread(int state, bool force)
48
49=== modified file 'plugins/unityshell/src/PluginAdapter.cpp'
50--- plugins/unityshell/src/PluginAdapter.cpp 2011-10-14 11:11:27 +0000
51+++ plugins/unityshell/src/PluginAdapter.cpp 2011-12-14 02:19:28 +0000
52@@ -568,7 +568,7 @@
53 window->lower();
54 }
55
56-void
57+void
58 PluginAdapter::FocusWindowGroup(std::vector<Window> window_ids, FocusVisibility focus_visibility)
59 {
60 CompPoint target_vp = m_Screen->vp();
61@@ -603,50 +603,63 @@
62 break;
63 }
64
65- if (!any_on_current)
66+ if (!any_on_current || focus_visibility == FocusVisibility::OnlyVisibleOnTop)
67 {
68- for (auto it = windows.rbegin(); it != windows.rend(); it++)
69+ for (auto it = windows.rbegin(); it != windows.rend(); ++it)
70 {
71- if ((any_mapped && !(*it)->minimized()) || !any_mapped)
72+ CompWindow* win = *it;
73+ if ((any_mapped && !win->minimized()) || !any_mapped)
74 {
75- target_vp = (*it)->defaultViewport();
76+ if (focus_visibility == FocusVisibility::OnlyVisibleOnTop)
77+ {
78+ win->raise();
79+ top_win = win;
80+ }
81+ else
82+ {
83+ target_vp = win->defaultViewport();
84+ }
85+
86 break;
87 }
88 }
89 }
90
91- for (CompWindow* &win : windows)
92+ if (focus_visibility != FocusVisibility::OnlyVisibleOnTop)
93 {
94- if (win->defaultViewport() == target_vp)
95+ for (CompWindow* &win : windows)
96 {
97- /* Any window which is actually unmapped is
98+ if (win->defaultViewport() == target_vp)
99+ {
100+ /* Any window which is actually unmapped is
101 * not going to be accessible by either switcher
102 * or scale, so unconditionally unminimize those
103 * windows when the launcher icon is activated */
104- if ((focus_visibility == WindowManager::FocusVisibility::ForceUnminimizeOnCurrentDesktop &&
105- WindowManager::Default ()->IsWindowOnCurrentDesktop(win->id ())) ||
106- (focus_visibility == WindowManager::FocusVisibility::ForceUnminimizeInvisible &&
107+ if ((focus_visibility == FocusVisibility::ForceUnminimizeOnCurrentDesktop &&
108+ WindowManager::Default()->IsWindowOnCurrentDesktop(win->id())) ||
109+ (focus_visibility == FocusVisibility::ForceUnminimizeInvisible &&
110 win->mapNum () == 0))
111- {
112- bool is_mapped = win->mapNum () != 0;
113- top_win = win;
114- win->unminimize ();
115-
116- forced_unminimize = true;
117-
118- /* Initially minimized windows dont get raised */
119- if (!is_mapped)
120- win->raise ();
121- }
122- else if ((any_mapped && !win->minimized()) || !any_mapped)
123- {
124- if (!forced_unminimize ||
125- WindowManager::Default ()->IsWindowOnCurrentDesktop (win->id ()))
126- {
127- win->raise();
128- top_win = win;
129- }
130- }
131+ {
132+ bool is_mapped = win->mapNum() != 0;
133+ win->unminimize();
134+ top_win = win;
135+
136+ forced_unminimize = true;
137+
138+ /* Initially minimized windows dont get raised */
139+ if (!is_mapped)
140+ win->raise();
141+ }
142+ else if ((any_mapped && !win->minimized()) || !any_mapped)
143+ {
144+ if (!forced_unminimize ||
145+ WindowManager::Default()->IsWindowOnCurrentDesktop(win->id()))
146+ {
147+ win->raise();
148+ top_win = win;
149+ }
150+ }
151+ }
152 }
153 }
154
155
156=== modified file 'plugins/unityshell/src/SwitcherController.cpp'
157--- plugins/unityshell/src/SwitcherController.cpp 2011-10-02 21:28:52 +0000
158+++ plugins/unityshell/src/SwitcherController.cpp 2011-12-14 02:19:28 +0000
159@@ -183,20 +183,25 @@
160 AbstractLauncherIcon* selection = model_->Selection();
161 if (selection)
162 {
163+ /* Instead of defining a new type of ActionArg we only use the "button"
164+ * ActionArg value to indicate to the view if we're performing a quick
165+ * switch or not. */
166+ unsigned int is_quick = (view_window_ && view_window_->IsVisible()) ? 0 : 1;
167+
168 if (model_->detail_selection)
169 {
170- selection->Activate(ActionArg(ActionArg::SWITCHER, 0, model_->DetailSelectionWindow ()));
171+ selection->Activate(ActionArg(ActionArg::SWITCHER, is_quick, model_->DetailSelectionWindow ()));
172 }
173 else
174 {
175 if (selection->GetQuirk (AbstractLauncherIcon::QUIRK_ACTIVE) &&
176 !model_->DetailXids().empty ())
177 {
178- selection->Activate(ActionArg (ActionArg::SWITCHER, 0, model_->DetailXids()[0]));
179+ selection->Activate(ActionArg (ActionArg::SWITCHER, is_quick, model_->DetailXids()[0]));
180 }
181 else
182 {
183- selection->Activate(ActionArg(ActionArg::SWITCHER, 0));
184+ selection->Activate(ActionArg(ActionArg::SWITCHER, is_quick));
185 }
186 }
187 }
188
189=== modified file 'plugins/unityshell/src/WindowManager.h'
190--- plugins/unityshell/src/WindowManager.h 2011-10-14 11:11:27 +0000
191+++ plugins/unityshell/src/WindowManager.h 2011-12-14 02:19:28 +0000
192@@ -48,6 +48,7 @@
193 enum class FocusVisibility
194 {
195 OnlyVisible,
196+ OnlyVisibleOnTop,
197 ForceUnminimizeInvisible,
198 ForceUnminimizeOnCurrentDesktop
199 };

Subscribers

People subscribed via source and target branches