Merge lp:~azzar1/unity/fix-978030 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 2357
Proposed branch: lp:~azzar1/unity/fix-978030
Merge into: lp:unity
Diff against target: 197 lines (+78/-2)
9 files modified
plugins/unityshell/src/AbstractLauncherIcon.h (+1/-0)
plugins/unityshell/src/BFBLauncherIcon.cpp (+1/-0)
plugins/unityshell/src/HudLauncherIcon.cpp (+1/-0)
plugins/unityshell/src/Launcher.cpp (+4/-1)
plugins/unityshell/src/LauncherIcon.cpp (+10/-1)
plugins/unityshell/src/LauncherIcon.h (+2/-0)
tests/autopilot/autopilot/emulators/unity/icons.py (+11/-0)
tests/autopilot/autopilot/emulators/unity/tooltip.py (+20/-0)
tests/autopilot/autopilot/tests/test_launcher.py (+28/-0)
To merge this branch: bzr merge lp:~azzar1/unity/fix-978030
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Review via email: mp+103847@code.launchpad.net

Commit message

Disable the bfb/hudlaunchericon tooltip when the dash/hud is open.

Description of the change

== Problem ==
Dash - search field is hidden by tooltips

== Fix ==
Disable the bfb/hudlaunchericon tooltip when the dash/hud is open.
Hide a launcher icon tooltip as soon as the dash/hud is shown.

== Test ==
2 AP tests added. The tooltip class is empty for the moment.

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

