Merge lp:~agateau/unity-2d/show-launcher-from-home-button into lp:unity-2d/3.0

Proposed by Aurélien Gâteau
Status: Merged
Approved by: Ugo Riboni
Approved revision: 465
Merged at revision: 473
Proposed branch: lp:~agateau/unity-2d/show-launcher-from-home-button
Merge into: lp:unity-2d/3.0
Diff against target: 295 lines (+41/-66)
7 files modified
launcher/app/autohidebehavior.cpp (+1/-16)
launcher/app/autohidebehavior.h (+0/-5)
launcher/app/intellihidebehavior.cpp (+10/-33)
launcher/app/intellihidebehavior.h (+3/-11)
panel/applets/CMakeLists.txt (+2/-0)
panel/applets/homebutton/homebuttonapplet.cpp (+19/-1)
panel/applets/homebutton/homebuttonapplet.h (+6/-0)
To merge this branch: bzr merge lp:~agateau/unity-2d/show-launcher-from-home-button
Reviewer Review Type Date Requested Status
unity-2d-team Pending
Ugo Riboni Pending
Review via email: mp+54360@code.launchpad.net

This proposal supersedes a proposal from 2011-03-16.

Commit message

[launcher] Only show launcher when moving over home button.

This branch implements the following changes:

- Make unity-2d-panel HomeButton applet call BeginForceVisible and EndForceVisible when mouse enters and leaves the button.

- IntelliHideBehavior has also been refactored to carry less state, which potentially fixes other bugs which could be triggered by the behavior instance being destroyed because the controller switched to the ForceVisibleBehavior.

Description of the change

This branch implements the following changes:

- Make unity-2d-panel HomeButton applet call BeginForceVisible and EndForceVisible when mouse enters and leaves the button.

- IntelliHideBehavior has also been refactored to carry less state, which potentially fixes other bugs which could be triggered by the behavior instance being destroyed because the controller switched to the ForceVisibleBehavior.

To post a comment you must log in.
Revision history for this message
Ugo Riboni (uriboni) wrote : Posted in a previous version of this proposal

Code works, except for the following problem that breaks autohide and keeps the launcher always visible:

- put a window across the launcher so it does autohide
- go to the home button, the launcher appears
- push the home button, the dash appears
- click the workspaces switcher button in launcher, spread appears
- exit the spread to the same workspace where you were initially

The launcher is now stuck and always visible.
Please note that i'm running all 4 unity-2d components from the branch where i merged your code.

review: Needs Fixing
Revision history for this message
Ugo Riboni (uriboni) wrote : Posted in a previous version of this proposal

Approving anyway as the next work in the pipeline for Aurelien should help fix that issue and similar ones

