Merge lp:~aacid/unity-2d/unity-2d-shell_strutmanager_improvements into lp:~unity-2d-team/unity-2d/unity-2d-shell

Proposed by Albert Astals Cid
Status: Merged
Approved by: Florian Boucault
Approved revision: 985
Merged at revision: 995
Proposed branch: lp:~aacid/unity-2d/unity-2d-shell_strutmanager_improvements
Merge into: lp:~unity-2d-team/unity-2d/unity-2d-shell
Diff against target: 171 lines (+54/-19)
4 files modified
libunity-2d-private/src/strutmanager.cpp (+39/-7)
libunity-2d-private/src/strutmanager.h (+14/-6)
libunity-2d-private/src/unity2dpanel.cpp (+0/-1)
shell/Shell.qml (+1/-5)
To merge this branch: bzr merge lp:~aacid/unity-2d/unity-2d-shell_strutmanager_improvements
Reviewer Review Type Date Requested Status
Florian Boucault Pending
Review via email: mp+92226@code.launchpad.net

Description of the change

Improvements to the StrutManager

More signals, less need to tell it to update itself

To post a comment you must log in.
Revision history for this message
Florian Boucault (fboucault) wrote :

In Shell.qml, you removed:

- height: declarativeView.screen.availableGeometry.height + (strutManager.enabled ? strutManager.height : 0)

It looks like an unrelated change.
I know that the height of the strutManager is 0 today but if it changes in the future (when we add the panel to the shell), we will forget to put it back.

Revision history for this message
Florian Boucault (fboucault) wrote :

