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.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'manual-tests/QuickAltTab.txt'
--- manual-tests/QuickAltTab.txt 1970-01-01 00:00:00 +0000
+++ manual-tests/QuickAltTab.txt 2011-12-15 03:29:25 +0000
@@ -0,0 +1,17 @@
1Quick Alt+Tab
2-------------
3This test shows how the alt+tab works when pressed quickly
4
5#. Start on a clean screen
6#. Open two windows of the same application (i.e. gnome-terminal)
7#. Open another window of another application (i.e. gedit)
8#. Focus a gnome-terminal window
9#. Quickly press Alt+Tab
10#. The gedit window should be now on focus
11#. Press again Alt+Tab
12
13Outcome
14 The gnome-terminal window that had been in focus before should be brought to
15 focus again. The second gnome-terminal window should below the gnome-terminal
16 and gedit windows. The same should happen if the gnome-terminal windows are
17 in different workspaces.
018
=== modified file 'plugins/unityshell/src/BamfLauncherIcon.cpp'
--- plugins/unityshell/src/BamfLauncherIcon.cpp 2011-12-13 08:58:59 +0000
+++ plugins/unityshell/src/BamfLauncherIcon.cpp 2011-12-15 03:29:25 +0000
@@ -295,8 +295,10 @@
295 {295 {
296 guint32 xid = bamf_window_get_xid(BAMF_WINDOW(view));296 guint32 xid = bamf_window_get_xid(BAMF_WINDOW(view));
297297
298 if (wm->IsWindowMapped(xid))298 if (wm->IsWindowMapped(xid) && !bamf_window_get_transient(BAMF_WINDOW(view)))
299 results.push_back ((Window) xid);299 {
300 results.push_back (xid);
301 }
300 }302 }
301 }303 }
302304
@@ -628,8 +630,18 @@
628 }630 }
629 }631 }
630 else632 else
631 WindowManager::Default()->FocusWindowGroup(windows,633 {
632 WindowManager::FocusVisibility::OnlyVisible);634 if (arg.button == 0)
635 {
636 WindowManager::Default()->FocusWindowGroup(windows,
637 WindowManager::FocusVisibility::OnlyVisible);
638 }
639 else
640 {
641 WindowManager::Default()->FocusWindowGroup(windows,
642 WindowManager::FocusVisibility::OnlyVisibleOnTop);
643 }
644 }
633}645}
634646
635bool BamfLauncherIcon::Spread(int state, bool force)647bool BamfLauncherIcon::Spread(int state, bool force)
636648
=== modified file 'plugins/unityshell/src/PluginAdapter.cpp'
--- plugins/unityshell/src/PluginAdapter.cpp 2011-10-14 09:46:14 +0000
+++ plugins/unityshell/src/PluginAdapter.cpp 2011-12-15 03:29:25 +0000
@@ -568,7 +568,7 @@
568 window->lower();568 window->lower();
569}569}
570570
571void 571void
572PluginAdapter::FocusWindowGroup(std::vector<Window> window_ids, FocusVisibility focus_visibility)572PluginAdapter::FocusWindowGroup(std::vector<Window> window_ids, FocusVisibility focus_visibility)
573{573{
574 CompPoint target_vp = m_Screen->vp();574 CompPoint target_vp = m_Screen->vp();
@@ -603,50 +603,63 @@
603 break;603 break;
604 }604 }
605605
606 if (!any_on_current)606 if (!any_on_current || focus_visibility == FocusVisibility::OnlyVisibleOnTop)
607 {607 {
608 for (auto it = windows.rbegin(); it != windows.rend(); it++)608 for (auto it = windows.rbegin(); it != windows.rend(); ++it)
609 {609 {
610 if ((any_mapped && !(*it)->minimized()) || !any_mapped)610 CompWindow* win = *it;
611 if ((any_mapped && !win->minimized()) || !any_mapped)
611 {612 {
612 target_vp = (*it)->defaultViewport();613 if (focus_visibility == FocusVisibility::OnlyVisibleOnTop)
614 {
615 win->raise();
616 top_win = win;
617 }
618 else
619 {
620 target_vp = win->defaultViewport();
621 }
622
613 break;623 break;
614 }624 }
615 }625 }
616 }626 }
617627
618 for (CompWindow* &win : windows)628 if (focus_visibility != FocusVisibility::OnlyVisibleOnTop)
619 {629 {
620 if (win->defaultViewport() == target_vp)630 for (CompWindow* &win : windows)
621 {631 {
622 /* Any window which is actually unmapped is632 if (win->defaultViewport() == target_vp)
633 {
634 /* Any window which is actually unmapped is
623 * not going to be accessible by either switcher635 * not going to be accessible by either switcher
624 * or scale, so unconditionally unminimize those636 * or scale, so unconditionally unminimize those
625 * windows when the launcher icon is activated */637 * windows when the launcher icon is activated */
626 if ((focus_visibility == WindowManager::FocusVisibility::ForceUnminimizeOnCurrentDesktop &&638 if ((focus_visibility == FocusVisibility::ForceUnminimizeOnCurrentDesktop &&
627 WindowManager::Default ()->IsWindowOnCurrentDesktop(win->id ())) ||639 WindowManager::Default()->IsWindowOnCurrentDesktop(win->id())) ||
628 (focus_visibility == WindowManager::FocusVisibility::ForceUnminimizeInvisible &&640 (focus_visibility == FocusVisibility::ForceUnminimizeInvisible &&
629 win->mapNum () == 0))641 win->mapNum () == 0))
630 {642 {
631 bool is_mapped = win->mapNum () != 0;643 bool is_mapped = win->mapNum() != 0;
632 top_win = win;644 win->unminimize();
633 win->unminimize ();645 top_win = win;
634646
635 forced_unminimize = true;647 forced_unminimize = true;
636648
637 /* Initially minimized windows dont get raised */649 /* Initially minimized windows dont get raised */
638 if (!is_mapped)650 if (!is_mapped)
639 win->raise ();651 win->raise();
640 }652 }
641 else if ((any_mapped && !win->minimized()) || !any_mapped)653 else if ((any_mapped && !win->minimized()) || !any_mapped)
642 {654 {
643 if (!forced_unminimize ||655 if (!forced_unminimize ||
644 WindowManager::Default ()->IsWindowOnCurrentDesktop (win->id ()))656 WindowManager::Default()->IsWindowOnCurrentDesktop(win->id()))
645 {657 {
646 win->raise();658 win->raise();
647 top_win = win;659 top_win = win;
648 }660 }
649 }661 }
662 }
650 }663 }
651 }664 }
652665
653666
=== modified file 'plugins/unityshell/src/SwitcherController.cpp'
--- plugins/unityshell/src/SwitcherController.cpp 2011-12-14 16:18:41 +0000
+++ plugins/unityshell/src/SwitcherController.cpp 2011-12-15 03:29:25 +0000
@@ -205,20 +205,25 @@
205 AbstractLauncherIcon* selection = model_->Selection();205 AbstractLauncherIcon* selection = model_->Selection();
206 if (selection)206 if (selection)
207 {207 {
208 /* Instead of defining a new type of ActionArg we only use the "button"
209 * ActionArg value to indicate to the view if we're performing a quick
210 * switch or not. */
211 unsigned int is_quick = (view_window_ && view_window_->IsVisible()) ? 0 : 1;
212
208 if (model_->detail_selection)213 if (model_->detail_selection)
209 {214 {
210 selection->Activate(ActionArg(ActionArg::SWITCHER, 0, model_->DetailSelectionWindow ()));215 selection->Activate(ActionArg(ActionArg::SWITCHER, is_quick, model_->DetailSelectionWindow ()));
211 }216 }
212 else217 else
213 {218 {
214 if (selection->GetQuirk (AbstractLauncherIcon::QUIRK_ACTIVE) &&219 if (selection->GetQuirk (AbstractLauncherIcon::QUIRK_ACTIVE) &&
215 !model_->DetailXids().empty ())220 !model_->DetailXids().empty ())
216 {221 {
217 selection->Activate(ActionArg (ActionArg::SWITCHER, 0, model_->DetailXids()[0]));222 selection->Activate(ActionArg (ActionArg::SWITCHER, is_quick, model_->DetailXids()[0]));
218 }223 }
219 else224 else
220 {225 {
221 selection->Activate(ActionArg(ActionArg::SWITCHER, 0));226 selection->Activate(ActionArg(ActionArg::SWITCHER, is_quick));
222 }227 }
223 }228 }
224 }229 }
225230
=== modified file 'plugins/unityshell/src/WindowManager.h'
--- plugins/unityshell/src/WindowManager.h 2011-10-14 09:18:55 +0000
+++ plugins/unityshell/src/WindowManager.h 2011-12-15 03:29:25 +0000
@@ -48,6 +48,7 @@
48 enum class FocusVisibility48 enum class FocusVisibility
49 {49 {
50 OnlyVisible,50 OnlyVisible,
51 OnlyVisibleOnTop,
51 ForceUnminimizeInvisible,52 ForceUnminimizeInvisible,
52 ForceUnminimizeOnCurrentDesktop53 ForceUnminimizeOnCurrentDesktop
53 };54 };