Merge lp:~brandontschaefer/unity/opening-dash-in-scale-mode-fix into lp:unity

Proposed by Brandon Schaefer on 2012-06-26
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2012-06-26
Approved revision: 2445
Merged at revision: 2443
Proposed branch: lp:~brandontschaefer/unity/opening-dash-in-scale-mode-fix
Merge into: lp:unity
Diff against target: 135 lines (+55/-2)
4 files modified
dash/DashController.cpp (+4/-1)
plugins/unityshell/src/unityshell.cpp (+24/-0)
plugins/unityshell/src/unityshell.h (+2/-0)
tests/autopilot/unity/tests/test_dash.py (+25/-1)
To merge this branch: bzr merge lp:~brandontschaefer/unity/opening-dash-in-scale-mode-fix
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) 2012-06-26 Approve on 2012-06-26
Review via email: mp+112181@code.launchpad.net

Commit message

The dash will now open when invoked while in spread/scale mode.

Description of the change

=== Problem ===
When is spread/scale mode you could not activate the dash.

=== Fix ===
Well this was a bit of a hack, as the scale plugin consumes all input, expect for the hacks already in place in unity. So to open the home dash I had to assume while in scale mode that the state CompTermTapped was true to tests for a super key tapping...if that was true then assume was_tap is true so the dash will open. (Otherwise it wont)

=== Tests ===
There are ap test for opening the Home lens/ Command lens/ Other lenses (app,file,music all open the same way)

To post a comment you must log in.
Marco Trevisan (Treviño) (3v1n0) wrote :

Works well, tests pass... So, approved! ;)

review: Approve
Sebastien Bacher (seb128) wrote :

The steps described there work, it doesn't work perfectly with the launcher spread though:
- left click on the nautilus launcher icon
- middle click on the same icon to open a second instance
- left click to trigger the spread view of nautilus instances
- hit the super key

-> nothing happens

- hit super again

-> the spread closes and the dash open