Everything else is good to go.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libunity-2d-private/src/strutmanager.cpp'
2--- libunity-2d-private/src/strutmanager.cpp 2012-01-23 14:31:06 +0000
3+++ libunity-2d-private/src/strutmanager.cpp 2012-02-09 09:32:19 +0000
4@@ -47,6 +47,9 @@
5 m_width(-1),
6 m_height(-1)
7 {
8+ QDesktopWidget* desktop = QApplication::desktop();
9+ connect(desktop, SIGNAL(resized(int)), SLOT(updateStrut()));
10+ connect(desktop, SIGNAL(workAreaResized(int)), SLOT(updateStrut()));
11 }
12
13 StrutManager::~StrutManager()
14@@ -81,8 +84,17 @@
15
16 void StrutManager::setWidget(QObject *widget)
17 {
18- m_widget = qobject_cast<QWidget*>(widget);
19- Q_ASSERT(m_widget != NULL);
20+ if (m_widget != widget) {
21+ if (m_widget) {
22+ m_widget->removeEventFilter(this);
23+ releaseStrut();
24+ }
25+ m_widget = qobject_cast<QWidget*>(widget);
26+ Q_ASSERT(m_widget != NULL);
27+ m_widget->installEventFilter(this);
28+ updateStrut();
29+ Q_EMIT widgetChanged(m_widget);
30+ }
31 }
32
33 Unity2dPanel::Edge StrutManager::edge() const
34@@ -92,8 +104,11 @@
35
36 void StrutManager::setEdge(Unity2dPanel::Edge edge)
37 {
38- m_edge = edge;
39- updateStrut();
40+ if (m_edge != edge) {
41+ m_edge = edge;
42+ updateStrut();
43+ Q_EMIT edgeChanged(m_edge);
44+ }
45 }
46
47 int StrutManager::width() const
48@@ -103,7 +118,11 @@
49
50 void StrutManager::setWidth(int width)
51 {
52- m_width = width;
53+ if (m_width != width) {
54+ m_width = width;
55+ updateStrut();
56+ Q_EMIT widthChanged(m_width);
57+ }
58 }
59
60 int StrutManager::realWidth() const
61@@ -124,7 +143,11 @@
62
63 void StrutManager::setHeight(int height)
64 {
65- m_height = height;
66+ if (m_height != height) {
67+ m_height = height;
68+ updateStrut();
69+ Q_EMIT heightChanged(m_height);
70+ }
71 }
72
73 int StrutManager::realHeight() const
74@@ -145,7 +168,6 @@
75 }
76 }
77
78-
79 void StrutManager::reserveStrut()
80 {
81 if (m_widget == NULL)
82@@ -188,4 +210,14 @@
83 setStrut(struts, m_widget->effectiveWinId());
84 }
85
86+bool StrutManager::eventFilter(QObject *watched, QEvent *event)
87+{
88+ Q_ASSERT(watched == m_widget);
89+
90+ if (event->type() == QEvent::Show || event->type() == QEvent::Resize) {
91+ updateStrut();
92+ }
93+ return QObject::eventFilter(watched, event);
94+}
95+
96 #include "strutmanager.moc"
97
98=== modified file 'libunity-2d-private/src/strutmanager.h'
99--- libunity-2d-private/src/strutmanager.h 2012-01-23 14:31:06 +0000
100+++ libunity-2d-private/src/strutmanager.h 2012-02-09 09:32:19 +0000
101@@ -30,10 +30,10 @@
102 {
103 Q_OBJECT
104 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
105- Q_PROPERTY(QObject* widget READ widget WRITE setWidget)
106- Q_PROPERTY(Unity2dPanel::Edge edge READ edge WRITE setEdge)
107- Q_PROPERTY(int width READ width WRITE setWidth)
108- Q_PROPERTY(int height READ height WRITE setHeight)
109+ Q_PROPERTY(QObject* widget READ widget WRITE setWidget NOTIFY widgetChanged)
110+ Q_PROPERTY(Unity2dPanel::Edge edge READ edge WRITE setEdge NOTIFY edgeChanged)
111+ Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
112+ Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
113
114 public:
115 StrutManager();
116@@ -73,10 +73,18 @@
117 */
118 int realHeight() const;
119
120- Q_INVOKABLE void updateStrut();
121-
122 Q_SIGNALS:
123 void enabledChanged(bool enabled);
124+ void widgetChanged(QObject *widget);
125+ void edgeChanged(Unity2dPanel::Edge edge);
126+ void widthChanged(int width);
127+ void heightChanged(int height);
128+
129+protected:
130+ bool eventFilter(QObject *watched, QEvent *event);
131+
132+private Q_SLOTS:
133+ void updateStrut();
134
135 private:
136 void reserveStrut();
137
138=== modified file 'libunity-2d-private/src/unity2dpanel.cpp'
139--- libunity-2d-private/src/unity2dpanel.cpp 2012-02-07 11:57:10 +0000
140+++ libunity-2d-private/src/unity2dpanel.cpp 2012-02-09 09:32:19 +0000
141@@ -90,7 +90,6 @@
142
143 void updateEdge()
144 {
145- m_strutManager.updateStrut();
146 updateGeometry();
147 updateLayoutDirection();
148 }
149
150=== modified file 'shell/Shell.qml'
151--- shell/Shell.qml 2012-02-08 14:53:49 +0000
152+++ shell/Shell.qml 2012-02-09 09:32:19 +0000
153@@ -26,7 +26,7 @@
154 /* Space reserved by strutManager is taken off screen.availableGeometry but
155 we want the shell to take all the available space, including the one we
156 reserved ourselves via strutManager. */
157- height: declarativeView.screen.availableGeometry.height + (strutManager.enabled ? strutManager.height : 0)
158+ height: declarativeView.screen.availableGeometry.height
159 width: declarativeView.screen.availableGeometry.width + (strutManager.enabled ? strutManager.width : 0)
160
161 Accessible.name: "shell"
162@@ -170,9 +170,5 @@
163 height: launcherLoader.height
164 width: launcherLoader.width
165 enabled: Utils.clamp(launcher2dConfiguration.hideMode, 0, 2) == 0
166-
167- Component.onCompleted: {
168- strutManager.updateStrut()
169- }
170 }
171 }

Subscribers

People subscribed via source and target branches