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
=== modified file 'libunity-2d-private/src/strutmanager.cpp'
--- libunity-2d-private/src/strutmanager.cpp 2012-01-23 14:31:06 +0000
+++ libunity-2d-private/src/strutmanager.cpp 2012-02-09 09:32:19 +0000
@@ -47,6 +47,9 @@
47 m_width(-1),47 m_width(-1),
48 m_height(-1)48 m_height(-1)
49{49{
50 QDesktopWidget* desktop = QApplication::desktop();
51 connect(desktop, SIGNAL(resized(int)), SLOT(updateStrut()));
52 connect(desktop, SIGNAL(workAreaResized(int)), SLOT(updateStrut()));
50}53}
5154
52StrutManager::~StrutManager()55StrutManager::~StrutManager()
@@ -81,8 +84,17 @@
8184
82void StrutManager::setWidget(QObject *widget)85void StrutManager::setWidget(QObject *widget)
83{86{
84 m_widget = qobject_cast<QWidget*>(widget);87 if (m_widget != widget) {
85 Q_ASSERT(m_widget != NULL);88 if (m_widget) {
89 m_widget->removeEventFilter(this);
90 releaseStrut();
91 }
92 m_widget = qobject_cast<QWidget*>(widget);
93 Q_ASSERT(m_widget != NULL);
94 m_widget->installEventFilter(this);
95 updateStrut();
96 Q_EMIT widgetChanged(m_widget);
97 }
86}98}
8799
88Unity2dPanel::Edge StrutManager::edge() const100Unity2dPanel::Edge StrutManager::edge() const
@@ -92,8 +104,11 @@
92104
93void StrutManager::setEdge(Unity2dPanel::Edge edge)105void StrutManager::setEdge(Unity2dPanel::Edge edge)
94{106{
95 m_edge = edge;107 if (m_edge != edge) {
96 updateStrut();108 m_edge = edge;
109 updateStrut();
110 Q_EMIT edgeChanged(m_edge);
111 }
97}112}
98113
99int StrutManager::width() const114int StrutManager::width() const
@@ -103,7 +118,11 @@
103118
104void StrutManager::setWidth(int width)119void StrutManager::setWidth(int width)
105{120{
106 m_width = width;121 if (m_width != width) {
122 m_width = width;
123 updateStrut();
124 Q_EMIT widthChanged(m_width);
125 }
107}126}
108127
109int StrutManager::realWidth() const128int StrutManager::realWidth() const
@@ -124,7 +143,11 @@
124143
125void StrutManager::setHeight(int height)144void StrutManager::setHeight(int height)
126{145{
127 m_height = height;146 if (m_height != height) {
147 m_height = height;
148 updateStrut();
149 Q_EMIT heightChanged(m_height);
150 }
128}151}
129152
130int StrutManager::realHeight() const153int StrutManager::realHeight() const
@@ -145,7 +168,6 @@
145 }168 }
146}169}
147170
148
149void StrutManager::reserveStrut()171void StrutManager::reserveStrut()
150{172{
151 if (m_widget == NULL)173 if (m_widget == NULL)
@@ -188,4 +210,14 @@
188 setStrut(struts, m_widget->effectiveWinId());210 setStrut(struts, m_widget->effectiveWinId());
189}211}
190212
213bool StrutManager::eventFilter(QObject *watched, QEvent *event)
214{
215 Q_ASSERT(watched == m_widget);
216
217 if (event->type() == QEvent::Show || event->type() == QEvent::Resize) {
218 updateStrut();
219 }
220 return QObject::eventFilter(watched, event);
221}
222
191#include "strutmanager.moc"223#include "strutmanager.moc"
192224
=== modified file 'libunity-2d-private/src/strutmanager.h'
--- libunity-2d-private/src/strutmanager.h 2012-01-23 14:31:06 +0000
+++ libunity-2d-private/src/strutmanager.h 2012-02-09 09:32:19 +0000
@@ -30,10 +30,10 @@
30{30{
31 Q_OBJECT31 Q_OBJECT
32 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)32 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
33 Q_PROPERTY(QObject* widget READ widget WRITE setWidget)33 Q_PROPERTY(QObject* widget READ widget WRITE setWidget NOTIFY widgetChanged)
34 Q_PROPERTY(Unity2dPanel::Edge edge READ edge WRITE setEdge)34 Q_PROPERTY(Unity2dPanel::Edge edge READ edge WRITE setEdge NOTIFY edgeChanged)
35 Q_PROPERTY(int width READ width WRITE setWidth)35 Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
36 Q_PROPERTY(int height READ height WRITE setHeight)36 Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
3737
38public:38public:
39 StrutManager();39 StrutManager();
@@ -73,10 +73,18 @@
73 */73 */
74 int realHeight() const;74 int realHeight() const;
7575
76 Q_INVOKABLE void updateStrut();
77
78Q_SIGNALS:76Q_SIGNALS:
79 void enabledChanged(bool enabled);77 void enabledChanged(bool enabled);
78 void widgetChanged(QObject *widget);
79 void edgeChanged(Unity2dPanel::Edge edge);
80 void widthChanged(int width);
81 void heightChanged(int height);
82
83protected:
84 bool eventFilter(QObject *watched, QEvent *event);
85
86private Q_SLOTS:
87 void updateStrut();
8088
81private:89private:
82 void reserveStrut();90 void reserveStrut();
8391
=== modified file 'libunity-2d-private/src/unity2dpanel.cpp'
--- libunity-2d-private/src/unity2dpanel.cpp 2012-02-07 11:57:10 +0000
+++ libunity-2d-private/src/unity2dpanel.cpp 2012-02-09 09:32:19 +0000
@@ -90,7 +90,6 @@
9090
91 void updateEdge()91 void updateEdge()
92 {92 {
93 m_strutManager.updateStrut();
94 updateGeometry();93 updateGeometry();
95 updateLayoutDirection();94 updateLayoutDirection();
96 }95 }
9796
=== modified file 'shell/Shell.qml'
--- shell/Shell.qml 2012-02-08 14:53:49 +0000
+++ shell/Shell.qml 2012-02-09 09:32:19 +0000
@@ -26,7 +26,7 @@
26 /* Space reserved by strutManager is taken off screen.availableGeometry but26 /* Space reserved by strutManager is taken off screen.availableGeometry but
27 we want the shell to take all the available space, including the one we27 we want the shell to take all the available space, including the one we
28 reserved ourselves via strutManager. */28 reserved ourselves via strutManager. */
29 height: declarativeView.screen.availableGeometry.height + (strutManager.enabled ? strutManager.height : 0)29 height: declarativeView.screen.availableGeometry.height
30 width: declarativeView.screen.availableGeometry.width + (strutManager.enabled ? strutManager.width : 0)30 width: declarativeView.screen.availableGeometry.width + (strutManager.enabled ? strutManager.width : 0)
3131
32 Accessible.name: "shell"32 Accessible.name: "shell"
@@ -170,9 +170,5 @@
170 height: launcherLoader.height170 height: launcherLoader.height
171 width: launcherLoader.width171 width: launcherLoader.width
172 enabled: Utils.clamp(launcher2dConfiguration.hideMode, 0, 2) == 0172 enabled: Utils.clamp(launcher2dConfiguration.hideMode, 0, 2) == 0
173
174 Component.onCompleted: {
175 strutManager.updateStrut()
176 }
177 }173 }
178}174}

Subscribers

People subscribed via source and target branches