on xenial help sign in
low crome
982fabeNick Dedekind
qml/Shell.qml+1−2
@@ -533,8 +533,7 @@ Item {
533 }
533 }
534
534
535 readonly property bool topmostApplicationIsFullscreen:
535 readonly property bool topmostApplicationIsFullscreen:
536− ApplicationManager.focusedApplicationId &&
536+ applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainAppWindowIsFullscreen : false
537− ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).fullscreen
538
537
539 fullscreenMode: (topmostApplicationIsFullscreen && !lightDM.greeter.active && launcher.progress == 0)
538 fullscreenMode: (topmostApplicationIsFullscreen && !lightDM.greeter.active && launcher.progress == 0)
540 || greeter.hasLockedApp
539 || greeter.hasLockedApp
qml/Stages/AbstractStage.qml+1
@@ -43,6 +43,7 @@ Rectangle {
43 // To be read from outside
43 // To be read from outside
44 property var mainApp: null
44 property var mainApp: null
45 property int mainAppWindowOrientationAngle
45 property int mainAppWindowOrientationAngle
46+ property bool mainAppWindowIsFullscreen: false
46 property bool orientationChangesEnabled
47 property bool orientationChangesEnabled
47 property int supportedOrientations: Qt.PortraitOrientation
48 property int supportedOrientations: Qt.PortraitOrientation
48 | Qt.LandscapeOrientation
49 | Qt.LandscapeOrientation
qml/Stages/ApplicationWindow.qml−1
@@ -24,7 +24,6 @@ FocusScope {
24 implicitHeight: sessionContainer.implicitHeight
24 implicitHeight: sessionContainer.implicitHeight
25
25
26 // to be read from outside
26 // to be read from outside
27− readonly property bool fullscreen: application ? application.fullscreen : false
28 property alias interactive: sessionContainer.interactive
27 property alias interactive: sessionContainer.interactive
29 property bool orientationChangesEnabled: d.supportsSurfaceResize ? d.surfaceOldEnoughToBeResized : true
28 property bool orientationChangesEnabled: d.supportsSurfaceResize ? d.surfaceOldEnoughToBeResized : true
30 readonly property string title: sessionContainer.surface && sessionContainer.surface.name !== "" ?
29 readonly property string title: sessionContainer.surface && sessionContainer.surface.name !== "" ?
qml/Stages/DecoratedWindow.qml+4−5
@@ -24,15 +24,14 @@ FocusScope {
24 id: root
24 id: root
25
25
26 width: applicationWindow.width
26 width: applicationWindow.width
27− height: (decorationShown ? decoration.height : 0) + applicationWindow.height
27+ height: (fullscreen ? 0 : decoration.height) + applicationWindow.height
28
28
29 property alias window: applicationWindow
29 property alias window: applicationWindow
30 property alias application: applicationWindow.application
30 property alias application: applicationWindow.application
31 property alias active: decoration.active
31 property alias active: decoration.active
32 property alias title: decoration.title
32 property alias title: decoration.title
33− property alias fullscreen: applicationWindow.fullscreen
33+ property bool fullscreen: false
34
34
35− readonly property bool decorationShown: !fullscreen
36 property bool highlightShown: false
35 property bool highlightShown: false
37 property real shadowOpacity: 1
36 property real shadowOpacity: 1
38
37
@@ -84,7 +83,7 @@ FocusScope {
84 height: units.gu(3)
83 height: units.gu(3)
85 width: root.width
84 width: root.width
86 title: window.title
85 title: window.title
87− visible: root.decorationShown
86+ visible: !fullscreen
88
87
89 onClose: root.close();
88 onClose: root.close();
90 onMaximize: { root.decorationPressed(); root.maximize(); }
89 onMaximize: { root.decorationPressed(); root.maximize(); }
@@ -98,7 +97,7 @@ FocusScope {
98 anchors.top: parent.top
97 anchors.top: parent.top
99 anchors.topMargin: decoration.height
98 anchors.topMargin: decoration.height
100 anchors.left: parent.left
99 anchors.left: parent.left
101− requestedHeight: root.requestedHeight - (root.decorationShown ? decoration.height : 0)
100+ requestedHeight: root.requestedHeight - (fullscreen ? 0 : decoration.height)
102 interactive: true
101 interactive: true
103 focus: true
102 focus: true
104 }
103 }
qml/Stages/DesktopStage.qml+23
@@ -440,6 +440,12 @@ AbstractStage {
440 value: ApplicationManager.count + 1
440 value: ApplicationManager.count + 1
441 when: index == spread.highlightedIndex && blurLayer.ready
441 when: index == spread.highlightedIndex && blurLayer.ready
442 }
442 }
443+ Binding {
444+ target: root
445+ when: index == 0
446+ property: "mainAppWindowIsFullscreen"
447+ value: decoratedWindow.fullscreen
448+ }
443
449
444 WindowResizeArea {
450 WindowResizeArea {
445 objectName: "windowResizeArea"
451 objectName: "windowResizeArea"
@@ -462,6 +468,7 @@ AbstractStage {
462 application: ApplicationManager.get(index)
468 application: ApplicationManager.get(index)
463 active: ApplicationManager.focusedApplicationId === model.appId
469 active: ApplicationManager.focusedApplicationId === model.appId
464 focus: true
470 focus: true
471+ fullscreen: application.fullscreen
465
472
466 onClose: ApplicationManager.stopApplication(model.appId)
473 onClose: ApplicationManager.stopApplication(model.appId)
467 onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
474 onMaximize: appDelegate.maximized || appDelegate.maximizedLeft || appDelegate.maximizedRight
@@ -469,6 +476,22 @@ AbstractStage {
469 onMinimize: appDelegate.minimize()
476 onMinimize: appDelegate.minimize()
470 onDecorationPressed: { ApplicationManager.focusApplication(model.appId) }
477 onDecorationPressed: { ApplicationManager.focusApplication(model.appId) }
471 }
478 }
479+
480+ property bool firstTimeSurface: true
481+ property var lastSurface: decoratedWindow.application && decoratedWindow.application.session ?
482+ decoratedWindow.application.session.lastSurface : null
483+ onLastSurfaceChanged: {
484+ if (!lastSurface) return;
485+ if (!firstTimeSurface) return;
486+ firstTimeSurface = false;
487+
488+ console.log("FULLSCREEN CHECK", lastSurface.state, lastSurface.shellChrome)
489+
490+ if (lastSurface.state === Mir.FullscreenState &&
491+ lastSurface.shellChrome === Mir.LowChrome) {
492+ lastSurface.state = Mir.RestoredState;
493+ }
494+ }
472 }
495 }
473 }
496 }
474 }
497 }
qml/Stages/PhoneStage.qml+21
@@ -574,12 +574,33 @@ AbstractStage {
574 property: "mainAppWindowOrientationAngle"
574 property: "mainAppWindowOrientationAngle"
575 value: appWindowOrientationAngle
575 value: appWindowOrientationAngle
576 }
576 }
577+ Binding {
578+ target: root
579+ when: index == 0
580+ property: "mainAppWindowIsFullscreen"
581+ value: appDelegate.fullscreen
582+ }
577 Binding {
583 Binding {
578 target: priv
584 target: priv
579 when: index == 0
585 when: index == 0
580 property: "focusedAppOrientationChangesEnabled"
586 property: "focusedAppOrientationChangesEnabled"
581 value: orientationChangesEnabled
587 value: orientationChangesEnabled
582 }
588 }
589+
590+ property bool firstTimeSurface: true
591+ property var lastSurface: application && application.session ?
592+ application.session.lastSurface : null
593+ onLastSurfaceChanged: {
594+ if (!lastSurface) return;
595+ if (!firstTimeSurface) return;
596+ firstTimeSurface = false;
597+
598+ if (lastSurface.state !== Mir.FullscreenState &&
599+ lastSurface.shellChrome === Mir.LowChrome) {
600+ lastSurface.state = Mir.FullscreenState;
601+ }
602+ }
603+ fullscreen: lastSurface ? lastSurface.shellChrome === Mir.LowChrome : false
583 }
604 }
584 }
605 }
585 }
606 }
qml/Stages/SpreadDelegate.qml+2−1
@@ -43,6 +43,7 @@ FocusScope {
43 property int shellOrientationAngle
43 property int shellOrientationAngle
44 property int shellOrientation
44 property int shellOrientation
45 property QtObject orientations
45 property QtObject orientations
46+ property bool fullscreen: false
46
47
47 function matchShellOrientation() {
48 function matchShellOrientation() {
48 if (!root.application)
49 if (!root.application)
@@ -267,7 +268,7 @@ FocusScope {
267 focus: true
268 focus: true
268 anchors {
269 anchors {
269 fill: parent
270 fill: parent
270− topMargin: appWindow.fullscreen || (application && application.rotatesWindowContents)
271+ topMargin: fullscreen || (application && application.rotatesWindowContents)
271 ? 0 : maximizedAppTopMargin
272 ? 0 : maximizedAppTopMargin
272 }
273 }
273
274
qml/Stages/TabletStage.qml+21
@@ -730,6 +730,12 @@ AbstractStage {
730 property: "mainAppWindowOrientationAngle"
730 property: "mainAppWindowOrientationAngle"
731 value: appWindowOrientationAngle
731 value: appWindowOrientationAngle
732 }
732 }
733+ Binding {
734+ target: root
735+ when: index == 0
736+ property: "mainAppWindowIsFullscreen"
737+ value: decoratedWindow.fullscreen
738+ }
733 Binding {
739 Binding {
734 target: priv
740 target: priv
735 when: model.appId == priv.mainStageAppId
741 when: model.appId == priv.mainStageAppId
@@ -743,6 +749,21 @@ AbstractStage {
743 period: (spreadView.positionMarker2 - spreadView.positionMarker1) / 3
749 period: (spreadView.positionMarker2 - spreadView.positionMarker1) / 3
744 progress: spreadTile.progress - spreadView.positionMarker1
750 progress: spreadTile.progress - spreadView.positionMarker1
745 }
751 }
752+
753+ property bool firstTimeSurface: true
754+ property var lastSurface: application && application.session ?
755+ application.session.lastSurface : null
756+ onLastSurfaceChanged: {
757+ if (!lastSurface) return;
758+ if (!firstTimeSurface) return;
759+ firstTimeSurface = false;
760+
761+ if (lastSurface.state !== Mir.FullscreenState &&
762+ lastSurface.shellChrome === Mir.LowChrome) {
763+ lastSurface.state = Mir.FullscreenState;
764+ }
765+ }
766+ fullscreen: lastSurface ? lastSurface.shellChrome === Mir.LowChrome : false
746 }
767 }
747 }
768 }
748 }
769 }
tests/mocks/Unity/Application/ApplicationInfo.cpp+21−3
@@ -44,6 +44,7 @@ ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
44 , m_isTouchApp(true)
44 , m_isTouchApp(true)
45 , m_exemptFromLifecycle(false)
45 , m_exemptFromLifecycle(false)
46 , m_manualSurfaceCreation(false)
46 , m_manualSurfaceCreation(false)
47+ , m_shellChrome(Mir::NormalChrome)
47{
48{
48}
49}
49
50
@@ -63,6 +64,7 @@ ApplicationInfo::ApplicationInfo(QObject *parent)
63 , m_isTouchApp(true)
64 , m_isTouchApp(true)
64 , m_exemptFromLifecycle(false)
65 , m_exemptFromLifecycle(false)
65 , m_manualSurfaceCreation(false)
66 , m_manualSurfaceCreation(false)
67+ , m_shellChrome(Mir::NormalChrome)
66{
68{
67}
69}
68
70
@@ -102,9 +104,11 @@ void ApplicationInfo::setSession(Session* session)
102 if (m_session) {
104 if (m_session) {
103 m_session->setApplication(this);
105 m_session->setApplication(this);
104 m_session->setParent(this);
106 m_session->setParent(this);
107+ m_session->setFullscreen(m_fullscreen);
105 SessionManager::singleton()->registerSession(m_session);
108 SessionManager::singleton()->registerSession(m_session);
106 connect(m_session, &Session::surfaceAdded,
109 connect(m_session, &Session::surfaceAdded,
107 this, &ApplicationInfo::onSessionSurfaceAdded);
110 this, &ApplicationInfo::onSessionSurfaceAdded);
111+ connect(m_session, &Session::fullscreenChanged, this, &ApplicationInfo::fullscreenChanged);
108
112
109 if (!m_manualSurfaceCreation) {
113 if (!m_manualSurfaceCreation) {
110 QTimer::singleShot(500, m_session, &Session::createSurface);
114 QTimer::singleShot(500, m_session, &Session::createSurface);
@@ -191,12 +195,17 @@ void ApplicationInfo::setFocused(bool value)
191
195
192void ApplicationInfo::setFullscreen(bool value)
196void ApplicationInfo::setFullscreen(bool value)
193{
197{
194− if (value != m_fullscreen) {
198+ m_fullscreen = value;
195− m_fullscreen = value;
199+ if (m_session) {
196− Q_EMIT fullscreenChanged(value);
200+ m_session->setFullscreen(value);
197 }
201 }
198}
202}
199
203
204+bool ApplicationInfo::fullscreen() const
205+{
206+ return m_session ? m_session->fullscreen() : false;
207+}
208+
200void ApplicationInfo::setManualSurfaceCreation(bool value)
209void ApplicationInfo::setManualSurfaceCreation(bool value)
201{
210{
202 if (value != m_manualSurfaceCreation) {
211 if (value != m_manualSurfaceCreation) {
@@ -262,6 +271,7 @@ void ApplicationInfo::onSessionSurfaceAdded(MirSurface* surface)
262 } else {
271 } else {
263 setState(Suspended);
272 setState(Suspended);
264 }
273 }
274+ surface->setShellChrome(m_shellChrome);
265 }
275 }
266}
276}
267
277
@@ -291,3 +301,11 @@ void ApplicationInfo::setInitialSurfaceSize(const QSize &size)
291 Q_EMIT initialSurfaceSizeChanged(m_initialSurfaceSize);
301 Q_EMIT initialSurfaceSizeChanged(m_initialSurfaceSize);
292 }
302 }
293}
303}
304+
305+void ApplicationInfo::setShellChrome(Mir::ShellChrome shellChrome)
306+{
307+ m_shellChrome = shellChrome;
308+ if (m_session && m_session->lastSurface()) {
309+ m_session->lastSurface()->setShellChrome(shellChrome);
310+ }
311+}
tests/mocks/Unity/Application/ApplicationInfo.h+5−1
@@ -24,6 +24,7 @@ class Session;
24
24
25// unity-api
25// unity-api
26#include <unity/shell/application/ApplicationInfoInterface.h>
26#include <unity/shell/application/ApplicationInfoInterface.h>
27+#include <unity/shell/application/Mir.h>
27
28
28using namespace unity::shell::application;
29using namespace unity::shell::application;
29
30
@@ -78,7 +79,7 @@ public:
78 QString screenshot() const { return m_screenshotFileName; }
79 QString screenshot() const { return m_screenshotFileName; }
79
80
80 void setFullscreen(bool value);
81 void setFullscreen(bool value);
81− bool fullscreen() const { return m_fullscreen; }
82+ bool fullscreen() const;
82
83
83 Qt::ScreenOrientations supportedOrientations() const override;
84 Qt::ScreenOrientations supportedOrientations() const override;
84 void setSupportedOrientations(Qt::ScreenOrientations orientations);
85 void setSupportedOrientations(Qt::ScreenOrientations orientations);
@@ -97,6 +98,8 @@ public:
97
98
98 QSize initialSurfaceSize() const override;
99 QSize initialSurfaceSize() const override;
99 void setInitialSurfaceSize(const QSize &size) override;
100 void setInitialSurfaceSize(const QSize &size) override;
101+
102+ Q_INVOKABLE void setShellChrome(Mir::ShellChrome shellChrome);
100public:
103public:
101 void setSession(Session* session);
104 void setSession(Session* session);
102 Session* session() const { return m_session; }
105 Session* session() const { return m_session; }
@@ -134,6 +137,7 @@ private:
134 QSize m_initialSurfaceSize;
137 QSize m_initialSurfaceSize;
135
138
136 bool m_manualSurfaceCreation;
139 bool m_manualSurfaceCreation;
140+ Mir::ShellChrome m_shellChrome;
137};
141};
138
142
139Q_DECLARE_METATYPE(ApplicationInfo*)
143Q_DECLARE_METATYPE(ApplicationInfo*)
tests/mocks/Unity/Application/ApplicationManager.cpp+3−4
@@ -336,6 +336,7 @@ void ApplicationManager::buildListOfAvailableApplications()
336 application->setName("Camera");
336 application->setName("Camera");
337 application->setScreenshotId("camera");
337 application->setScreenshotId("camera");
338 application->setIconId("camera");
338 application->setIconId("camera");
339+ application->setShellChrome(Mir::LowChrome);
339 application->setFullscreen(true);
340 application->setFullscreen(true);
340 application->setSupportedOrientations(Qt::PortraitOrientation
341 application->setSupportedOrientations(Qt::PortraitOrientation
341 | Qt::LandscapeOrientation
342 | Qt::LandscapeOrientation
@@ -349,7 +350,7 @@ void ApplicationManager::buildListOfAvailableApplications()
349 application->setName("Gallery");
350 application->setName("Gallery");
350 application->setScreenshotId("gallery");
351 application->setScreenshotId("gallery");
351 application->setIconId("gallery");
352 application->setIconId("gallery");
352− application->setFullscreen(true);
353+ application->setShellChrome(Mir::LowChrome);
353 application->setStage(ApplicationInfo::MainStage);
354 application->setStage(ApplicationInfo::MainStage);
354 m_availableApplications.append(application);
355 m_availableApplications.append(application);
355
356
@@ -363,7 +364,7 @@ void ApplicationManager::buildListOfAvailableApplications()
363
364
364 application = new ApplicationInfo(this);
365 application = new ApplicationInfo(this);
365 application->setAppId("webbrowser-app");
366 application->setAppId("webbrowser-app");
366− application->setFullscreen(true);
367+ application->setShellChrome(Mir::LowChrome);
367 application->setName("Browser");
368 application->setName("Browser");
368 application->setScreenshotId("browser");
369 application->setScreenshotId("browser");
369 application->setIconId("browser");
370 application->setIconId("browser");
@@ -389,7 +390,6 @@ void ApplicationManager::buildListOfAvailableApplications()
389 application->setName("GMail");
390 application->setName("GMail");
390 application->setIconId("gmail");
391 application->setIconId("gmail");
391 application->setScreenshotId("gmail-webapp.svg");
392 application->setScreenshotId("gmail-webapp.svg");
392− application->setFullscreen(false);
393 application->setStage(ApplicationInfo::MainStage);
393 application->setStage(ApplicationInfo::MainStage);
394 application->setSupportedOrientations(Qt::PortraitOrientation
394 application->setSupportedOrientations(Qt::PortraitOrientation
395 | Qt::LandscapeOrientation
395 | Qt::LandscapeOrientation
@@ -402,7 +402,6 @@ void ApplicationManager::buildListOfAvailableApplications()
402 application->setName("Music");
402 application->setName("Music");
403 application->setIconId("soundcloud");
403 application->setIconId("soundcloud");
404 application->setScreenshotId("music");
404 application->setScreenshotId("music");
405− application->setFullscreen(false);
406 application->setStage(ApplicationInfo::MainStage);
405 application->setStage(ApplicationInfo::MainStage);
407 application->setSupportedOrientations(Qt::PortraitOrientation
406 application->setSupportedOrientations(Qt::PortraitOrientation
408 | Qt::LandscapeOrientation
407 | Qt::LandscapeOrientation
tests/mocks/Unity/Application/MirSurface.cpp+17
@@ -36,6 +36,7 @@ MirSurface::MirSurface(const QString& name,
36 , m_width(-1)
36 , m_width(-1)
37 , m_height(-1)
37 , m_height(-1)
38 , m_slowToResize(false)
38 , m_slowToResize(false)
39+ , m_shellChrome(Mir::NormalChrome)
39{
40{
40// qDebug() << "MirSurface::MirSurface() " << name;
41// qDebug() << "MirSurface::MirSurface() " << name;
41 m_delayedResizeTimer.setInterval(600);
42 m_delayedResizeTimer.setInterval(600);
@@ -70,6 +71,7 @@ void MirSurface::setState(Mir::State state)
70
71
71 m_state = state;
72 m_state = state;
72 Q_EMIT stateChanged(state);
73 Q_EMIT stateChanged(state);
74+ qDebug() << "SETSTATE!" << state;
73}
75}
74
76
75bool MirSurface::live() const
77bool MirSurface::live() const
@@ -130,6 +132,21 @@ void MirSurface::setOrientationAngle(Mir::OrientationAngle angle)
130}
132}
131
133
132
134
135+Mir::ShellChrome MirSurface::shellChrome() const
136+{
137+ return m_shellChrome;
138+}
139+
140+void MirSurface::setShellChrome(Mir::ShellChrome shellChrome)
141+{
142+ if (shellChrome == m_shellChrome)
143+ return;
144+
145+ m_shellChrome = shellChrome;
146+ Q_EMIT shellChromeChanged(shellChrome);
147+}
148+
149+
133
150
134void MirSurface::registerView(qintptr viewId)
151void MirSurface::registerView(qintptr viewId)
135{
152{
tests/mocks/Unity/Application/MirSurface.h+5−3
@@ -73,10 +73,13 @@ public:
73 int widthIncrement() const override { return m_widthIncrement; }
73 int widthIncrement() const override { return m_widthIncrement; }
74 int heightIncrement() const override { return m_heightIncrement; }
74 int heightIncrement() const override { return m_heightIncrement; }
75
75
76+ Mir::ShellChrome shellChrome() const override;
77+
76 ////
78 ////
77 // API for tests
79 // API for tests
78
80
79 Q_INVOKABLE void setLive(bool live);
81 Q_INVOKABLE void setLive(bool live);
82+ Q_INVOKABLE void setShellChrome(Mir::ShellChrome shellChrome);
80
83
81 void registerView(qintptr viewId);
84 void registerView(qintptr viewId);
82 void unregisterView(qintptr viewId);
85 void unregisterView(qintptr viewId);
@@ -108,9 +111,6 @@ public:
108 void setActiveFocus(bool);
111 void setActiveFocus(bool);
109
112
110Q_SIGNALS:
113Q_SIGNALS:
111− void stateChanged(Mir::State);
112− void liveChanged(bool live);
113− void orientationAngleChanged(Mir::OrientationAngle angle);
114 void widthChanged();
114 void widthChanged();
115 void heightChanged();
115 void heightChanged();
116 void slowToResizeChanged();
116 void slowToResizeChanged();
@@ -151,6 +151,8 @@ private:
151 QSize m_delayedResize;
151 QSize m_delayedResize;
152 QSize m_pendingResize;
152 QSize m_pendingResize;
153
153
154+ Mir::ShellChrome m_shellChrome;
155+
154 struct View {
156 struct View {
155 bool visible;
157 bool visible;
156 };
158 };
tests/mocks/Unity/Application/MirSurfaceItem.cpp+9
@@ -100,6 +100,15 @@ bool MirSurfaceItem::live() const
100 }
100 }
101}
101}
102
102
103+Mir::ShellChrome MirSurfaceItem::shellChrome() const
104+{
105+ if (m_qmlSurface) {
106+ return m_qmlSurface->shellChrome();
107+ } else {
108+ return Mir::NormalChrome;
109+ }
110+}
111+
103Mir::OrientationAngle MirSurfaceItem::orientationAngle() const
112Mir::OrientationAngle MirSurfaceItem::orientationAngle() const
104{
113{
105 if (m_qmlSurface) {
114 if (m_qmlSurface) {
tests/mocks/Unity/Application/MirSurfaceItem.h+1
@@ -47,6 +47,7 @@ public:
47 Mir::Type type() const override;
47 Mir::Type type() const override;
48 QString name() const override;
48 QString name() const override;
49 bool live() const override;
49 bool live() const override;
50+ Mir::ShellChrome shellChrome() const override;
50
51
51 Mir::State surfaceState() const override;
52 Mir::State surfaceState() const override;
52 void setSurfaceState(Mir::State) override {}
53 void setSurfaceState(Mir::State) override {}
tests/mocks/Unity/Application/Session.cpp+28−1
@@ -34,6 +34,7 @@ Session::Session(const QString &name,
34 , m_surface(nullptr)
34 , m_surface(nullptr)
35 , m_parentSession(nullptr)
35 , m_parentSession(nullptr)
36 , m_children(new SessionModel(this))
36 , m_children(new SessionModel(this))
37+ , m_fullscreen(false)
37{
38{
38// qDebug() << "Session::Session() " << this->name();
39// qDebug() << "Session::Session() " << this->name();
39
40
@@ -71,6 +72,27 @@ void Session::release()
71 deleteLater();
72 deleteLater();
72}
73}
73
74
75+void Session::updateFullscreenProperty()
76+{
77+ qDebug() << "updateFullscreenProperty!";
78+
79+ if (m_surfaces.rowCount() > 0) {
80+ // TODO: Figure out something better
81+ setFullscreen(lastSurface()->state() == Mir::FullscreenState);
82+ } else {
83+ // Keep the current value of the fullscreen property until we get a new
84+ // surface
85+ }
86+}
87+
88+void Session::setFullscreen(bool fullscreen)
89+{
90+ if (m_fullscreen != fullscreen) {
91+ m_fullscreen = fullscreen;
92+ Q_EMIT fullscreenChanged(m_fullscreen);
93+ }
94+}
95+
74void Session::setApplication(ApplicationInfo* application)
96void Session::setApplication(ApplicationInfo* application)
75{
97{
76 if (m_application == application)
98 if (m_application == application)
@@ -82,15 +104,18 @@ void Session::setApplication(ApplicationInfo* application)
82
104
83void Session::appendSurface(MirSurface* surface)
105void Session::appendSurface(MirSurface* surface)
84{
106{
85− // qDebug() << "Session::appendSurface - session=" << name() << "surface=" << surface;
107+ qDebug() << "Session::appendSurface - session=" << name() << "surface=" << surface;
86
108
87 m_surfaces.insert(m_surfaces.rowCount(), surface);
109 m_surfaces.insert(m_surfaces.rowCount(), surface);
88
110
111+ connect(surface, &MirSurfaceInterface::stateChanged, this, &Session::updateFullscreenProperty);
89 connect(surface, &QObject::destroyed,
112 connect(surface, &QObject::destroyed,
90 this, [this, surface]() { this->removeSurface(surface); });
113 this, [this, surface]() { this->removeSurface(surface); });
91
114
92 Q_EMIT lastSurfaceChanged(surface);
115 Q_EMIT lastSurfaceChanged(surface);
93 Q_EMIT surfaceAdded(surface);
116 Q_EMIT surfaceAdded(surface);
117+
118+ updateFullscreenProperty();
94}
119}
95
120
96void Session::removeSurface(MirSurface* surface)
121void Session::removeSurface(MirSurface* surface)
@@ -99,6 +124,8 @@ void Session::removeSurface(MirSurface* surface)
99 if (m_surfaces.contains(surface)) {
124 if (m_surfaces.contains(surface)) {
100 m_surfaces.remove(surface);
125 m_surfaces.remove(surface);
101 }
126 }
127+
128+ updateFullscreenProperty();
102}
129}
103
130
104void Session::setScreenshot(const QUrl& screenshot)
131void Session::setScreenshot(const QUrl& screenshot)
tests/mocks/Unity/Application/Session.h+7
@@ -47,6 +47,7 @@ public:
47 //getters
47 //getters
48 QString name() const { return m_name; }
48 QString name() const { return m_name; }
49 bool live() const { return m_live; }
49 bool live() const { return m_live; }
50+ bool fullscreen() const { return m_fullscreen; }
50 ApplicationInfo* application() const { return m_application; }
51 ApplicationInfo* application() const { return m_application; }
51 MirSurface *lastSurface() const;
52 MirSurface *lastSurface() const;
52 ObjectListModel<MirSurface>* surfaces() const;
53 ObjectListModel<MirSurface>* surfaces() const;
@@ -57,6 +58,7 @@ public:
57 void removeSurface(MirSurface* surface);
58 void removeSurface(MirSurface* surface);
58 void setScreenshot(const QUrl& m_screenshot);
59 void setScreenshot(const QUrl& m_screenshot);
59 void setLive(bool live);
60 void setLive(bool live);
61+ void setFullscreen(bool fullscreen);
60
62
61 Q_INVOKABLE void addChildSession(Session* session);
63 Q_INVOKABLE void addChildSession(Session* session);
62 void insertChildSession(uint index, Session* session);
64 void insertChildSession(uint index, Session* session);
@@ -68,6 +70,7 @@ Q_SIGNALS:
68 void liveChanged(bool live);
70 void liveChanged(bool live);
69 void surfaceAdded(MirSurface *surface);
71 void surfaceAdded(MirSurface *surface);
70 void lastSurfaceChanged(MirSurface *surface);
72 void lastSurfaceChanged(MirSurface *surface);
73+ void fullscreenChanged(bool fullscreen);
71
74
72 // internal mock use
75 // internal mock use
73 void deregister();
76 void deregister();
@@ -75,6 +78,9 @@ Q_SIGNALS:
75public Q_SLOTS:
78public Q_SLOTS:
76 Q_INVOKABLE void createSurface();
79 Q_INVOKABLE void createSurface();
77
80
81+private Q_SLOTS:
82+ void updateFullscreenProperty();
83+
78private:
84private:
79 SessionModel* childSessions() const;
85 SessionModel* childSessions() const;
80 void setParentSession(Session* session);
86 void setParentSession(Session* session);
@@ -87,6 +93,7 @@ private:
87 Session* m_parentSession;
93 Session* m_parentSession;
88 SessionModel* m_children;
94 SessionModel* m_children;
89 ObjectListModel<MirSurface> m_surfaces;
95 ObjectListModel<MirSurface> m_surfaces;
96+ bool m_fullscreen;
90
97
91 friend class ApplicationTestInterface;
98 friend class ApplicationTestInterface;
92};
99};
tests/qmltests/tst_Shell.qml+54
@@ -139,6 +139,9 @@ Rectangle {
139 anchors.right: root.right
139 anchors.right: root.right
140 width: units.gu(30)
140 width: units.gu(30)
141
141
142+ property var focusedApp: ApplicationManager.findApplication(ApplicationManager.focusedApplicationId)
143+ property var focusedSurface: focusedApp && focusedApp.session ? focusedApp.session.lastSurface : null
144+
142 Rectangle {
145 Rectangle {
143 id: controlRect
146 id: controlRect
144 anchors { left: parent.left; right: parent.right }
147 anchors { left: parent.left; right: parent.right }
@@ -234,6 +237,57 @@ Rectangle {
234 appId: modelData
237 appId: modelData
235 }
238 }
236 }
239 }
240+
241+ Label { text: "Focused Application"; font.bold: true }
242+
243+ Row {
244+ CheckBox {
245+ id: fullscreeAppCheck
246+
247+ onTriggered: {
248+ if (controls.focusedSurface.state == Mir.FullscreenState) {
249+ controls.focusedSurface.state = Mir.RestoredState;
250+ } else {
251+ controls.focusedSurface.state = Mir.FullscreenState;
252+ }
253+ }
254+
255+ Binding {
256+ target: fullscreeAppCheck
257+ when: controls.focusedSurface !== null
258+ property: "checked"
259+ value: controls.focusedSurface.state === Mir.FullscreenState
260+ }
261+ }
262+ Label {
263+ text: "Fullscreen"
264+ }
265+ }
266+
267+ Row {
268+ CheckBox {
269+ id: chromeAppCheck
270+
271+ onTriggered: {
272+ if (controls.focusedSurface.shellChrome == Mir.LowChrome) {
273+ controls.focusedSurface.setShellChrome(Mir.NormalChrome);
274+ } else {
275+ controls.focusedSurface.setShellChrome(Mir.LowChrome);
276+ }
277+ }
278+
279+ Binding {
280+ target: chromeAppCheck
281+ when: controls.focusedSurface !== null
282+ property: "checked"
283+ value: controls.focusedSurface.shellChrome === Mir.LowChrome
284+ }
285+ }
286+ Label {
287+ text: "Low Chrome"
288+ }
289+ }
290+
237 }
291 }
238 }
292 }
239 }
293 }