Merge lp:~agateau/unity-2d/edge-reveal into lp:unity-2d/3.0

Proposed by Aurélien Gâteau on 2011-04-28
Status: Merged
Approved by: Ugo Riboni on 2011-06-06
Approved revision: 554
Merged at revision: 583
Proposed branch: lp:~agateau/unity-2d/edge-reveal
Merge into: lp:unity-2d/3.0
Diff against target: 318 lines (+168/-5) 7 files modified
To merge this branch: bzr merge lp:~agateau/unity-2d/edge-reveal
Reviewer Review Type Date Requested Status
Ugo Riboni 2011-04-28 Approve on 2011-06-06
Florian Boucault functional 2011-04-28 Needs Fixing on 2011-04-28
Review via email: mp+59362@code.launchpad.net

Commit Message

[launcher] In *Hide behaviors, show launcher when hitting left edge

Description of the Change

This branch changes the way the launcher is shown in *Hide mode to match latest unity-3d behavior: hit the left edge of the screen to show the launcher.

It has been tested with multiple screens of different heights.

To post a comment you must log in.
Florian Boucault (fboucault) wrote :

16:46 < Kaleo> agateau: the edge reveal does not behave like in Unity 3D
16:47 < Kaleo> agateau: and provokes a lot of false positives
16:47 < Kaleo> agateau: where the user will reach for example for the back button in Firefox and accidentally reveal the launcher
16:48 < agateau> Kaleo: so what does unity-3d do?
16:48 < Kaleo> agateau: I don't know the exact technical details but it takes a little while for the launcher to show when I reach the edge
16:48 < Kaleo> agateau: the code needs to be looked at
16:48 < agateau> Kaleo: ok

review: Needs Fixing (functional)
lp:~agateau/unity-2d/edge-reveal updated on 2011-05-18
552. By Aurélien Gâteau on 2011-05-18

Merged trunk

553. By Aurélien Gâteau on 2011-05-18

Cursor must stay on edge for 500ms to cause launcher to reveal

Same timeout as unity-3d

554. By Aurélien Gâteau on 2011-05-18

EdgeMouseArea no longer IsA MouseArea, so rename it

Florian Boucault (fboucault) wrote :

In the current form, merging this would add the bug Unity 3D has:
https://bugs.launchpad.net/ubuntu/+source/unity/+bug/757650

Aurélien Gâteau (agateau) wrote :

John Lea agreed it should not block the merge of edge-reveal in unity-2d:
"""
[14:50:29] <agateau> JohnLea: hey, it seems you are active here. Can I have your opinion regarding bug #757650 ?
[14:50:30] <_mup_> Bug #757650: Unable to select a maximised app by clicking on left edge of the screen <apport-bug> <compiz-0.9> <i386> <natty> <needs-design> <running-unity> <ubuntu> <Ayatana Design:New> <unity:Incomplete> <unity (Ubuntu):Incomplete> < https://launchpad.net/bugs/757650 >
[14:50:57] <agateau> JohnLea: whether it matters or not will decide edge-reveal can be merged into unity-2d
[15:00:14] <JohnLea_> agateau; that is a good bug, I'll accept is a UX bug that needs fixing
[15:03:04] <agateau> JohnLea_: triggering the bug requires quite sharp reflexes... and is going to be quite complicated to fix... (read: X is getting in the way here) :(
[15:03:35] <JohnLea_> agateau; it's not a high priority bug, but it is a valid bug
[15:03:55] <JohnLea_> agateau; I'm adding a bit of clarity to the bug description
[15:04:01] <agateau> JohnLea_: ok. Do you think it should block the landing of edge-reveal feature in unity-2d?
[15:05:44] <JohnLea_> agateau; no, definitely not. Edge reveal is very important, this is far less important. However it will become a little bit more important with the *new* more responsive edge reveal behaviour that is on Jason's todo list
"""

Ugo Riboni (uriboni) wrote :

