Merge lp:~nick-dedekind/unity/smart-scopes.double-click-activation into lp:~unity-team/unity/libunity-7.0-breakage

Proposed by Nick Dedekind
Status: Merged
Approved by: Michal Hruby
Approved revision: no longer in the source branch.
Merged at revision: 3141
Proposed branch: lp:~nick-dedekind/unity/smart-scopes.double-click-activation
Merge into: lp:~unity-team/unity/libunity-7.0-breakage
Diff against target: 329 lines (+96/-21)
6 files modified
com.canonical.Unity.gschema.xml (+5/-0)
dash/ResultViewGrid.cpp (+59/-16)
dash/ResultViewGrid.h (+3/-0)
tests/autopilot/unity/emulators/dash.py (+5/-3)
unity-shared/UnitySettings.cpp (+23/-2)
unity-shared/UnitySettings.h (+1/-0)
To merge this branch: bzr merge lp:~nick-dedekind/unity/smart-scopes.double-click-activation
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+161967@code.launchpad.net

Commit message

Result preview activated on left single-click. Normal result activation on double-click.

Description of the change

Result preview activated on left single-click. Normal result activation on double-click.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michal Hruby (mhr3) wrote :

Not approving just yet, as this will break half of AP tests.

Revision history for this message
Michal Hruby (mhr3) wrote :

This is a high-prio feature, so approving right before landing. The tests will be updated shortly with a different branch. (probably once merged in trunk)

review: Approve
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

217 - def activate(self):
218 + def activate(self, double_click=True):
219 tx = self.x + (self.width / 2)
220 ty = self.y + (self.height / 2)
221 self.mouse.move(tx, ty)
222 self.mouse.click(1)
223 + if double_click:
224 + self.mouse.click(1)
225
226 - def preview(self):
227 + def preview(self, button=1):
228 tx = self.x + (self.width / 2)
229 ty = self.y + (self.height / 2)
230 self.mouse.move(tx, ty)
231 - self.mouse.click(3)
232 + self.mouse.click(button)

