Merge lp://staging/~jjed/unity/tooltips-redux into lp://staging/unity

Proposed by Jjed
Status: Merged
Approved by: Stephen M. Webb
Approved revision: no longer in the source branch.
Merged at revision: 3191
Proposed branch: lp://staging/~jjed/unity/tooltips-redux
Merge into: lp://staging/unity
Diff against target: 564 lines (+356/-36)
11 files modified
launcher/AbstractLauncherIcon.h (+1/-0)
launcher/CMakeLists.txt (+1/-0)
launcher/Launcher.cpp (+21/-24)
launcher/Launcher.h (+3/-0)
launcher/LauncherIcon.cpp (+0/-11)
launcher/MockLauncherIcon.h (+5/-1)
launcher/TooltipManager.cpp (+126/-0)
launcher/TooltipManager.h (+57/-0)
tests/CMakeLists.txt (+1/-0)
tests/autopilot/unity/tests/launcher/test_tooltips.py (+87/-0)
tests/test_tooltip_manager.cpp (+54/-0)
To merge this branch: bzr merge lp://staging/~jjed/unity/tooltips-redux
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Stephen M. Webb (community) Approve
Marco Trevisan (Treviño) Approve
Jjed (community) Needs Resubmitting
Thomi Richards Pending
Review via email: mp+150942@code.staging.launchpad.net

Commit message

Add a 1s delay between hovering on a launcher icon and showing its tooltip.
Further tooltips before clicking or unhovering launcher will appear instantly.

Description of the change

== Problem

There is currently no delay between hovering on a Launcher icon and displaying its tooltip.

This proposal supercedes the (long defunct) lp:~j-johan-edwards/unity/tooltip-delay/ merge proposal.

== Fix implementation

I've removed the ability of `LauncherIcon` to prompt its own tooltip display. Instead, a new object `TooltipManager`
(notified of events by a monitor's `Launcher`) controls launcher tooltip logic according to a `_hover_timer` which resets on mouse movement. A `LauncherIcon` may refuse to display based on its local condition (eg if it is the BFB and active, or being dragged).

Clicking an icon causes its tooltip to disappear, and the `_hover_clock` to be "locked" until the mouse moves to another icon. This behavior feels right to me (as otherwise tooltips appear while you hover over an app you just clicked, waiting for it to open) but I'm open to changing it.

Tooltip delay is 1s per lp:#687956. Let me know if the design has changed.

== Testing

There are three new autopilot tests in `test_tooltips`. Dash tooltip behavior is further tested in `test_icon_behavior`.

`autopilot run unity.tests.launcher` passes. I have only one monitor.

== Old feedback

I'm using `assertTrue` in my tooltips test because the behavior tested is time-specific, and `assertThat(.... Eventually(Equals(bool))` doesn't distinguish between instantaneous and delayed tooltip display. Maybe there's some other way...?

To post a comment you must log in.
Revision history for this message
Stephen M. Webb (bregma) wrote :

(1) Please fix the copyright dates in the new source files.
(2) Please do not prepend an underscore wart to indicate a member variable: the Unity style is to use appended underscore warts.
(3) You need to add a commit message to this MP.

Other than that, this seems OK.

review: Needs Fixing
Revision history for this message
Jjed (jjed) wrote :

I believe that should fix them. Thanks for the quick review!

review: Needs Resubmitting
Revision history for this message
Andrea Azzarone (azzar1) wrote :

+#define NULL_ICON (AbstractLauncherIcon::Ptr)nullptr

Don't do this please :)

314 +void TooltipManager::StopTimer() {
315 + hover_timer_.reset(new glib::Timeout(TOOLTIPS_SHOW_TIMEOUT_LENGTH));
316 +}

Is this the right way to stop the timeout?

Also I think you can unit test the new class ;)

Revision history for this message
Jjed (jjed) wrote :

> Don't do this please :)

Okay, removed.

> Is this the right way to stop the timeout?

It seems to be (you can `grep -R "reset(new glib::Timeout" to see similar uses). `hover_timer_->Remove() would also stop it, but then I'd just need add the same line afterwards to set a new timeout.

> Also I think you can unit test the new class

Okay, added. There's not much to test, as the modules only interaction with the outside world is calling `icon_->ShowTooltip()` and `icon_->HideTooltip()`. Tell me if there are any other test cases you'd like to see.

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

324 +void TooltipManager::StopTimer() {
325 + hover_timer_.reset(new glib::Timeout(TOOLTIPS_SHOW_TIMEOUT_LENGTH));
326 +}

Please just call hover_timer_.reset();

Then when you need to start it again, reset it to a new one.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

> > Don't do this please :)
>
> Okay, removed.
>
> > Is this the right way to stop the timeout?
>
> It seems to be (you can `grep -R "reset(new glib::Timeout" to see similar
> uses). `hover_timer_->Remove() would also stop it, but then I'd just need add
> the same line afterwards to set a new timeout.

hover_timer_->reset() should just work.

>
> > Also I think you can unit test the new class
>
> Okay, added. There's not much to test, as the modules only interaction with
> the outside world is calling `icon_->ShowTooltip()` and
> `icon_->HideTooltip()`. Tell me if there are any other test cases you'd like
> to see.

Revision history for this message
Jjed (jjed) wrote :

Okay, that works (and does fewer glib::Timeout allocations too).

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

81 + SetIconUnderMouse((AbstractLauncherIcon::Ptr)nullptr);

Please pass an empty icon PTR to the function as it expects:
SetIconUnderMouse(AbstractLauncherIcon::Ptr());

245 + : show_tooltips_(false)
246 + , hovered_(false)
247 + , icon_(nullptr)
248 + , icon_clicked_(false)

This is pure style, but we use 2-spaces to indent initialization list, also you don't need to initialize the icon_ at all.

366 +class TooltipManager : public sigc::trackable

You don't need sigc::trackable, but you probably want this to be non-copyable instead.

371 + void SetHover(bool on_launcher);

What about a nux::Property<bool> for this?

258 + if (show_tooltips_) {

Please add a space after the if statements (so that the brace is on the new line)

539 + tm.SetIcon((AbstractLauncherIcon::Ptr)icon);

Pass to it an icon ptr: tm.SetIcon(AbstractLauncherIcon::Ptr(icon));

Revision history for this message
Jjed (jjed) wrote :

Okay, changed most of that.

> 371 + void SetHover(bool on_launcher);
>
> What about a nux::Property<bool> for this?

I don't think that makes sense, given that `hover_` is private and the TooltipMannager doesn't need any internal hooks for when it changes. LauncherHoverMachine already has a signal for changing hover-state as well.

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

Cool, this is fine now..

Stephen, are you ok now with removing the "Needs fixing" flag? :)

review: Approve
Revision history for this message
Stephen M. Webb (bregma) wrote :

Looks good.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)
Revision history for this message
Adolfo Jayme Barrientos (fitojb) wrote :

As Launcher icons don't visually change at all when hovered with the mouse, Unity again feels so sluggish/unresponsive, that I have to wonder if it has freezed. I reported that as bug 1152390.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.