Merge lp:~macslow/qtmir/fix-1475678 into lp:qtmir

Proposed by Mirco Müller
Status: Work in progress
Proposed branch: lp:~macslow/qtmir/fix-1475678
Merge into: lp:qtmir
Diff against target: 172 lines (+66/-0)
4 files modified
src/modules/Unity/Application/mirsurfaceitem.cpp (+29/-0)
src/modules/Unity/Application/mirsurfaceitem.h (+5/-0)
src/modules/Unity/Application/mirsurfacemanager.cpp (+29/-0)
src/modules/Unity/Application/mirsurfacemanager.h (+3/-0)
To merge this branch: bzr merge lp:~macslow/qtmir/fix-1475678
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+266418@code.launchpad.net

Commit message

Added hook to allow MirSurfaceManager to mark MirSurfaceItems visible/non-visible.

Description of the change

Added hook to allow MirSurfaceManager to mark MirSurfaceItems visible/non-visible.

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote :

m_surface->visible()
this isn't doing what you'd expect. Looking into the Mir code: src/server/scene/basic_surface.cpp:

bool ms::BasicSurface::visible() const
{
    std::unique_lock<std::mutex> lk(guard);
    return visible(lk);
}

bool ms::BasicSurface::visible(std::unique_lock<std::mutex>&) const
{
    bool visible{false};
    for (auto const& info : layers)
        visible |= info.stream->has_submitted_buffer();
    return !hidden && visible;
}

This is a place where the integration of QtMir and Mir isn't so good. Mir kinda assumes that we're using its Scene, and thus its compositor. But we're not. Our Scene is defined in QML, and our compositor is the Qt scenegraph renderer.

BasicSurface::visible() defines if the surface is visible in Mir's scene. It doesn't notify the client that its surface is exposed or not.

So instead you should ignore this, and read the surface attribute to learn if the client thinks it is exposed or not.

Revision history for this message
Gerry Boland (gerboland) wrote :

I'm unclear why you're introducing "visibility" - do you want to distinguish QML's visible state from the client's exposure state?

I also don't see the point of an enum for it, it's just true/false.

Revision history for this message
Gerry Boland (gerboland) wrote :

void MirSurfaceManager::displayOff()
void MirSurfaceManager::displayOn()

I disapprove of this design. A surface manager should not care about display state. It's the shell's decision if a client surface should be marked invisible when the display is off.

Also this throws away any visibility state that the shell may have set on surfaces.

A remote desktop would be an example where we don't care about the actual display state.

lp:~macslow/qtmir/fix-1475678 updated
349. By Mirco Müller

Just use visible as a term instead of visibility for MirSurfaceItem and map that to mir::scene::surface's visibility-attribute.

Revision history for this message
Mirco Müller (macslow) wrote :

> ...
> So instead you should ignore this, and read the surface attribute to learn if
> the client thinks it is exposed or not.

This has been addressed.

Revision history for this message
Mirco Müller (macslow) wrote :

> I'm unclear why you're introducing "visibility" - do you want to distinguish
> QML's visible state from the client's exposure state?
>
> I also don't see the point of an enum for it, it's just true/false.

I got rid of visibility.

Revision history for this message
Mirco Müller (macslow) wrote :

> void MirSurfaceManager::displayOff()
> void MirSurfaceManager::displayOn()
>
> I disapprove of this design. A surface manager should not care about display
> state. It's the shell's decision if a client surface should be marked
> invisible when the display is off.
>
> Also this throws away any visibility state that the shell may have set on
> surfaces.
>
> A remote desktop would be an example where we don't care about the actual
> display state.

displayOn()/displayOff() are just temp. methods for quicker testing of the correct working of the visible-flag propagation. They will not stay... it's a WIP-branch after all :)

Unmerged revisions

349. By Mirco Müller

Just use visible as a term instead of visibility for MirSurfaceItem and map that to mir::scene::surface's visibility-attribute.

348. By Mirco Müller

Added hooks to allow MirSurfaceManager to mark MirSurfaceItems visible/non-visible.

347. By Mirco Müller

Merge with trunk.

346. By Mirco Müller

Expose visibility property of MirSurfaceItem.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/modules/Unity/Application/mirsurfaceitem.cpp'
2--- src/modules/Unity/Application/mirsurfaceitem.cpp 2015-07-16 06:53:53 +0000
3+++ src/modules/Unity/Application/mirsurfaceitem.cpp 2015-07-31 13:26:26 +0000
4@@ -260,6 +260,8 @@
5 //m_surface->configure(mir_surface_attrib_focus, mir_surface_unfocused);
6 connect(this, &QQuickItem::activeFocusChanged, this, &MirSurfaceItem::updateMirSurfaceFocus);
7
8+ connect(this, &QQuickItem::visibleChanged, this, &MirSurfaceItem::updateMirSurfaceVisibility);
9+
10 if (m_session) {
11 connect(m_session.data(), &Session::stateChanged, this, &MirSurfaceItem::onSessionStateChanged);
12 }
13@@ -306,6 +308,11 @@
14 return static_cast<MirSurfaceItem::State>(m_surface->state());
15 }
16
17+bool MirSurfaceItem::visible() const
18+{
19+ return m_surface->query(mir_surface_attrib_visibility) == mir_surface_visibility_exposed;
20+}
21+
22 MirSurfaceItem::OrientationAngle MirSurfaceItem::orientationAngle() const
23 {
24 return m_orientationAngle;
25@@ -672,6 +679,15 @@
26 }
27 }
28
29+void MirSurfaceItem::setVisible(const bool visible)
30+{
31+ qDebug() << "MirSurfaceItem::setVisible(" << (visible ? "true" : "false") << ")";
32+ if (this->visible() != visible) {
33+ m_shell->set_surface_attribute(m_session->session(), m_surface, mir_surface_attrib_visibility, static_cast<int>(visible));
34+ Q_EMIT visibleChanged();
35+ }
36+}
37+
38 void MirSurfaceItem::setLive(const bool live)
39 {
40 if (m_live != live) {
41@@ -689,6 +705,9 @@
42 case mir_surface_attrib_state:
43 Q_EMIT stateChanged();
44 break;
45+ case mir_surface_attrib_visibility:
46+ Q_EMIT visibleChanged();
47+ break;
48 default:
49 break;
50 }
51@@ -735,6 +754,16 @@
52 }
53 }
54
55+void MirSurfaceItem::updateMirSurfaceVisibility()
56+{
57+ qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::updateMirSurfaceVisibility";
58+ if (visible()) {
59+ m_shell->set_surface_attribute(m_session->session(), m_surface, mir_surface_attrib_visibility, mir_surface_visibility_exposed);
60+ } else {
61+ m_shell->set_surface_attribute(m_session->session(), m_surface, mir_surface_attrib_visibility, mir_surface_visibility_occluded);
62+ }
63+}
64+
65 void MirSurfaceItem::dropPendingBuffers()
66 {
67 QMutexLocker locker(&m_mutex);
68
69=== modified file 'src/modules/Unity/Application/mirsurfaceitem.h'
70--- src/modules/Unity/Application/mirsurfaceitem.h 2015-05-13 17:18:45 +0000
71+++ src/modules/Unity/Application/mirsurfaceitem.h 2015-07-31 13:26:26 +0000
72@@ -52,6 +52,7 @@
73
74 Q_PROPERTY(Type type READ type NOTIFY typeChanged)
75 Q_PROPERTY(State state READ state NOTIFY stateChanged)
76+ Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
77 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
78 Q_PROPERTY(bool live READ live NOTIFY liveChanged)
79
80@@ -98,6 +99,7 @@
81 //getters
82 Type type() const;
83 State state() const;
84+ bool visible() const;
85 QString name() const;
86 bool live() const;
87 SessionInterface *session() const;
88@@ -128,6 +130,7 @@
89 Q_SIGNALS:
90 void typeChanged();
91 void stateChanged();
92+ void visibleChanged();
93 void nameChanged();
94 void orientationAngleChanged(OrientationAngle angle);
95 void liveChanged(bool live);
96@@ -161,6 +164,7 @@
97 void updateMirSurfaceSize();
98
99 void updateMirSurfaceFocus(bool focused);
100+ void updateMirSurfaceVisibility();
101 void onAttributeChanged(const MirSurfaceAttrib, const int);
102
103 private:
104@@ -169,6 +173,7 @@
105
106 void setType(const Type&);
107 void setState(const State&);
108+ void setVisible(const bool);
109 void setLive(const bool);
110
111 // called by MirSurfaceManager
112
113=== modified file 'src/modules/Unity/Application/mirsurfacemanager.cpp'
114--- src/modules/Unity/Application/mirsurfacemanager.cpp 2015-03-11 10:10:49 +0000
115+++ src/modules/Unity/Application/mirsurfacemanager.cpp 2015-07-31 13:26:26 +0000
116@@ -17,6 +17,7 @@
117 // Qt
118 #include <QGuiApplication>
119 #include <QMutexLocker>
120+#include <QDebug>
121
122 // local
123 #include "mirsurfacemanager.h"
124@@ -94,6 +95,34 @@
125 m_mirSurfaceToItemHash.clear();
126 }
127
128+void MirSurfaceManager::displayOff()
129+{
130+ qDebug() << "MirSurfaceManager::displayOff() - surfaces: " << m_mirSurfaceToItemHash.size();
131+
132+ MirSurfaceItem* item = nullptr;
133+ QMutexLocker lock(&m_mutex);
134+ auto it = m_mirSurfaceToItemHash.begin();
135+ while (it != m_mirSurfaceToItemHash.end()) {
136+ item = it.value();
137+ item->setVisible(false);
138+ it++;
139+ }
140+}
141+
142+void MirSurfaceManager::displayOn()
143+{
144+ qDebug() << "MirSurfaceManager::displayOn() - surfaces: " << m_mirSurfaceToItemHash.size();
145+
146+ MirSurfaceItem* item = nullptr;
147+ QMutexLocker lock(&m_mutex);
148+ auto it = m_mirSurfaceToItemHash.begin();
149+ while (it != m_mirSurfaceToItemHash.end()) {
150+ item = it.value();
151+ item->setVisible(true);
152+ it++;
153+ }
154+}
155+
156 void MirSurfaceManager::onSessionCreatedSurface(const mir::scene::Session *mirSession,
157 const std::shared_ptr<mir::scene::Surface> &surface,
158 const std::shared_ptr<SurfaceObserver> &observer)
159
160=== modified file 'src/modules/Unity/Application/mirsurfacemanager.h'
161--- src/modules/Unity/Application/mirsurfacemanager.h 2015-03-11 10:10:49 +0000
162+++ src/modules/Unity/Application/mirsurfacemanager.h 2015-07-31 13:26:26 +0000
163@@ -63,6 +63,9 @@
164
165 static MirSurfaceManager* singleton();
166
167+ Q_INVOKABLE void displayOff();
168+ Q_INVOKABLE void displayOn();
169+
170 Q_SIGNALS:
171 void surfaceCreated(MirSurfaceItem* surface);
172 void surfaceDestroyed(MirSurfaceItem* surface);

Subscribers

People subscribed via source and target branches