Works as advertised and code looks good.
I also confirm that this introduces bug #757650 for us, as expected.

review: Approve

Preview Diff

1=== modified file 'launcher/app/CMakeLists.txt'
2--- launcher/app/CMakeLists.txt 2011-03-14 13:53:10 +0000
3+++ launcher/app/CMakeLists.txt 2011-05-18 13:38:24 +0000
4@@ -9,6 +9,7 @@
5 set(launcher_SRCS
6 abstractvisibilitybehavior.cpp
7 autohidebehavior.cpp
8+ edgehitdetector.cpp
9 forcevisiblebehavior.cpp
10 visibilitycontroller.cpp
11 intellihidebehavior.cpp
12@@ -20,6 +21,7 @@
13 set(launcher_MOC_HDRS
14 abstractvisibilitybehavior.h
15 autohidebehavior.h
16+ edgehitdetector.h
17 forcevisiblebehavior.h
18 visibilitycontroller.h
19 intellihidebehavior.h
20
21=== modified file 'launcher/app/autohidebehavior.cpp'
22--- launcher/app/autohidebehavior.cpp 2011-03-22 11:30:53 +0000
23+++ launcher/app/autohidebehavior.cpp 2011-05-18 13:38:24 +0000
24@@ -22,11 +22,11 @@
25 #include "autohidebehavior.h"
26
27 // Local
28+#include <edgehitdetector.h>
29
30 // libunity-2d
31 #include <debug_p.h>
32 #include <unity2dpanel.h>
33-#include <mousearea.h>
34
35 // Qt
36 #include <QCursor>
37@@ -37,10 +37,11 @@
38 AutoHideBehavior::AutoHideBehavior(Unity2dPanel* panel)
39 : AbstractVisibilityBehavior(panel)
40 , m_autohideTimer(new QTimer(this))
41+, m_edgeHitDetector(0)
42 {
43 m_autohideTimer->setSingleShot(true);
44 m_autohideTimer->setInterval(AUTOHIDE_TIMEOUT);
45- connect(m_autohideTimer, SIGNAL(timeout()), m_panel, SLOT(slideOut()));
46+ connect(m_autohideTimer, SIGNAL(timeout()), SLOT(hidePanel()));
47
48 m_panel->installEventFilter(this);
49 if (!m_panel->geometry().contains(QCursor::pos())) {
50@@ -49,7 +50,7 @@
51 m_autohideTimer->start();
52 } else {
53 /* Launcher is partially hidden */
54- m_panel->slideOut();
55+ hidePanel();
56 }
57 }
58 }
59@@ -72,3 +73,25 @@
60 }
61 return false;
62 }
63+
64+void AutoHideBehavior::hidePanel()
65+{
66+ m_panel->slideOut();
67+ createEdgeHitDetector();
68+}
69+
70+void AutoHideBehavior::showPanel()
71+{
72+ // Delete the mouse area so that it does not prevent mouse events from
73+ // reaching the panel
74+ delete m_edgeHitDetector;
75+ m_edgeHitDetector = 0;
76+ m_autohideTimer->stop();
77+ m_panel->slideIn();
78+}
79+
80+void AutoHideBehavior::createEdgeHitDetector()
81+{
82+ m_edgeHitDetector = new EdgeHitDetector(this);
83+ connect(m_edgeHitDetector, SIGNAL(edgeHit()), SLOT(showPanel()));
84+}
85
86=== modified file 'launcher/app/autohidebehavior.h'
87--- launcher/app/autohidebehavior.h 2011-03-22 11:30:53 +0000
88+++ launcher/app/autohidebehavior.h 2011-05-18 13:38:24 +0000
89@@ -27,6 +27,7 @@
90 // Qt
91 #include <QObject>
92
93+class EdgeHitDetector;
94 class QTimer;
95 class Unity2dPanel;
96
97@@ -43,8 +44,15 @@
98 protected:
99 bool eventFilter(QObject*, QEvent*);
100
101+private Q_SLOTS:
102+ void hidePanel();
103+ void showPanel();
104+
105 private:
106 QTimer* m_autohideTimer;
107+ EdgeHitDetector* m_edgeHitDetector;
108+
109+ void createEdgeHitDetector();
110 };
111
112 #endif /* AUTOHIDEBEHAVIOR_H */
113
114=== added file 'launcher/app/edgehitdetector.cpp'
115--- launcher/app/edgehitdetector.cpp 1970-01-01 00:00:00 +0000
116+++ launcher/app/edgehitdetector.cpp 2011-05-18 13:38:24 +0000
117@@ -0,0 +1,57 @@
118+/*
119+ * This file is part of unity-2d
120+ *
121+ * Copyright 2011 Canonical Ltd.
122+ *
123+ * Authors:
124+ * - Aurélien Gâteau <aurelien.gateau@canonical.com>
125+ *
126+ * License: GPL v3
127+ */
128+// Self
129+#include "edgehitdetector.h"
130+
131+// Local
132+
133+// libunity-2d
134+#include <debug_p.h>
135+
136+// Qt
137+#include <QDesktopWidget>
138+#include <QTimer>
139+
140+static const int EDGE_HIT_DELAY = 500;
141+
142+EdgeHitDetector::EdgeHitDetector(QObject* parent)
143+: QObject(parent)
144+, m_mouseArea(new MouseArea(this))
145+, m_updateTimer(new QTimer(this))
146+, m_edgeHitTimer(new QTimer(this))
147+{
148+ updateGeometryFromScreen();
149+
150+ // Use a timer to delay geometry updates because sometimes when
151+ // QDesktopWidget emits its signals, immediatly asking for screen geometry
152+ // yields wrong results.
153+ m_updateTimer->setSingleShot(true);
154+ m_updateTimer->setInterval(1000);
155+ connect(m_updateTimer, SIGNAL(timeout()), SLOT(updateGeometryFromScreen()));
156+
157+ QDesktopWidget* desktop = QApplication::desktop();
158+ connect(desktop, SIGNAL(resized(int)), m_updateTimer, SLOT(start()));
159+ connect(desktop, SIGNAL(screenCountChanged(int)), m_updateTimer, SLOT(start()));
160+
161+ m_edgeHitTimer->setInterval(EDGE_HIT_DELAY);
162+ m_edgeHitTimer->setSingleShot(true);
163+ connect(m_edgeHitTimer, SIGNAL(timeout()), SIGNAL(edgeHit()));
164+
165+ connect(m_mouseArea, SIGNAL(entered()), m_edgeHitTimer, SLOT(start()));
166+ connect(m_mouseArea, SIGNAL(exited()), m_edgeHitTimer, SLOT(stop()));
167+}
168+
169+void EdgeHitDetector::updateGeometryFromScreen()
170+{
171+ int leftScreen = QApplication::desktop()->screenNumber(QPoint());
172+ QRect rect = QApplication::desktop()->screenGeometry(leftScreen);
173+ m_mouseArea->setGeometry(rect.left(), rect.top(), 1, rect.height());
174+}
175
176=== added file 'launcher/app/edgehitdetector.h'
177--- launcher/app/edgehitdetector.h 1970-01-01 00:00:00 +0000
178+++ launcher/app/edgehitdetector.h 2011-05-18 13:38:24 +0000
179@@ -0,0 +1,44 @@
180+/*
181+ * This file is part of unity-2d
182+ *
183+ * Copyright 2011 Canonical Ltd.
184+ *
185+ * Authors:
186+ * - Aurélien Gâteau <aurelien.gateau@canonical.com>
187+ *
188+ * License: GPL v3
189+ */
190+#ifndef EDGEHITDETECTOR_H
191+#define EDGEHITDETECTOR_H
192+
193+// Local
194+
195+// libunity-2d
196+#include <mousearea.h>
197+
198+// Qt
199+
200+class QTimer;
201+
202+/**
203+ * A mouse area which stays on the left edge of the leftmost screen
204+ */
205+class EdgeHitDetector : public QObject
206+{
207+Q_OBJECT
208+public:
209+ EdgeHitDetector(QObject* parent = 0);
210+
211+Q_SIGNALS:
212+ void edgeHit();
213+
214+private Q_SLOTS:
215+ void updateGeometryFromScreen();
216+
217+private:
218+ MouseArea* m_mouseArea;
219+ QTimer* m_updateTimer;
220+ QTimer* m_edgeHitTimer;
221+};
222+
223+#endif /* EDGEHITDETECTOR_H */
224
225=== modified file 'launcher/app/intellihidebehavior.cpp'
226--- launcher/app/intellihidebehavior.cpp 2011-03-23 14:31:55 +0000
227+++ launcher/app/intellihidebehavior.cpp 2011-05-18 13:38:24 +0000
228@@ -15,6 +15,7 @@
229
230 // libunity-2d
231 #include <debug_p.h>
232+#include <edgehitdetector.h>
233 #include <unity2dpanel.h>
234
235 // Qt
236@@ -66,6 +67,7 @@
237 IntelliHideBehavior::IntelliHideBehavior(Unity2dPanel* panel)
238 : AbstractVisibilityBehavior(panel)
239 , m_updateVisibilityTimer(new QTimer(this))
240+, m_edgeHitDetector(0)
241 , m_activeWindow(0)
242 {
243 m_updateVisibilityTimer->setSingleShot(true);
244@@ -167,9 +169,9 @@
245 }
246
247 if (crossWindow) {
248- m_panel->slideOut();
249+ hidePanel();
250 } else {
251- m_panel->slideIn();
252+ showPanel();
253 }
254 }
255
256@@ -194,3 +196,24 @@
257 // is unreliable. It causes LP bug #740280
258 return m_panel->geometry().contains(QCursor::pos());
259 }
260+
261+void IntelliHideBehavior::hidePanel()
262+{
263+ m_panel->slideOut();
264+ createEdgeHitDetector();
265+}
266+
267+void IntelliHideBehavior::showPanel()
268+{
269+ // Delete the edge hit detector so that it does not prevent mouse events
270+ // from reaching the panel
271+ delete m_edgeHitDetector;
272+ m_edgeHitDetector = 0;
273+ m_panel->slideIn();
274+}
275+
276+void IntelliHideBehavior::createEdgeHitDetector()
277+{
278+ m_edgeHitDetector = new EdgeHitDetector(this);
279+ connect(m_edgeHitDetector, SIGNAL(edgeHit()), SLOT(showPanel()));
280+}
281\ No newline at end of file
282
283=== modified file 'launcher/app/intellihidebehavior.h'
284--- launcher/app/intellihidebehavior.h 2011-03-23 11:00:12 +0000
285+++ launcher/app/intellihidebehavior.h 2011-05-18 13:38:24 +0000
286@@ -22,6 +22,7 @@
287 class QTimer;
288
289 class Unity2dPanel;
290+class EdgeHitDetector;
291
292 /**
293 * This class implements the Intellihide behavior of the launcher
294@@ -39,6 +40,8 @@
295 private Q_SLOTS:
296 void updateVisibility();
297 void updateActiveWindowConnections();
298+ void showPanel();
299+ void hidePanel();
300
301 private:
302 Q_DISABLE_COPY(IntelliHideBehavior);
303@@ -48,12 +51,15 @@
304 HiddenPanel
305 };
306 QTimer* m_updateVisibilityTimer;
307+ EdgeHitDetector* m_edgeHitDetector;
308
309 struct _WnckWindow* m_activeWindow;
310
311 void disconnectFromGSignals();
312
313 bool isMouseForcingVisibility() const;
314+
315+ void createEdgeHitDetector();
316 };
317
318 #endif /* INTELLIHIDEBEHAVIOR_H */

Subscribers

People subscribed via source and target branches