Ideally you would need to only press super once in those cases (it's not a regression and probably not worth blocking the SRU but would be nice to fix for the next round)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/DashController.cpp'
2--- dash/DashController.cpp 2012-06-15 15:51:40 +0000
3+++ dash/DashController.cpp 2012-06-26 18:36:22 +0000
4@@ -80,7 +80,7 @@
5 window_->ShowWindow(false);
6 window_->SetOpacity(0.0f);
7 window_->mouse_down_outside_pointer_grab_area.connect(sigc::mem_fun(this, &Controller::OnMouseDownOutsideWindow));
8-
9+
10 /* FIXME - first time we load our windows there is a race that causes the input window not to actually get input, this side steps that by causing an input window show and hide before we really need it. */
11 auto plugin_adapter = PluginAdapter::Default();
12 plugin_adapter->saveInputFocus ();
13@@ -337,6 +337,9 @@
14 std::string lens_id = view_->GetIdForShortcutActivation(std::string(key_string));
15 if (lens_id != "")
16 {
17+ if (PluginAdapter::Default()->IsScaleActive())
18+ PluginAdapter::Default()->TerminateScale();
19+
20 GVariant* args = g_variant_new("(sus)", lens_id.c_str(), dash::GOTO_DASH_URI, "");
21 OnActivateRequest(args);
22 g_variant_unref(args);
23
24=== modified file 'plugins/unityshell/src/unityshell.cpp'
25--- plugins/unityshell/src/unityshell.cpp 2012-06-25 21:37:57 +0000
26+++ plugins/unityshell/src/unityshell.cpp 2012-06-26 18:36:22 +0000
27@@ -131,6 +131,7 @@
28 , hud_keypress_time_(0)
29 , panel_texture_has_changed_(true)
30 , paint_panel_(false)
31+ , scale_just_activated_(false)
32 {
33 Timer timer;
34 gfloat version;
35@@ -1532,6 +1533,11 @@
36 ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST);
37 }
38
39+ if (PluginAdapter::Default()->IsScaleActive() && g_strcmp0(plugin, "scale") == 0)
40+ {
41+ scale_just_activated_ = true;
42+ }
43+
44 screen->handleCompizEvent(plugin, event, option);
45 }
46
47@@ -1579,6 +1585,18 @@
48 LOG_DEBUG(logger) << "Super released: " << (was_tap ? "tapped" : "released");
49 int when = options[7].value().i(); // XEvent time in millisec
50
51+ // hack...if the scale just wasn't activated AND the 'when' time is within time to start the
52+ // dash then assume was_tap is also true, since the ScalePlugin doesn't accept that state...
53+ if (PluginAdapter::Default()->IsScaleActive() && !scale_just_activated_ && launcher_controller_->AboutToShowDash(true, when))
54+ {
55+ PluginAdapter::Default()->TerminateScale();
56+ was_tap = true;
57+ }
58+ else if (scale_just_activated_)
59+ {
60+ scale_just_activated_ = false;
61+ }
62+
63 if (hud_controller_->IsVisible() && launcher_controller_->AboutToShowDash(was_tap, when))
64 hud_controller_->HideHud();
65
66@@ -1635,6 +1653,12 @@
67 {
68 hud_controller_->HideHud();
69 }
70+
71+ if (PluginAdapter::Default()->IsScaleActive())
72+ {
73+ PluginAdapter::Default()->TerminateScale();
74+ }
75+
76 ubus_manager_.SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST,
77 g_variant_new("(sus)", "commands.lens", 0, ""));
78 }
79
80=== modified file 'plugins/unityshell/src/unityshell.h'
81--- plugins/unityshell/src/unityshell.h 2012-06-23 01:54:48 +0000
82+++ plugins/unityshell/src/unityshell.h 2012-06-26 18:36:22 +0000
83@@ -311,6 +311,8 @@
84 bool paint_panel_;
85 nux::ObjectPtr<nux::IOpenGLBaseTexture> panel_texture_;
86
87+ bool scale_just_activated_;
88+
89 #ifndef USE_MODERN_COMPIZ_GL
90 ScreenEffectFramebufferObject::GLXGetProcAddressProc glXGetProcAddressP;
91 #endif
92
93=== modified file 'tests/autopilot/unity/tests/test_dash.py'
94--- tests/autopilot/unity/tests/test_dash.py 2012-06-19 12:53:17 +0000
95+++ tests/autopilot/unity/tests/test_dash.py 2012-06-26 18:36:22 +0000
96@@ -70,6 +70,30 @@
97 self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
98 self.assertThat(self.dash.visible, Eventually(Equals(False)))
99
100+ def test_dash_opens_when_in_spread(self):
101+ """This test shows the dash opens when in spread mode."""
102+ self.keybinding("spread/start")
103+ self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
104+
105+ self.dash.ensure_visible()
106+ self.assertThat(self.dash.visible, Eventually(Equals(True)))
107+
108+ def test_command_lens_opens_when_in_spread(self):
109+ """This test shows the command lens opens when in spread mode."""
110+ self.keybinding("spread/start")
111+ self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
112+
113+ self.dash.reveal_command_lens()
114+ self.assertThat(self.dash.active_lens, Eventually(Equals('commands.lens')))
115+
116+ def test_lens_opens_when_in_spread(self):
117+ """This test shows that any lens opens when in spread mode."""
118+ self.keybinding("spread/start")
119+ self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
120+
121+ self.dash.reveal_application_lens()
122+ self.assertThat(self.dash.active_lens, Eventually(Equals('applications.lens')))
123+
124
125 class DashSearchInputTests(DashTestCase):
126 """Test features involving input to the dash search"""
127@@ -514,7 +538,7 @@
128 self.mouse.move(self.dash.view.x + self.dash.view.width / 2,
129 category.header_y + category.header_height / 2)
130
131- self.mouse.click()
132+ self.mouse.click()
133 self.assertThat(category.is_expanded, Eventually(Equals(not is_expanded)))
134
135 self.mouse.click()