Should be handling double click activate change in AP

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'com.canonical.Unity.gschema.xml'
2--- com.canonical.Unity.gschema.xml 2013-03-20 11:25:40 +0000
3+++ com.canonical.Unity.gschema.xml 2013-05-03 19:01:31 +0000
4@@ -41,6 +41,11 @@
5 <summary>The number of minimizations required to reach maximum speed.</summary>
6 <description>The speed of the minimize animation will progressively get faster as minimize-count approaches this value.</description>
7 </key>
8+ <key type="b" name="double-click-activate">
9+ <default>true</default>
10+ <summary>Enable/Disable dash result double-click activation.</summary>
11+ <description>This is used to enable/disable double-click result activation in the dash. Double-click to activate, single click preview</description>
12+ </key>
13 </schema>
14 <schema path="/com/canonical/unity/launcher/" id="com.canonical.Unity.Launcher" gettext-domain="unity">
15 <key type="as" name="favorites">
16
17=== modified file 'dash/ResultViewGrid.cpp'
18--- dash/ResultViewGrid.cpp 2013-04-17 15:10:39 +0000
19+++ dash/ResultViewGrid.cpp 2013-05-03 19:01:31 +0000
20@@ -34,6 +34,7 @@
21 #include "unity-shared/UBusWrapper.h"
22 #include "unity-shared/UBusMessages.h"
23 #include "unity-shared/GraphicsUtils.h"
24+#include "unity-shared/UnitySettings.h"
25 #include "ResultViewGrid.h"
26 #include "math.h"
27
28@@ -51,6 +52,8 @@
29
30 const float FOCUSED_GHOST_ICON_OPACITY_REF = 0.7f;
31 const float FOCUSED_ICON_SATURATION_REF = 0.5f;
32+
33+ const int DOUBLE_CLICK_SPEED = 500; //500 ms (double-click speed hardcoded to 400 ms in nux)
34 }
35
36 NUX_IMPLEMENT_OBJECT_TYPE(ResultViewGrid);
37@@ -74,6 +77,7 @@
38 , mouse_last_y_(-1)
39 , extra_horizontal_spacing_(0)
40 {
41+ EnableDoubleClick(true);
42 SetAcceptKeyNavFocusOnMouseDown(false);
43
44 auto needredraw_lambda = [&](int value) { NeedRedraw(); };
45@@ -92,6 +96,7 @@
46 key_down.connect(sigc::mem_fun(this, &ResultViewGrid::OnKeyDown));
47 mouse_move.connect(sigc::mem_fun(this, &ResultViewGrid::MouseMove));
48 mouse_click.connect(sigc::mem_fun(this, &ResultViewGrid::MouseClick));
49+ mouse_double_click.connect(sigc::mem_fun(this, &ResultViewGrid::MouseDoubleClick));
50
51 mouse_down.connect([&](int x, int y, unsigned long mouse_state, unsigned long button_state)
52 {
53@@ -142,7 +147,7 @@
54 int current_index = GetIndexForLocalResult(activated_result_);
55 if (nav_mode == -1) // left
56 {
57- current_index--;
58+ current_index--;
59 }
60 else if (nav_mode == 1) // right
61 {
62@@ -164,7 +169,7 @@
63 {
64 selected_index_ = active_index_ = current_index;
65 activated_result_ = GetLocalResultForIndex(current_index);
66- LOG_DEBUG(logger) << "activating preview for index: "
67+ LOG_DEBUG(logger) << "activating preview for index: "
68 << "(" << current_index << ")"
69 << " " << activated_result_.uri;
70 Activate(activated_result_, current_index, ActivateType::PREVIEW);
71@@ -178,11 +183,12 @@
72
73 void ResultViewGrid::Activate(LocalResult const& local_result, int index, ResultView::ActivateType type)
74 {
75+ activate_timer_.reset();
76 unsigned num_results = GetNumResults();
77
78 int left_results = index;
79 int right_results = num_results ? (num_results - index) - 1 : 0;
80- //FIXME - just uses y right now, needs to use the absolute position of the bottom of the result
81+ //FIXME - just uses y right now, needs to use the absolute position of the bottom of the result
82 // (jay) Here is the fix: Compute the y position of the row where the item is located.
83 nux::Geometry abs_geo = GetAbsoluteGeometry();
84 int row_y = padding + abs_geo.y;
85@@ -242,7 +248,7 @@
86 SizeReallocate();
87 results_changed_idle_.reset();
88 lazy_load_source_.reset(); // no point doing this one as well.
89-
90+
91 if (!all_results_preloaded_)
92 {
93 last_lazy_loaded_result_ = 0; // reset the lazy load index in case we got an insert
94@@ -289,7 +295,7 @@
95 else if (!lazy_load_source_)
96 {
97 lazy_load_source_.reset(new glib::Idle(glib::Source::Priority::DEFAULT));
98- lazy_load_source_->Run(sigc::mem_fun(this, &ResultViewGrid::DoLazyLoad));
99+ lazy_load_source_->Run(sigc::mem_fun(this, &ResultViewGrid::DoLazyLoad));
100 }
101 QueueDraw();
102
103@@ -686,7 +692,7 @@
104 break;
105
106 ResultRenderer::ResultRendererState state = ResultRenderer::RESULT_RENDERER_NORMAL;
107-
108+
109 if (enable_texture_render() == false)
110 {
111 if (index == selected_index_)
112@@ -797,19 +803,56 @@
113 Result result = *it;
114 selected_index_ = index;
115 focused_result_ = result;
116-
117- ActivateType type = nux::GetEventButton(button_flags) == nux::MouseButton::MOUSE_BUTTON3 ? ResultView::ActivateType::PREVIEW :
118- ResultView::ActivateType::DIRECT;
119-
120- activated_result_ = result;
121- Activate(activated_result_, index, type);
122+ activated_result_ = result;
123+
124+
125+ if (nux::GetEventButton(button_flags) == nux::NUX_MOUSE_BUTTON1)
126+ {
127+ if (unity::Settings::Instance().double_click_activate)
128+ {
129+ // delay activate for single left click. (for double click check)
130+ activate_timer_.reset(new glib::Timeout(DOUBLE_CLICK_SPEED, [this, index]() {
131+ Activate(activated_result_, index, ResultView::ActivateType::PREVIEW);
132+ return false;
133+ }));
134+ }
135+ else
136+ {
137+ Activate(activated_result_, index, ResultView::ActivateType::DIRECT);
138+ }
139+ }
140+ else
141+ {
142+ Activate(activated_result_, index, ResultView::ActivateType::PREVIEW);
143+ }
144+ }
145+}
146+
147+void ResultViewGrid::MouseDoubleClick(int x, int y, unsigned long button_flags, unsigned long key_flags)
148+{
149+ if (unity::Settings::Instance().double_click_activate == false)
150+ return;
151+
152+ unsigned num_results = GetNumResults();
153+ unsigned index = GetIndexAtPosition(x, y);
154+ mouse_over_index_ = index;
155+ if (index < num_results && nux::GetEventButton(button_flags) == nux::NUX_MOUSE_BUTTON1)
156+ {
157+ // we got a click on a button so activate it
158+ ResultIterator it(GetIteratorAtRow(index));
159+ Result result = *it;
160+ selected_index_ = index;
161+ focused_result_ = result;
162+
163+ activated_result_ = result;
164+ Activate(activated_result_, index, ResultView::ActivateType::DIRECT);
165 }
166 }
167
168 unsigned ResultViewGrid::GetIndexAtPosition(int x, int y)
169 {
170- if (x < 0 || y < 0)
171- return -1;
172+ if (x < 0 || y < 0)
173+ return -1;
174
175 unsigned items_per_row = GetItemsPerRow();
176
177@@ -841,8 +884,8 @@
178 if (G_UNLIKELY(index >= static_cast<unsigned>(GetNumResults()) || index < 0))
179 {
180 LOG_ERROR(logger) << "index (" << index << ") does not exist in this category";
181- return std::tuple<int, int>(0,0);
182- } // out of bounds.
183+ return std::tuple<int, int>(0,0);
184+ } // out of bounds.
185
186 int items_per_row = GetItemsPerRow();
187 int column_size = renderer_->width + horizontal_spacing + extra_horizontal_spacing_;
188
189=== modified file 'dash/ResultViewGrid.h'
190--- dash/ResultViewGrid.h 2013-03-27 11:18:56 +0000
191+++ dash/ResultViewGrid.h 2013-05-03 19:01:31 +0000
192@@ -61,6 +61,7 @@
193 protected:
194 void MouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
195 void MouseClick(int x, int y, unsigned long button_flags, unsigned long key_flags);
196+ void MouseDoubleClick(int x, int y, unsigned long button_flags, unsigned long key_flags);
197
198 virtual bool DndSourceDragBegin();
199 virtual nux::NBitmapData* DndSourceGetDragImage();
200@@ -128,6 +129,8 @@
201 glib::Source::UniquePtr lazy_load_source_;
202 glib::Source::UniquePtr results_changed_idle_;
203 nux::Color background_color_;
204+
205+ glib::Source::UniquePtr activate_timer_;
206 };
207
208 } // namespace dash
209
210=== modified file 'tests/autopilot/unity/emulators/dash.py'
211--- tests/autopilot/unity/emulators/dash.py 2013-04-17 15:10:39 +0000
212+++ tests/autopilot/unity/emulators/dash.py 2013-05-03 19:01:31 +0000
213@@ -283,17 +283,19 @@
214 self.mouse = get_mouse()
215 self.keyboard = get_keyboard()
216
217- def activate(self):
218+ def activate(self, double_click=True):
219 tx = self.x + (self.width / 2)
220 ty = self.y + (self.height / 2)
221 self.mouse.move(tx, ty)
222 self.mouse.click(1)
223+ if double_click:
224+ self.mouse.click(1)
225
226- def preview(self):
227+ def preview(self, button=1):
228 tx = self.x + (self.width / 2)
229 ty = self.y + (self.height / 2)
230 self.mouse.move(tx, ty)
231- self.mouse.click(3)
232+ self.mouse.click(button)
233
234 def preview_key(self):
235 tx = self.x + (self.width / 2)
236
237=== modified file 'unity-shared/UnitySettings.cpp'
238--- unity-shared/UnitySettings.cpp 2012-11-06 18:19:09 +0000
239+++ unity-shared/UnitySettings.cpp 2013-05-03 19:01:31 +0000
240@@ -35,6 +35,7 @@
241
242 const std::string SETTINGS_NAME = "com.canonical.Unity";
243 const std::string FORM_FACTOR = "form-factor";
244+const std::string DOUBLE_CLICK_ACTIVATE = "double-click-activate";
245 }
246
247 //
248@@ -47,14 +48,20 @@
249 : parent_(owner)
250 , gsettings_(g_settings_new(SETTINGS_NAME.c_str()))
251 , cached_form_factor_(FormFactor::DESKTOP)
252+ , cached_double_click_activate_(true)
253 , lowGfx_(false)
254 {
255 CacheFormFactor();
256+ CacheDoubleClickActivate();
257
258 form_factor_changed_.Connect(gsettings_, "changed::" + FORM_FACTOR, [this] (GSettings*, gchar*) {
259 CacheFormFactor();
260 parent_->form_factor.changed.emit(cached_form_factor_);
261 });
262+ double_click_activate_changed_.Connect(gsettings_, "changed::" + DOUBLE_CLICK_ACTIVATE, [this] (GSettings*, gchar*) {
263+ CacheDoubleClickActivate();
264+ parent_->double_click_activate.changed.emit(cached_double_click_activate_);
265+ });
266 }
267
268 void CacheFormFactor()
269@@ -75,6 +82,11 @@
270 }
271 }
272
273+ void CacheDoubleClickActivate()
274+ {
275+ cached_double_click_activate_ = g_settings_get_boolean(gsettings_, DOUBLE_CLICK_ACTIVATE.c_str());
276+ }
277+
278 FormFactor GetFormFactor() const
279 {
280 return cached_form_factor_;
281@@ -86,12 +98,19 @@
282 return true;
283 }
284
285+ bool GetDoubleClickActivate() const
286+ {
287+ return cached_double_click_activate_;
288+ }
289+
290 Settings* parent_;
291 glib::Object<GSettings> gsettings_;
292 FormFactor cached_form_factor_;
293+ bool cached_double_click_activate_;
294 bool lowGfx_;
295
296 glib::Signal<void, GSettings*, gchar* > form_factor_changed_;
297+ glib::Signal<void, GSettings*, gchar* > double_click_activate_changed_;
298 };
299
300 //
301@@ -106,12 +125,14 @@
302 {
303 LOG_ERROR(logger) << "More than one unity::Settings created.";
304 }
305-
306+
307 else
308- {
309+ {
310 form_factor.SetGetterFunction(sigc::mem_fun(*pimpl, &Impl::GetFormFactor));
311 form_factor.SetSetterFunction(sigc::mem_fun(*pimpl, &Impl::SetFormFactor));
312
313+ double_click_activate.SetGetterFunction(sigc::mem_fun(*pimpl, &Impl::GetDoubleClickActivate));
314+
315 settings_instance = this;
316 }
317 }
318
319=== modified file 'unity-shared/UnitySettings.h'
320--- unity-shared/UnitySettings.h 2012-11-06 18:19:09 +0000
321+++ unity-shared/UnitySettings.h 2013-05-03 19:01:31 +0000
322@@ -47,6 +47,7 @@
323
324 nux::RWProperty<FormFactor> form_factor;
325 nux::Property<bool> is_standalone;
326+ nux::ROProperty<bool> double_click_activate;
327
328 private:
329 class Impl;

Subscribers

People subscribed via source and target branches

to all changes: