on xenial help sign in
fixed surface visibility
6d92157Nick Dedekind
qml/Stages/DesktopStage.qml+25−5
@@ -150,13 +150,16 @@ Rectangle {
150 property bool maximized: false
150 property bool maximized: false
151 property bool minimized: false
151 property bool minimized: false
152
152
153+ property bool visuallyMaximized: false
154+ property bool visuallyMinimized: false
155+
153 onFocusChanged: {
156 onFocusChanged: {
154 if (focus && ApplicationManager.focusedApplicationId !== model.appId) {
157 if (focus && ApplicationManager.focusedApplicationId !== model.appId) {
155 ApplicationManager.focusApplication(model.appId);
158 ApplicationManager.focusApplication(model.appId);
156 }
159 }
157 }
160 }
158
161
159− readonly property bool foregroundMaximized: maximized && index == 0
162+ readonly property bool foregroundMaximized: visuallyMaximized && index == 0
160 onForegroundMaximizedChanged: {
163 onForegroundMaximizedChanged: {
161 if (foregroundMaximized) {
164 if (foregroundMaximized) {
162 priv.foregroundMaximizedAppId = model.appId;
165 priv.foregroundMaximizedAppId = model.appId;
@@ -165,8 +168,9 @@ Rectangle {
165 }
168 }
166 }
169 }
167
170
168− visible: !minimized &&
171+ visible: !visuallyMinimized &&
169 (priv.foregroundMaximizedAppId === "" || priv.foregroundMaximizedAppId === model.appId)
172 (priv.foregroundMaximizedAppId === "" || priv.foregroundMaximizedAppId === model.appId)
173+ || (spread.focus && index === spread.highlightedIndex)
170
174
171 Binding {
175 Binding {
172 target: ApplicationManager.get(index)
176 target: ApplicationManager.get(index)
@@ -207,9 +211,25 @@ Rectangle {
207 ]
211 ]
208 transitions: [
212 transitions: [
209 Transition {
213 Transition {
210− from: "maximized,minimized,normal,"
214+ to: "normal"
215+ PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized"; value: false }
216+ PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale," }
217+ },
218+ Transition {
211− to: "maximized,minimized,normal,"
219+ to: "maximized"
220+ SequentialAnimation {
221+ PropertyAction { target: appDelegate; property: "visuallyMinimized"; value: false }
222+ PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale" }
223+ PropertyAction { target: appDelegate; property: "visuallyMaximized"; value: true }
224+ }
225+ },
226+ Transition {
227+ to: "minimized"
228+ SequentialAnimation {
229+ PropertyAction { target: appDelegate; property: "visuallyMaximized"; value: false }
212− PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale" }
230+ PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale" }
231+ PropertyAction { target: appDelegate; property: "visuallyMinimized"; value: true }
232+ }
213 },
233 },
214 Transition {
234 Transition {
215 from: ""
235 from: ""
tests/mocks/Unity/Application/MirSurface.cpp+35−26
@@ -32,7 +32,6 @@ MirSurface::MirSurface(const QString& name,
32 , m_qmlFilePath(qmlFilePath)
32 , m_qmlFilePath(qmlFilePath)
33 , m_live(true)
33 , m_live(true)
34 , m_visible(true)
34 , m_visible(true)
35− , m_viewCount(0)
36 , m_activeFocus(false)
35 , m_activeFocus(false)
37 , m_width(-1)
36 , m_width(-1)
38 , m_height(-1)
37 , m_height(-1)
@@ -88,7 +87,7 @@ void MirSurface::setLive(bool live)
88 m_live = live;
87 m_live = live;
89 Q_EMIT liveChanged(live);
88 Q_EMIT liveChanged(live);
90
89
91− if (!m_live && m_viewCount == 0) {
90+ if (!m_live && m_views.count() == 0) {
92 deleteLater();
91 deleteLater();
93 }
92 }
94}
93}
@@ -126,27 +125,49 @@ void MirSurface::setOrientationAngle(Mir::OrientationAngle angle)
126 Q_EMIT orientationAngleChanged(angle);
125 Q_EMIT orientationAngleChanged(angle);
127}
126}
128
127
129−void MirSurface::incrementViewCount()
128+
129+
130+void MirSurface::registerView(qintptr viewId)
130{
131{
131− ++m_viewCount;
132+ m_views.insert(viewId, MirSurface::View{false});
132−// qDebug().nospace() << "MirSurface::incrementViewCount() viewCount(after)=" << m_viewCount << " " << name();
133+ qDebug().nospace() << "MirSurface[" << name() << "]::registerView(" << viewId << ")"
134+ << " after=" << m_views.count();
133}
135}
134
136
135−void MirSurface::decrementViewCount()
137+void MirSurface::unregisterView(qintptr viewId)
136{
138{
137− --m_viewCount;
139+ qDebug().nospace() << "MirSurface[" << name() << "]::unregisterView(" << viewId << ")"
138−// qDebug().nospace() << "MirSurface::decrementViewCount() viewCount(after)=" << m_viewCount << " " << name();
140+ << " after=" << m_views.count() << " live=" << m_live;
139−
141+ m_views.remove(viewId);
140− Q_ASSERT(m_viewCount >= 0);
141−
142− if (!m_live && m_viewCount == 0) {
142+ if (!m_live && m_views.count() == 0) {
143 deleteLater();
143 deleteLater();
144 }
144 }
145+ updateVisibility();
145}
146}
146
147
147−int MirSurface::viewCount() const
148+void MirSurface::setViewVisibility(qintptr viewId, bool visible)
148{
149{
149− return m_viewCount;
150+ if (!m_views.contains(viewId)) return;
151+
152+ m_views[viewId].visible = visible;
153+ updateVisibility();
154+}
155+
156+void MirSurface::updateVisibility()
157+{
158+ bool newVisible = false;
159+ QHashIterator<qintptr, View> i(m_views);
160+ while (i.hasNext()) {
161+ i.next();
162+ newVisible |= i.value().visible;
163+ }
164+
165+ if (newVisible != visible()) {
166+// qDebug().nospace() << "MirSurface[" << name() << "]::updateVisibility(" << newVisible << ")";
167+
168+ m_visible = newVisible;
169+ Q_EMIT visibleChanged(m_visible);
170+ }
150}
171}
151
172
152bool MirSurface::activeFocus() const
173bool MirSurface::activeFocus() const
@@ -164,18 +185,6 @@ void MirSurface::setActiveFocus(bool value)
164 Q_EMIT activeFocusChanged(value);
185 Q_EMIT activeFocusChanged(value);
165}
186}
166
187
167−void MirSurface::setVisible(bool visible)
168−{
169− qDebug() << "MirSurface::setVisible(visible=" << visible << ")";
170−
171− if (m_visible == visible)
172− return;
173−
174− m_visible = visible;
175−
176− Q_EMIT visibleChanged(m_visible);
177−}
178−
179int MirSurface::width() const
188int MirSurface::width() const
180{
189{
181 return m_width;
190 return m_width;
tests/mocks/Unity/Application/MirSurface.h+11−6
@@ -19,6 +19,7 @@
19
19
20#include <QObject>
20#include <QObject>
21#include <QUrl>
21#include <QUrl>
22+#include <QHash>
22
23
23// unity-api
24// unity-api
24#include <unity/shell/application/MirSurfaceInterface.h>
25#include <unity/shell/application/MirSurfaceInterface.h>
@@ -68,9 +69,10 @@ public:
68
69
69 Q_INVOKABLE void setLive(bool live);
70 Q_INVOKABLE void setLive(bool live);
70
71
71− void incrementViewCount();
72+ void registerView(qintptr viewId);
72− void decrementViewCount();
73+ void unregisterView(qintptr viewId);
74+ void setViewVisibility(qintptr viewId, bool visible);
73− int viewCount() const;
75+ int viewCount() const { return m_views.count(); }
74
76
75 int width() const;
77 int width() const;
76 int height() const;
78 int height() const;
@@ -86,8 +88,6 @@ public:
86 bool activeFocus() const;
88 bool activeFocus() const;
87 void setActiveFocus(bool);
89 void setActiveFocus(bool);
88
90
89− void setVisible(bool visible);
90−
91Q_SIGNALS:
91Q_SIGNALS:
92 void stateChanged(Mir::State);
92 void stateChanged(Mir::State);
93 void liveChanged(bool live);
93 void liveChanged(bool live);
@@ -101,6 +101,8 @@ Q_SIGNALS:
101 void activeFocusChanged(bool);
101 void activeFocusChanged(bool);
102
102
103private:
103private:
104+ void updateVisibility();
105+
104 const QString m_name;
106 const QString m_name;
105 const Mir::Type m_type;
107 const Mir::Type m_type;
106 Mir::State m_state;
108 Mir::State m_state;
@@ -109,10 +111,13 @@ private:
109 QUrl m_qmlFilePath;
111 QUrl m_qmlFilePath;
110 bool m_live;
112 bool m_live;
111 bool m_visible;
113 bool m_visible;
112− int m_viewCount;
113 bool m_activeFocus;
114 bool m_activeFocus;
114 int m_width;
115 int m_width;
115 int m_height;
116 int m_height;
117+ struct View {
118+ bool visible;
119+ };
120+ QHash<qintptr, View> m_views;
116};
121};
117
122
118#endif // MOCK_MIR_SURFACE_H
123#endif // MOCK_MIR_SURFACE_H
tests/mocks/Unity/Application/MirSurfaceItem.cpp+12−7
@@ -44,6 +44,8 @@ MirSurfaceItem::MirSurfaceItem(QQuickItem *parent)
44 Qt::ExtraButton5 | Qt::ExtraButton6 | Qt::ExtraButton7 | Qt::ExtraButton8 |
44 Qt::ExtraButton5 | Qt::ExtraButton6 | Qt::ExtraButton7 | Qt::ExtraButton8 |
45 Qt::ExtraButton9 | Qt::ExtraButton10 | Qt::ExtraButton11 |
45 Qt::ExtraButton9 | Qt::ExtraButton10 | Qt::ExtraButton11 |
46 Qt::ExtraButton12 | Qt::ExtraButton13);
46 Qt::ExtraButton12 | Qt::ExtraButton13);
47+
48+ connect(this, &QQuickItem::visibleChanged, this, &MirSurfaceItem::updateMirSurfaceVisibility);
47}
49}
48
50
49MirSurfaceItem::~MirSurfaceItem()
51MirSurfaceItem::~MirSurfaceItem()
@@ -194,18 +196,18 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
194 m_qmlContentComponent = nullptr;
196 m_qmlContentComponent = nullptr;
195
197
196 disconnect(m_qmlSurface, nullptr, this, nullptr);
198 disconnect(m_qmlSurface, nullptr, this, nullptr);
197− m_qmlSurface->decrementViewCount();
199+ m_qmlSurface->unregisterView((qintptr)this);
198 }
200 }
199
201
200 m_qmlSurface = static_cast<MirSurface*>(surface);
202 m_qmlSurface = static_cast<MirSurface*>(surface);
201
203
202 if (m_qmlSurface) {
204 if (m_qmlSurface) {
203− m_qmlSurface->incrementViewCount();
205+ m_qmlSurface->registerView((qintptr)this);
204
206
205 m_qmlSurface->setActiveFocus(hasActiveFocus());
207 m_qmlSurface->setActiveFocus(hasActiveFocus());
206− m_qmlSurface->setVisible(isVisible());
207
208
208 updateSurfaceSize();
209 updateSurfaceSize();
210+ updateMirSurfaceVisibility();
209
211
210 connect(m_qmlSurface, &MirSurface::orientationAngleChanged, this, &MirSurfaceItem::orientationAngleChanged);
212 connect(m_qmlSurface, &MirSurface::orientationAngleChanged, this, &MirSurfaceItem::orientationAngleChanged);
211 connect(m_qmlSurface, &MirSurface::screenshotUrlChanged, this, &MirSurfaceItem::updateScreenshot);
213 connect(m_qmlSurface, &MirSurface::screenshotUrlChanged, this, &MirSurfaceItem::updateScreenshot);
@@ -251,13 +253,16 @@ void MirSurfaceItem::itemChange(ItemChange change, const ItemChangeData & value)
251 if (m_qmlSurface) {
253 if (m_qmlSurface) {
252 m_qmlSurface->setActiveFocus(value.boolValue);
254 m_qmlSurface->setActiveFocus(value.boolValue);
253 }
255 }
254− } else if (change == QQuickItem::ItemVisibleHasChanged) {
255− if (m_qmlSurface) {
256− m_qmlSurface->setVisible(value.boolValue);
257− }
258 }
256 }
259}
257}
260
258
259+void MirSurfaceItem::updateMirSurfaceVisibility()
260+{
261+ if (!m_qmlSurface) return;
262+
263+ m_qmlSurface->setViewVisibility((qintptr)this, isVisible());
264+}
265+
261void MirSurfaceItem::setConsumesInput(bool value)
266void MirSurfaceItem::setConsumesInput(bool value)
262{
267{
263 if (m_consumesInput != value) {
268 if (m_consumesInput != value) {
tests/mocks/Unity/Application/MirSurfaceItem.h+1
@@ -87,6 +87,7 @@ protected:
87private Q_SLOTS:
87private Q_SLOTS:
88 void onComponentStatusChanged(QQmlComponent::Status status);
88 void onComponentStatusChanged(QQmlComponent::Status status);
89 void updateScreenshot(QUrl screenshot);
89 void updateScreenshot(QUrl screenshot);
90+ void updateMirSurfaceVisibility();
90
91
91private:
92private:
92 void createQmlContentItem();
93 void createQmlContentItem();