Merge lp:~uriboni/unity/adjust-minimize-animation-speed into lp:unity
- adjust-minimize-animation-speed
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Ugo Riboni |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2647 |
Proposed branch: | lp:~uriboni/unity/adjust-minimize-animation-speed |
Merge into: | lp:unity |
Diff against target: |
470 lines (+361/-1) 7 files modified
com.canonical.Unity.gschema.xml (+20/-0) plugins/unityshell/src/WindowMinimizeSpeedController.cpp (+108/-0) plugins/unityshell/src/WindowMinimizeSpeedController.h (+57/-0) plugins/unityshell/src/unityshell.cpp (+44/-0) plugins/unityshell/src/unityshell.h (+7/-1) tests/CMakeLists.txt (+2/-0) tests/test_launcher_minimize_speed.cpp (+123/-0) |
To merge this branch: | bzr merge lp:~uriboni/unity/adjust-minimize-animation-speed |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sam Spilsbury (community) | Approve | ||
Review via email: mp+120362@code.launchpad.net |
Commit message
Progressively adjust the speed of the minimize animation. First time it is used is slower, then speeds up the more it is used.
Description of the change
Progressively adjust the speed of the minimize animation. First time it is used is slower, then speeds up the more it is used.
Sam Spilsbury (smspillaz) wrote : | # |
Sam Spilsbury (smspillaz) wrote : | # |
Hey Ugo,
Were you able to make this take references?
135 + CompOption::Value value = o.value();
136 + CompOption:
137 + CompOption:
Sam Spilsbury (smspillaz) wrote : | # |
Ugo ?
Ugo Riboni (uriboni) wrote : | # |
Sam, I fixed all the issues you mentioned and refactored the code some more to make it testable. I had some problems with writing the tests but hopefully they are solved now and I'll be able to add push all the changes today hopefully.
Sam Spilsbury (smspillaz) wrote : | # |
272 if (!mMinimizeHandler)
273 {
274 + /* Updating the count in dconf will trigger a "changed" signal to which
275 + * the method setting the new animation speed is attached */
276 + UnityScreen* unityScreen = UnityScreen:
277 + unityScreen-
Its probably better to do this in UnityWindow:
362 + *
363 + * Authored by: Andrea Azzarone <email address hidden>
Put yourself there if you want ;-)
398 + g_setenv(
399 + g_setenv(
You can just do g_unsetenv here.
I like the tests for signal emmission.
Overall looks good. Feel free to fix those if you want - I'll put my +1 here, someone else can make the branch approved once you're fine with it :)
Ugo Riboni (uriboni) wrote : | # |
I'll fix your comments, then ping you for final approval. Thanks !
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Unity Merger (unity-merger) wrote : | # |
Attempt to merge into lp:unity failed due to conflicts:
text conflict in tests/CMakeList
Sam Spilsbury (smspillaz) wrote : | # |
Hey Ugo,
I can't push to your branch but there is a trivial conflict in tests/CMakeList
Preview Diff
1 | === modified file 'com.canonical.Unity.gschema.xml' |
2 | --- com.canonical.Unity.gschema.xml 2012-08-15 14:19:47 +0000 |
3 | +++ com.canonical.Unity.gschema.xml 2012-08-31 09:17:21 +0000 |
4 | @@ -21,6 +21,26 @@ |
5 | <summary>Whether the home screen should be expanded.</summary> |
6 | <description>Whether the home screen should be expanded.</description> |
7 | </key> |
8 | + <key type="i" name="minimize-count"> |
9 | + <default>0</default> |
10 | + <summary>Number of times a normal window has been minimized.</summary> |
11 | + <description>This is used to adjust the animation speed by making it progressively faster the more it is used.</description> |
12 | + </key> |
13 | + <key type="i" name="minimize-fast-duration"> |
14 | + <default>300</default> |
15 | + <summary>The duration for the minimize animation when it is at its fastest setting.</summary> |
16 | + <description>This is the duration that the minimize animation will have when it has been used more than an number of times equal minimize-speed-threshold.</description> |
17 | + </key> |
18 | + <key type="i" name="minimize-slow-duration"> |
19 | + <default>800</default> |
20 | + <summary>The duration for the minimize animation when it is at its slowest setting.</summary> |
21 | + <description>This is the duration that the minimize animation will have when it has never been used.</description> |
22 | + </key> |
23 | + <key type="i" name="minimize-speed-threshold"> |
24 | + <default>100</default> |
25 | + <summary>The number of minimizations required to reach maximum speed.</summary> |
26 | + <description>The speed of the minimize animation will progressively get faster as minimize-count approaches this value.</description> |
27 | + </key> |
28 | </schema> |
29 | <schema path="/com/canonical/unity/launcher/" id="com.canonical.Unity.Launcher" gettext-domain="unity"> |
30 | <key type="as" name="favorites"> |
31 | |
32 | === added file 'plugins/unityshell/src/WindowMinimizeSpeedController.cpp' |
33 | --- plugins/unityshell/src/WindowMinimizeSpeedController.cpp 1970-01-01 00:00:00 +0000 |
34 | +++ plugins/unityshell/src/WindowMinimizeSpeedController.cpp 2012-08-31 09:17:21 +0000 |
35 | @@ -0,0 +1,108 @@ |
36 | +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
37 | +/* Compiz unity plugin |
38 | + * unity.h |
39 | + * |
40 | + * Copyright (c) 2010-11 Canonical Ltd. |
41 | + * |
42 | + * This program is free software; you can redistribute it and/or |
43 | + * modify it under the terms of the GNU General Public License |
44 | + * as published by the Free Software Foundation; either version 3 |
45 | + * of the License, or (at your option) any later version. |
46 | + * |
47 | + * This program is distributed in the hope that it will be useful, |
48 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
49 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
50 | + * GNU General Public License for more details. |
51 | + * |
52 | + * Your own copyright notice would go above. You are free to choose whatever |
53 | + * licence you want, just take note that some compiz code is GPL and you will |
54 | + * not be able to re-use it if you want to use a different licence. |
55 | + */ |
56 | + |
57 | +#include <gio/gio.h> |
58 | +#include <NuxCore/Logger.h> |
59 | + |
60 | +#include "WindowMinimizeSpeedController.h" |
61 | + |
62 | +namespace |
63 | +{ |
64 | + |
65 | +nux::logging::Logger logger ("unity.WindowMinimizeSpeedController"); |
66 | + |
67 | +namespace local |
68 | +{ |
69 | +const std::string UNITY_SCHEMA = "com.canonical.Unity"; |
70 | +} |
71 | +} |
72 | + |
73 | +WindowMinimizeSpeedController::WindowMinimizeSpeedController() |
74 | + : _settings(g_settings_new(local::UNITY_SCHEMA.c_str())) |
75 | + , _minimize_count(g_settings_get_int(_settings, "minimize-count")) |
76 | + , _minimize_speed_threshold(g_settings_get_int(_settings, "minimize-speed-threshold")) |
77 | + , _minimize_slow_duration(g_settings_get_int(_settings, "minimize-slow-duration")) |
78 | + , _minimize_fast_duration(g_settings_get_int(_settings, "minimize-fast-duration")) |
79 | +{ |
80 | + _minimize_count_changed.Connect(_settings, "changed::minimize-count", |
81 | + [&] (GSettings*, gchar* name) { |
82 | + _minimize_count = g_settings_get_int(_settings, name); |
83 | + SetDuration(); |
84 | + }); |
85 | + _minimize_speed_threshold_changed.Connect(_settings, "changed::minimize-speed-threshold", |
86 | + [&] (GSettings*, gchar* name) { |
87 | + _minimize_speed_threshold = g_settings_get_int(_settings, name); |
88 | + SetDuration(); |
89 | + }); |
90 | + _minimize_fast_duration_changed.Connect(_settings, "changed::minimize-fast-duration", |
91 | + [&] (GSettings*, gchar* name) { |
92 | + _minimize_fast_duration = g_settings_get_int(_settings, name); |
93 | + SetDuration(); |
94 | + }); |
95 | + _minimize_slow_duration_changed.Connect(_settings, "changed::minimize-slow-duration", |
96 | + [&] (GSettings*, gchar* name) { |
97 | + _minimize_slow_duration = g_settings_get_int(_settings, name); |
98 | + SetDuration(); |
99 | + }); |
100 | +} |
101 | + |
102 | +void WindowMinimizeSpeedController::UpdateCount() |
103 | +{ |
104 | + if (_minimize_count < _minimize_speed_threshold) { |
105 | + _minimize_count += 1; |
106 | + g_settings_set_int(_settings, "minimize-count", _minimize_count); |
107 | + } |
108 | +} |
109 | + |
110 | +int WindowMinimizeSpeedController::getDuration() |
111 | +{ |
112 | + return mDuration; |
113 | +} |
114 | + |
115 | +void WindowMinimizeSpeedController::SetDuration() |
116 | +{ |
117 | + /* Perform some sanity checks on the configuration values */ |
118 | + if (_minimize_fast_duration > _minimize_slow_duration) |
119 | + { |
120 | + LOG_WARN(logger) << "Configuration mismatch: minimize-fast-duration (" |
121 | + << _minimize_fast_duration |
122 | + << ") is longer than minimize-slow-duration (" |
123 | + << _minimize_slow_duration << "). Not changing speed."; |
124 | + return; |
125 | + } |
126 | + |
127 | + if (_minimize_count < 0) |
128 | + _minimize_count = 0; |
129 | + if (_minimize_count > _minimize_speed_threshold) |
130 | + _minimize_count = _minimize_speed_threshold; |
131 | + |
132 | + /* Adjust the speed so that it gets linearly closer to maximum speed as we |
133 | + approach the threshold */ |
134 | + int speed_range = _minimize_slow_duration - _minimize_fast_duration; |
135 | + float position = (_minimize_speed_threshold <= 0) ? 1.0 : |
136 | + static_cast<float>(_minimize_count) / _minimize_speed_threshold; |
137 | + int duration = _minimize_slow_duration - std::ceil(position * speed_range); |
138 | + |
139 | + if (duration != mDuration) { |
140 | + mDuration = duration; |
141 | + DurationChanged.emit(); |
142 | + } |
143 | +} |
144 | |
145 | === added file 'plugins/unityshell/src/WindowMinimizeSpeedController.h' |
146 | --- plugins/unityshell/src/WindowMinimizeSpeedController.h 1970-01-01 00:00:00 +0000 |
147 | +++ plugins/unityshell/src/WindowMinimizeSpeedController.h 2012-08-31 09:17:21 +0000 |
148 | @@ -0,0 +1,57 @@ |
149 | +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
150 | +/* Compiz unity plugin |
151 | + * unity.h |
152 | + * |
153 | + * Copyright (c) 2010-11 Canonical Ltd. |
154 | + * |
155 | + * This program is free software; you can redistribute it and/or |
156 | + * modify it under the terms of the GNU General Public License |
157 | + * as published by the Free Software Foundation; either version 3 |
158 | + * of the License, or (at your option) any later version. |
159 | + * |
160 | + * This program is distributed in the hope that it will be useful, |
161 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
162 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
163 | + * GNU General Public License for more details. |
164 | + * |
165 | + * Your own copyright notice would go above. You are free to choose whatever |
166 | + * licence you want, just take note that some compiz code is GPL and you will |
167 | + * not be able to re-use it if you want to use a different licence. |
168 | + */ |
169 | + |
170 | +#ifndef WINDOWMINIMIZESPEEDCONTROLLER_H |
171 | +#define WINDOWMINIMIZESPEEDCONTROLLER_H |
172 | + |
173 | +#include <core/core.h> |
174 | +#include <UnityCore/GLibWrapper.h> |
175 | +#include <UnityCore/GLibSignal.h> |
176 | +#include <sigc++/sigc++.h> |
177 | + |
178 | +typedef struct _GSettings GSettings; |
179 | + |
180 | +using namespace unity; |
181 | + |
182 | +class WindowMinimizeSpeedController |
183 | +{ |
184 | +public: |
185 | + WindowMinimizeSpeedController(); |
186 | + void UpdateCount(); |
187 | + int getDuration(); |
188 | + sigc::signal<void> DurationChanged; |
189 | + |
190 | +private: |
191 | + void SetDuration(); |
192 | + |
193 | + glib::Object<GSettings> _settings; |
194 | + int _minimize_count; |
195 | + int _minimize_speed_threshold; |
196 | + int _minimize_slow_duration; |
197 | + int _minimize_fast_duration; |
198 | + glib::Signal<void, GSettings*, gchar* > _minimize_count_changed; |
199 | + glib::Signal<void, GSettings*, gchar* > _minimize_speed_threshold_changed; |
200 | + glib::Signal<void, GSettings*, gchar* > _minimize_slow_duration_changed; |
201 | + glib::Signal<void, GSettings*, gchar* > _minimize_fast_duration_changed; |
202 | + int mDuration; |
203 | +}; |
204 | + |
205 | +#endif // WINDOWMINIMIZESPEEDCONTROLLER_H |
206 | |
207 | === modified file 'plugins/unityshell/src/unityshell.cpp' |
208 | --- plugins/unityshell/src/unityshell.cpp 2012-08-29 08:16:08 +0000 |
209 | +++ plugins/unityshell/src/unityshell.cpp 2012-08-31 09:17:21 +0000 |
210 | @@ -128,6 +128,7 @@ |
211 | , panel_texture_has_changed_(true) |
212 | , paint_panel_(false) |
213 | , scale_just_activated_(false) |
214 | + , minimize_speed_controller(new WindowMinimizeSpeedController()) |
215 | { |
216 | Timer timer; |
217 | #ifndef USE_GLES |
218 | @@ -384,6 +385,10 @@ |
219 | } |
220 | |
221 | panel::Style::Instance().changed.connect(sigc::mem_fun(this, &UnityScreen::OnPanelStyleChanged)); |
222 | + |
223 | + minimize_speed_controller->DurationChanged.connect( |
224 | + sigc::mem_fun(this, &UnityScreen::OnMinimizeDurationChanged) |
225 | + ); |
226 | } |
227 | |
228 | UnityScreen::~UnityScreen() |
229 | @@ -2540,6 +2545,40 @@ |
230 | } |
231 | |
232 | void |
233 | +UnityScreen::OnMinimizeDurationChanged () |
234 | +{ |
235 | + /* Update the compiz plugin setting with the new computed speed so that it |
236 | + * will be used in the following minimizations */ |
237 | + CompPlugin *p = CompPlugin::find("animation"); |
238 | + if (p) |
239 | + { |
240 | + CompOption::Vector &opts = p->vTable->getOptions(); |
241 | + |
242 | + for (CompOption &o : opts) |
243 | + { |
244 | + if (o.name () == std::string ("minimize_durations")) |
245 | + { |
246 | + /* minimize_durations is a list value, but minimize applies only to |
247 | + * normal windows, so there's always one value */ |
248 | + CompOption::Value& value = o.value(); |
249 | + CompOption::Value::Vector& list = value.list(); |
250 | + CompOption::Value::Vector::iterator i = list.begin(); |
251 | + if (i != list.end()) { |
252 | + i->set(minimize_speed_controller->getDuration()); |
253 | + } |
254 | + value.set(list); |
255 | + screen->setOptionForPlugin(p->vTable->name().c_str(), |
256 | + o.name().c_str(), value); |
257 | + break; |
258 | + } |
259 | + } |
260 | + } |
261 | + else { |
262 | + LOG_WARN(logger) << "Animation plugin not found. Can't set minimize speed."; |
263 | + } |
264 | +} |
265 | + |
266 | +void |
267 | UnityWindow::minimize () |
268 | { |
269 | if (!window->managed ()) |
270 | @@ -2655,6 +2694,11 @@ |
271 | case CompWindowNotifyBeforeDestroy: |
272 | being_destroyed.emit(); |
273 | break; |
274 | + case CompWindowNotifyMinimize: |
275 | + /* Updating the count in dconf will trigger a "changed" signal to which |
276 | + * the method setting the new animation speed is attached */ |
277 | + UnityScreen::get(screen)->minimize_speed_controller->UpdateCount(); |
278 | + break; |
279 | default: |
280 | break; |
281 | } |
282 | |
283 | === modified file 'plugins/unityshell/src/unityshell.h' |
284 | --- plugins/unityshell/src/unityshell.h 2012-08-21 05:44:45 +0000 |
285 | +++ plugins/unityshell/src/unityshell.h 2012-08-31 09:17:21 +0000 |
286 | @@ -65,6 +65,8 @@ |
287 | |
288 | #include "HudController.h" |
289 | #include "ThumbnailGenerator.h" |
290 | +#include "WindowMinimizeSpeedController.h" |
291 | + |
292 | namespace unity |
293 | { |
294 | |
295 | @@ -189,6 +191,8 @@ |
296 | |
297 | void SetUpAndShowSwitcher(switcher::ShowMode show_mode = switcher::ShowMode::CURRENT_VIEWPORT); |
298 | |
299 | + void OnMinimizeDurationChanged(); |
300 | + |
301 | switcher::Controller::Ptr switcher_controller(); |
302 | launcher::Controller::Ptr launcher_controller(); |
303 | |
304 | @@ -242,7 +246,7 @@ |
305 | void OnPanelStyleChanged(); |
306 | |
307 | void InitGesturesSupport(); |
308 | - |
309 | + |
310 | nux::animation::TickSource tick_source_; |
311 | nux::animation::AnimationController animation_controller_; |
312 | |
313 | @@ -339,6 +343,8 @@ |
314 | UBusManager ubus_manager_; |
315 | glib::SourceManager sources_; |
316 | unity::ThumbnailGenerator thumb_generator; |
317 | + |
318 | + WindowMinimizeSpeedController* minimize_speed_controller; |
319 | |
320 | friend class UnityWindow; |
321 | }; |
322 | |
323 | === modified file 'tests/CMakeLists.txt' |
324 | --- tests/CMakeLists.txt 2012-08-29 08:16:08 +0000 |
325 | +++ tests/CMakeLists.txt 2012-08-31 09:17:21 +0000 |
326 | @@ -227,6 +227,7 @@ |
327 | test_switcher_model.cpp |
328 | test_texture_cache.cpp |
329 | test_thumbnail_generator.cpp |
330 | + test_launcher_minimize_speed.cpp |
331 | test_volume_imp.cpp |
332 | test_volume_launcher_icon.cpp |
333 | gmockmount.c |
334 | @@ -338,6 +339,7 @@ |
335 | ${CMAKE_SOURCE_DIR}/unity-shared/UserThumbnailProvider.cpp |
336 | ${CMAKE_SOURCE_DIR}/unity-shared/WindowManager.cpp |
337 | ${CMAKE_SOURCE_DIR}/unity-shared/ubus-server.cpp |
338 | + ${CMAKE_SOURCE_DIR}/plugins/unityshell/src/WindowMinimizeSpeedController.cpp |
339 | ) |
340 | target_link_libraries(test-gtest gtest gmock ${LIBS}) |
341 | add_test(UnityGTest test-gtest) |
342 | |
343 | === added file 'tests/test_launcher_minimize_speed.cpp' |
344 | --- tests/test_launcher_minimize_speed.cpp 1970-01-01 00:00:00 +0000 |
345 | +++ tests/test_launcher_minimize_speed.cpp 2012-08-31 09:17:21 +0000 |
346 | @@ -0,0 +1,123 @@ |
347 | +/* |
348 | + * Copyright 2012 Canonical Ltd. |
349 | + * |
350 | + * This program is free software: you can redistribute it and/or modify it |
351 | + * under the terms of the GNU General Public License version 3, as published |
352 | + * by the Free Software Foundation. |
353 | + * |
354 | + * This program is distributed in the hope that it will be useful, but |
355 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
356 | + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
357 | + * PURPOSE. See the GNU General Public License for more details. |
358 | + * |
359 | + * You should have received a copy of the GNU General Public License |
360 | + * version 3 along with this program. If not, see |
361 | + * <http://www.gnu.org/licenses/> |
362 | + * |
363 | + * Authored by: Ugo Riboni <ugo.riboni@canonical.com> |
364 | + * |
365 | + */ |
366 | + |
367 | +#include <config.h> |
368 | + |
369 | +#include <gio/gio.h> |
370 | +#include <gtest/gtest.h> |
371 | + |
372 | +#include "plugins/unityshell/src/WindowMinimizeSpeedController.h" |
373 | + |
374 | +using namespace unity; |
375 | +using namespace testing; |
376 | + |
377 | +namespace |
378 | +{ |
379 | + |
380 | +const gchar* SCHEMA_DIRECTORY = BUILDDIR"/settings"; |
381 | + |
382 | +class TestLauncherMinimizeSpeed : public Test |
383 | +{ |
384 | +public: |
385 | + glib::Object<GSettings> mSettings; |
386 | + WindowMinimizeSpeedController* mController; |
387 | + |
388 | + /* override */ void SetUp() |
389 | + { |
390 | + g_setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIRECTORY, true); |
391 | + g_setenv("GSETTINGS_BACKEND", "memory", TRUE); |
392 | + mSettings = g_settings_new("com.canonical.Unity"); |
393 | + mController = new WindowMinimizeSpeedController(); |
394 | + } |
395 | + |
396 | + /* override */ void TearDown() |
397 | + { |
398 | + g_setenv("GSETTINGS_SCHEMA_DIR", "", true); |
399 | + g_unsetenv("GSETTINGS_BACKEND"); |
400 | + delete mController; |
401 | + } |
402 | +}; |
403 | + |
404 | +TEST_F(TestLauncherMinimizeSpeed, TestSlowest) |
405 | +{ |
406 | + g_settings_set_int(mSettings, "minimize-count", 0); |
407 | + g_settings_set_int(mSettings, "minimize-speed-threshold", 10); |
408 | + g_settings_set_int(mSettings, "minimize-fast-duration", 200); |
409 | + g_settings_set_int(mSettings, "minimize-slow-duration", 1200); |
410 | + |
411 | + EXPECT_TRUE(mController->getDuration() == 1200); |
412 | +} |
413 | + |
414 | +TEST_F(TestLauncherMinimizeSpeed, TestFastest) |
415 | +{ |
416 | + g_settings_set_int(mSettings, "minimize-count", 10); |
417 | + g_settings_set_int(mSettings, "minimize-speed-threshold", 10); |
418 | + g_settings_set_int(mSettings, "minimize-fast-duration", 200); |
419 | + g_settings_set_int(mSettings, "minimize-slow-duration", 1200); |
420 | + |
421 | + EXPECT_TRUE(mController->getDuration() == 200); |
422 | +} |
423 | + |
424 | +TEST_F(TestLauncherMinimizeSpeed, TestHalfway) |
425 | +{ |
426 | + g_settings_set_int(mSettings, "minimize-count", 5); |
427 | + g_settings_set_int(mSettings, "minimize-speed-threshold", 10); |
428 | + g_settings_set_int(mSettings, "minimize-fast-duration", 200); |
429 | + g_settings_set_int(mSettings, "minimize-slow-duration", 1200); |
430 | + |
431 | + EXPECT_TRUE(mController->getDuration() == 700); |
432 | +} |
433 | + |
434 | +TEST_F(TestLauncherMinimizeSpeed, TestOvershoot) |
435 | +{ |
436 | + g_settings_set_int(mSettings, "minimize-count", 20); |
437 | + g_settings_set_int(mSettings, "minimize-speed-threshold", 10); |
438 | + g_settings_set_int(mSettings, "minimize-fast-duration", 200); |
439 | + g_settings_set_int(mSettings, "minimize-slow-duration", 1200); |
440 | + |
441 | + EXPECT_TRUE(mController->getDuration() == 200); |
442 | +} |
443 | + |
444 | +TEST_F(TestLauncherMinimizeSpeed, TestSignal) |
445 | +{ |
446 | + |
447 | + bool signal_emitted = false; |
448 | + mController->DurationChanged.connect([&] () { |
449 | + signal_emitted = true; |
450 | + }); |
451 | + |
452 | + g_settings_set_int(mSettings, "minimize-count", 5); |
453 | + EXPECT_TRUE(signal_emitted); |
454 | +} |
455 | + |
456 | +TEST_F(TestLauncherMinimizeSpeed, TestInvalidFastSlow) |
457 | +{ |
458 | + g_settings_set_int(mSettings, "minimize-fast-duration", 2000); |
459 | + g_settings_set_int(mSettings, "minimize-slow-duration", 100); |
460 | + |
461 | + bool signal_emitted = false; |
462 | + mController->DurationChanged.connect([&] () { |
463 | + signal_emitted = true; |
464 | + }); |
465 | + |
466 | + g_settings_set_int(mSettings, "minimize-count", 5); |
467 | + EXPECT_FALSE(signal_emitted); |
468 | +} |
469 | +} |
470 | \ No newline at end of file |
Overall looks fine, comments:
133 + /* minimize_durations is a list value, but minimize applies only to :Value: :Vector list = value.list();
134 + * normal windows, so there's always one value */
135 + CompOption::Value value = o.value();
136 + CompOption:
You probably do not want to make copies of these if you can avoid it.
Use a reference instead.
180 +<<<<<<< TREE ThumbnailGenera tor thumb_generator; GSettings> _settings; speed_threshold ; slow_duration; fast_duration; count_changed; speed_threshold _changed; slow_duration_ changed; fast_duration_ changed;
181 unity::
182
183 +=======
184 +
185 + glib::Object<
186 + int _minimize_count;
187 + int _minimize_
188 + int _minimize_
189 + int _minimize_
190 + glib::Signal<void, GSettings*, gchar* > _minimize_
191 + glib::Signal<void, GSettings*, gchar* > _minimize_
192 + glib::Signal<void, GSettings*, gchar* > _minimize_
193 + glib::Signal<void, GSettings*, gchar* > _minimize_
194 +
195 +>>>>>>> MERGE-SOURCE
Also conflicts.
100 + /* Perform some sanity checks on the configuration values */ fast_duration > _minimize_ slow_duration) fast-duration (" fast_duration slow-duration (" slow_duration << "). Not changing speed."; speed_threshold ) speed_threshold ; slow_duration - _minimize_ fast_duration; speed_threshold <= 0) ? 1.0 : cast<float> (_minimize_ count) / _minimize_ speed_threshold ; slow_duration - std::ceil(position * speed_range);
101 + if (_minimize_
102 + {
103 + LOG_WARN(logger) << "Configuration mismatch: minimize-
104 + << _minimize_
105 + << ") is longer than minimize-
106 + << _minimize_
107 + return;
108 + }
109 +
110 + if (_minimize_count < 0)
111 + _minimize_count = 0;
112 + if (_minimize_count > _minimize_
113 + _minimize_count = _minimize_
114 +
115 + /* Adjust the speed so that it gets linearly closer to maximum speed as we
116 + approach the threshold */
117 + int speed_range = _minimize_
118 + float position = (_minimize_
119 + static_
120 + int speed = _minimize_
You will probably want some tests to cover this code.