Code and tests look good, please include a small test also for the HudLauncherIcon ;)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/AbstractLauncherIcon.h'
--- plugins/unityshell/src/AbstractLauncherIcon.h 2012-04-25 00:32:14 +0000
+++ plugins/unityshell/src/AbstractLauncherIcon.h 2012-04-27 10:33:25 +0000
@@ -119,6 +119,7 @@
119 virtual ~AbstractLauncherIcon() {}119 virtual ~AbstractLauncherIcon() {}
120120
121 nux::Property<std::string> tooltip_text;121 nux::Property<std::string> tooltip_text;
122 nux::Property<bool> tooltip_enabled;
122123
123 virtual void HideTooltip() = 0;124 virtual void HideTooltip() = 0;
124125
125126
=== modified file 'plugins/unityshell/src/BFBLauncherIcon.cpp'
--- plugins/unityshell/src/BFBLauncherIcon.cpp 2012-04-19 22:46:07 +0000
+++ plugins/unityshell/src/BFBLauncherIcon.cpp 2012-04-27 10:33:25 +0000
@@ -65,6 +65,7 @@
6565
66 if (overlay_identity.Str() == "dash" && IsVisibleOnMonitor(overlay_monitor))66 if (overlay_identity.Str() == "dash" && IsVisibleOnMonitor(overlay_monitor))
67 {67 {
68 tooltip_enabled = !visible;
68 SetQuirk(QUIRK_ACTIVE, visible);69 SetQuirk(QUIRK_ACTIVE, visible);
69 EmitNeedsRedraw();70 EmitNeedsRedraw();
70 }71 }
7172
=== modified file 'plugins/unityshell/src/HudLauncherIcon.cpp'
--- plugins/unityshell/src/HudLauncherIcon.cpp 2012-04-24 13:22:42 +0000
+++ plugins/unityshell/src/HudLauncherIcon.cpp 2012-04-27 10:33:25 +0000
@@ -101,6 +101,7 @@
101 SetMonitor(overlay_monitor);101 SetMonitor(overlay_monitor);
102 SetQuirk(QUIRK_VISIBLE, visible);102 SetQuirk(QUIRK_VISIBLE, visible);
103 SetQuirk(QUIRK_ACTIVE, visible);103 SetQuirk(QUIRK_ACTIVE, visible);
104 tooltip_enabled = !visible;
104 EmitNeedsRedraw();105 EmitNeedsRedraw();
105 }106 }
106}107}
107108
=== modified file 'plugins/unityshell/src/Launcher.cpp'
--- plugins/unityshell/src/Launcher.cpp 2012-04-24 22:21:03 +0000
+++ plugins/unityshell/src/Launcher.cpp 2012-04-27 10:33:25 +0000
@@ -1340,7 +1340,7 @@
1340 gint32 overlay_monitor = 0;1340 gint32 overlay_monitor = 0;
1341 g_variant_get(data, UBUS_OVERLAY_FORMAT_STRING,1341 g_variant_get(data, UBUS_OVERLAY_FORMAT_STRING,
1342 &overlay_identity, &can_maximise, &overlay_monitor);1342 &overlay_identity, &can_maximise, &overlay_monitor);
1343 std::string identity = overlay_identity.Str();1343 std::string identity(overlay_identity.Str());
13441344
1345 LOG_DEBUG(logger) << "Overlay shown: " << identity1345 LOG_DEBUG(logger) << "Overlay shown: " << identity
1346 << ", " << (can_maximise ? "can maximise" : "can't maximise")1346 << ", " << (can_maximise ? "can maximise" : "can't maximise")
@@ -1366,6 +1366,9 @@
1366 LOG_DEBUG(logger) << "Desaturate on monitor " << monitor();1366 LOG_DEBUG(logger) << "Desaturate on monitor " << monitor();
1367 DesaturateIcons();1367 DesaturateIcons();
1368 }1368 }
1369
1370 if (_icon_under_mouse)
1371 _icon_under_mouse->HideTooltip();
1369 }1372 }
1370 EnsureAnimation();1373 EnsureAnimation();
1371}1374}
13721375
=== modified file 'plugins/unityshell/src/LauncherIcon.cpp'
--- plugins/unityshell/src/LauncherIcon.cpp 2012-04-24 18:09:33 +0000
+++ plugins/unityshell/src/LauncherIcon.cpp 2012-04-27 10:33:25 +0000
@@ -99,6 +99,9 @@
99 for (int i = 0; i < max_num_monitors; ++i)99 for (int i = 0; i < max_num_monitors; ++i)
100 _is_visible_on_monitor[i] = true;100 _is_visible_on_monitor[i] = true;
101101
102 tooltip_enabled = true;
103 tooltip_enabled.changed.connect(sigc::mem_fun(this, &LauncherIcon::OnTooltipEnabledChanged));
104
102 tooltip_text.SetSetterFunction(sigc::mem_fun(this, &LauncherIcon::SetTooltipText));105 tooltip_text.SetSetterFunction(sigc::mem_fun(this, &LauncherIcon::SetTooltipText));
103 tooltip_text = "blank";106 tooltip_text = "blank";
104107
@@ -481,6 +484,12 @@
481 return result;484 return result;
482}485}
483486
487void LauncherIcon::OnTooltipEnabledChanged(bool value)
488{
489 if (!value)
490 HideTooltip();
491}
492
484void493void
485LauncherIcon::SetShortcut(guint64 shortcut)494LauncherIcon::SetShortcut(guint64 shortcut)
486{495{
@@ -499,7 +508,7 @@
499void508void
500LauncherIcon::ShowTooltip()509LauncherIcon::ShowTooltip()
501{510{
502 if (_quicklist && _quicklist->IsVisible())511 if (!tooltip_enabled || (_quicklist && _quicklist->IsVisible()))
503 return;512 return;
504513
505 int tip_x = 100;514 int tip_x = 100;
506515
=== modified file 'plugins/unityshell/src/LauncherIcon.h'
--- plugins/unityshell/src/LauncherIcon.h 2012-04-24 22:21:03 +0000
+++ plugins/unityshell/src/LauncherIcon.h 2012-04-27 10:33:25 +0000
@@ -324,6 +324,8 @@
324 void LoadTooltip();324 void LoadTooltip();
325 void LoadQuicklist();325 void LoadQuicklist();
326326
327 void OnTooltipEnabledChanged(bool value);
328
327 bool _remote_urgent;329 bool _remote_urgent;
328 float _present_urgency;330 float _present_urgency;
329 float _progress;331 float _progress;
330332
=== modified file 'tests/autopilot/autopilot/emulators/unity/icons.py'
--- tests/autopilot/autopilot/emulators/unity/icons.py 2012-04-24 13:14:52 +0000
+++ tests/autopilot/autopilot/emulators/unity/icons.py 2012-04-27 10:33:25 +0000
@@ -9,6 +9,7 @@
99
10from autopilot.emulators.unity import UnityIntrospectionObject10from autopilot.emulators.unity import UnityIntrospectionObject
11from autopilot.emulators.unity.quicklist import Quicklist11from autopilot.emulators.unity.quicklist import Quicklist
12from autopilot.emulators.unity.tooltip import ToolTip
1213
13class SimpleLauncherIcon(UnityIntrospectionObject):14class SimpleLauncherIcon(UnityIntrospectionObject):
14 """Holds information about a simple launcher icon.15 """Holds information about a simple launcher icon.
@@ -33,6 +34,16 @@
33 matches = self.get_children_by_type(Quicklist)34 matches = self.get_children_by_type(Quicklist)
34 return matches[0] if matches else None35 return matches[0] if matches else None
3536
37 def get_tooltip(self):
38 """Get the tooltip for this launcher icon.
39
40 This may return None, if there is no tooltip associated with this
41 launcher icon.
42
43 """
44 matches = self.get_children_by_type(ToolTip)
45 return matches[0] if matches else None
46
36 def is_on_monitor(self, monitor):47 def is_on_monitor(self, monitor):
37 """Returns True if the icon is available in the defined monitor"""48 """Returns True if the icon is available in the defined monitor"""
38 if monitor >= 0 and monitor < len(self.monitors_visibility):49 if monitor >= 0 and monitor < len(self.monitors_visibility):
3950
=== added file 'tests/autopilot/autopilot/emulators/unity/tooltip.py'
--- tests/autopilot/autopilot/emulators/unity/tooltip.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/autopilot/emulators/unity/tooltip.py 2012-04-27 10:33:25 +0000
@@ -0,0 +1,20 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2012 Canonical
3# Author: Andrea Azzarone
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9
10import logging
11from time import sleep
12
13from autopilot.emulators.unity import UnityIntrospectionObject
14
15
16logger = logging.getLogger(__name__)
17
18
19class ToolTip(UnityIntrospectionObject):
20 """Represents a tooltip."""
021
=== modified file 'tests/autopilot/autopilot/tests/test_launcher.py'
--- tests/autopilot/autopilot/tests/test_launcher.py 2012-04-26 06:44:00 +0000
+++ tests/autopilot/autopilot/tests/test_launcher.py 2012-04-27 10:33:25 +0000
@@ -717,3 +717,31 @@
717 x_fin, y_fin = self.mouse.position()717 x_fin, y_fin = self.mouse.position()
718 # The launcher should have held the mouse a little bit718 # The launcher should have held the mouse a little bit
719 self.assertThat(x_fin, LessThan(x + width * 1.5))719 self.assertThat(x_fin, LessThan(x + width * 1.5))
720
721
722class LauncherTooltipTests(AutopilotTestCase):
723 """Test the launcher tooltips"""
724
725 def setUp(self):
726 super(LauncherTooltipTests, self).setUp()
727 self.set_unity_option('launcher_hide_mode', 0)
728
729 def test_bfb_tooltip_disappear_when_dash_is_opened(self):
730 """Tests that the bfb tooltip disappear when the dash is opened."""
731 bfb = self.launcher.model.get_bfb_icon()
732 self.mouse.move(bfb.center_x, bfb.center_y)
733
734 self.dash.ensure_visible()
735 self.addCleanup(self.dash.ensure_hidden)
736
737 self.assertThat(bfb.get_tooltip().active, Eventually(Equals(False)))
738
739 def test_bfb_tooltip_is_disabled_when_dash_is_open(self):
740 """Tests the that bfb tooltip is disabled when the dash is open."""
741 self.dash.ensure_visible()
742 self.addCleanup(self.dash.ensure_hidden)
743
744 bfb = self.launcher.model.get_bfb_icon()
745 self.mouse.move(bfb.center_x, bfb.center_y)
746
747 self.assertThat(bfb.get_tooltip().active, Eventually(Equals(False)))