review: Approve
Revision history for this message
Bob The Builder (bobthebuilder-deactivatedaccount) wrote : Posted in a previous version of this proposal

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/app/autohidebehavior.cpp'
2--- launcher/app/autohidebehavior.cpp 2011-03-10 10:00:33 +0000
3+++ launcher/app/autohidebehavior.cpp 2011-03-22 15:21:34 +0000
4@@ -36,17 +36,13 @@
5
6 AutoHideBehavior::AutoHideBehavior(Unity2dPanel* panel)
7 : AbstractVisibilityBehavior(panel)
8-, m_mouseArea(new MouseArea(this))
9 , m_autohideTimer(new QTimer(this))
10 {
11- connect(m_mouseArea, SIGNAL(entered()), m_panel, SLOT(slideIn()));
12-
13 m_autohideTimer->setSingleShot(true);
14 m_autohideTimer->setInterval(AUTOHIDE_TIMEOUT);
15 connect(m_autohideTimer, SIGNAL(timeout()), m_panel, SLOT(slideOut()));
16
17 m_panel->installEventFilter(this);
18- updateFromPanelGeometry();
19 if (!m_panel->geometry().contains(QCursor::pos())) {
20 if (m_panel->delta() == 0) {
21 /* Launcher is fully visible */
22@@ -69,21 +65,10 @@
23 m_autohideTimer->stop();
24 break;
25 case QEvent::Leave:
26- if (!m_mouseArea->containsMouse()) {
27- m_autohideTimer->start();
28- }
29- break;
30- case QEvent::Resize:
31- updateFromPanelGeometry();
32+ m_autohideTimer->start();
33 break;
34 default:
35 break;
36 }
37 return false;
38 }
39-
40-void AutoHideBehavior::updateFromPanelGeometry()
41-{
42- QRect rect(0, m_panel->y(), 1, m_panel->height());
43- m_mouseArea->setGeometry(rect);
44-}
45
46=== modified file 'launcher/app/autohidebehavior.h'
47--- launcher/app/autohidebehavior.h 2011-03-10 10:00:33 +0000
48+++ launcher/app/autohidebehavior.h 2011-03-22 15:21:34 +0000
49@@ -28,7 +28,6 @@
50 #include <QObject>
51
52 class QTimer;
53-class MouseArea;
54 class Unity2dPanel;
55
56 /**
57@@ -45,11 +44,7 @@
58 bool eventFilter(QObject*, QEvent*);
59
60 private:
61- MouseArea* m_mouseArea;
62 QTimer* m_autohideTimer;
63- bool m_requestAttention;
64-
65- void updateFromPanelGeometry();
66 };
67
68 #endif /* AUTOHIDEBEHAVIOR_H */
69
70=== modified file 'launcher/app/intellihidebehavior.cpp'
71--- launcher/app/intellihidebehavior.cpp 2011-03-15 11:37:03 +0000
72+++ launcher/app/intellihidebehavior.cpp 2011-03-22 15:21:34 +0000
73@@ -15,7 +15,6 @@
74
75 // libunity-2d
76 #include <debug_p.h>
77-#include <mousearea.h>
78 #include <unity2dpanel.h>
79
80 // Qt
81@@ -63,19 +62,14 @@
82
83 IntelliHideBehavior::IntelliHideBehavior(Unity2dPanel* panel)
84 : AbstractVisibilityBehavior(panel)
85-, m_mouseArea(new MouseArea(this))
86 , m_activeWindow(0)
87-, m_visibility(VisiblePanel)
88 {
89 m_panel->installEventFilter(this);
90
91- connect(m_mouseArea, SIGNAL(entered()), SLOT(forceVisiblePanel()));
92-
93 WnckScreen* screen = wnck_screen_get_default();
94 g_signal_connect(G_OBJECT(screen), "active-window-changed", G_CALLBACK(activeWindowChangedCB), this);
95 g_signal_connect(G_OBJECT(screen), "active-workspace-changed", G_CALLBACK(activeWorkspaceChangedCB), this);
96
97- updateFromPanelGeometry();
98 /* Delay monitoring the active window giving time to the user to reach
99 for the panel before it disappears */
100 QTimer::singleShot(1000, this, SLOT(updateActiveWindowConnections()));
101@@ -118,7 +112,7 @@
102
103 void IntelliHideBehavior::updateVisibility()
104 {
105- if (m_visibility == ForceVisiblePanel) {
106+ if (isMouseForcingVisibility()) {
107 return;
108 }
109 int launcherPid = getpid();
110@@ -166,41 +160,24 @@
111 }
112 }
113
114- m_visibility = crossWindow ? HiddenPanel : VisiblePanel;
115- slidePanel();
116+ if (crossWindow) {
117+ m_panel->slideOut();
118+ } else {
119+ m_panel->slideIn();
120+ }
121 }
122
123 bool IntelliHideBehavior::eventFilter(QObject* object, QEvent* event)
124 {
125- if (event->type() == QEvent::Leave && !m_mouseArea->containsMouse() && m_visibility == ForceVisiblePanel) {
126- m_visibility = VisiblePanel;
127+ if (event->type() == QEvent::Leave && !isMouseForcingVisibility()) {
128 updateVisibility();
129 } else if (event->type() == QEvent::Resize) {
130- updateFromPanelGeometry();
131 updateVisibility();
132 }
133 return false;
134 }
135
136-void IntelliHideBehavior::slidePanel()
137-{
138- if (m_visibility != HiddenPanel) {
139- m_panel->slideIn();
140- } else {
141- m_panel->slideOut();
142- }
143-}
144-
145-void IntelliHideBehavior::updateFromPanelGeometry()
146-{
147- QRect rect(0, m_panel->y(), 1, m_panel->height());
148- m_mouseArea->setGeometry(rect);
149-}
150-
151-void IntelliHideBehavior::forceVisiblePanel()
152-{
153- if (m_visibility != ForceVisiblePanel) {
154- m_visibility = ForceVisiblePanel;
155- slidePanel();
156- }
157+bool IntelliHideBehavior::isMouseForcingVisibility() const
158+{
159+ return m_panel->underMouse();
160 }
161
162=== modified file 'launcher/app/intellihidebehavior.h'
163--- launcher/app/intellihidebehavior.h 2011-03-10 10:00:33 +0000
164+++ launcher/app/intellihidebehavior.h 2011-03-22 15:21:34 +0000
165@@ -19,7 +19,6 @@
166
167 struct _WnckWindow;
168
169-class MouseArea;
170 class Unity2dPanel;
171
172 /**
173@@ -38,27 +37,20 @@
174 private Q_SLOTS:
175 void updateVisibility();
176 void updateActiveWindowConnections();
177- void forceVisiblePanel();
178
179 private:
180 Q_DISABLE_COPY(IntelliHideBehavior);
181
182 enum PanelVisibility {
183 VisiblePanel,
184- HiddenPanel,
185- ForceVisiblePanel
186+ HiddenPanel
187 };
188
189- // A 1px invisible area used to force the panel to be visible if the user
190- // hits the edge of the screen with the mouse cursor
191- MouseArea* m_mouseArea;
192-
193 struct _WnckWindow* m_activeWindow;
194- PanelVisibility m_visibility;
195
196- void slidePanel();
197- void updateFromPanelGeometry();
198 void disconnectFromGSignals();
199+
200+ bool isMouseForcingVisibility() const;
201 };
202
203 #endif /* INTELLIHIDEBEHAVIOR_H */
204
205=== modified file 'panel/applets/CMakeLists.txt'
206--- panel/applets/CMakeLists.txt 2011-03-01 09:04:13 +0000
207+++ panel/applets/CMakeLists.txt 2011-03-22 15:21:34 +0000
208@@ -68,6 +68,7 @@
209 ${WNCK_INCLUDE_DIRS}
210 ${CMAKE_CURRENT_BINARY_DIR}
211 ${X11_INCLUDE_DIR}
212+ ${libunity-2d-private_SOURCE_DIR}/src
213 )
214
215 add_library(uqapplets ${uqapplets_SRCS})
216@@ -85,4 +86,5 @@
217 ${X11_Xcomposite_LIB}
218 ${X11_Xdamage_LIB}
219 ${X11_Xfixes_LIB}
220+ unity-2d-private
221 )
222
223=== modified file 'panel/applets/homebutton/homebuttonapplet.cpp'
224--- panel/applets/homebutton/homebuttonapplet.cpp 2011-03-17 13:14:29 +0000
225+++ panel/applets/homebutton/homebuttonapplet.cpp 2011-03-22 15:21:34 +0000
226@@ -25,6 +25,9 @@
227 // Local
228 #include <debug_p.h>
229
230+// libunity-2d
231+#include <launcherclient.h>
232+
233 // Qt
234 #include <QHBoxLayout>
235 #include <QDBusInterface>
236@@ -35,7 +38,10 @@
237 static const char* DBUS_PATH = "/Dash";
238 static const char* DBUS_IFACE = "com.canonical.Unity2d.Dash";
239
240-HomeButtonApplet::HomeButtonApplet() : m_button(new QToolButton), m_dashInterface(NULL)
241+HomeButtonApplet::HomeButtonApplet()
242+: m_button(new QToolButton)
243+, m_dashInterface(NULL)
244+, m_launcherClient(new LauncherClient(this))
245 {
246 m_button->setAutoRaise(true);
247 QIcon::setThemeName("unity-icon-theme");
248@@ -107,4 +113,16 @@
249 }
250 }
251
252+void HomeButtonApplet::enterEvent(QEvent* event)
253+{
254+ Unity2d::Applet::enterEvent(event);
255+ m_launcherClient->beginForceVisible();
256+}
257+
258+void HomeButtonApplet::leaveEvent(QEvent* event)
259+{
260+ Unity2d::Applet::leaveEvent(event);
261+ m_launcherClient->endForceVisible();
262+}
263+
264 #include "homebuttonapplet.moc"
265
266=== modified file 'panel/applets/homebutton/homebuttonapplet.h'
267--- panel/applets/homebutton/homebuttonapplet.h 2011-01-15 01:41:03 +0000
268+++ panel/applets/homebutton/homebuttonapplet.h 2011-03-22 15:21:34 +0000
269@@ -29,6 +29,7 @@
270 #include <QToolButton>
271
272 class QDBusInterface;
273+class LauncherClient;
274
275 class HomeButtonApplet : public Unity2d::Applet
276 {
277@@ -36,6 +37,10 @@
278 public:
279 HomeButtonApplet();
280
281+protected:
282+ void enterEvent(QEvent*);
283+ void leaveEvent(QEvent*);
284+
285 private Q_SLOTS:
286 void toggleDash();
287 void connectToDash();
288@@ -44,6 +49,7 @@
289 Q_DISABLE_COPY(HomeButtonApplet)
290 QToolButton* m_button;
291 QDBusInterface* m_dashInterface;
292+ LauncherClient* m_launcherClient;
293 };
294
295 #endif /* HOMEBUTTONAPPLET_H */

Subscribers

People subscribed via source and target branches