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

Proposed by Marco Trevisan (Treviño)
Status: Merged
Merged at revision: 2282
Proposed branch: lp:~3v1n0/unity/quick-alt+tab-fixes
Merge into: lp:unity
Diff against target: 211 lines (+86/-38)
5 files modified
manual-tests/QuickAltTab.txt (+17/-0)
plugins/unityshell/src/BamfLauncherIcon.cpp (+16/-4)
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
Reviewer Review Type Date Requested Status
Tim Penhey (community) Needs Information
Review via email: mp+85583@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
Tim Penhey (thumper) wrote :

How does this interaction work with the alt-tab switcher defaulting to only showing applications running on the same workspace? Are there any considerations we have to make there?

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

Mh, in that case this modification doesn't affect the switcher behavior.

I've to look better to this case, to see how we can handle it correctly.

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

> How does this interaction work with the alt-tab switcher defaulting to only
> showing applications running on the same workspace? Are there any
> considerations we have to make there?

I've gave a look to this, but in this case it's the switcher itself that defines the possible windows to switch to.
So, In that case, my code is used with only a subset of windows, and so it should continue to work as expected.

lp:~3v1n0/unity/quick-alt+tab-fixes updated
1781. By Marco Trevisan (Treviño)

BamfLauncherIcon: don't include dialog windows on Alt+Tab.

Preview Diff

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