Merge lp:~gerboland/unity-mir/add-screen-blank into lp:unity-mir

Proposed by Gerry Boland
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 98
Merged at revision: 91
Proposed branch: lp:~gerboland/unity-mir/add-screen-blank
Merge into: lp:unity-mir
Diff against target: 274 lines (+176/-8)
7 files modified
debian/com.canonical.Unity.conf (+18/-0)
debian/libunity-mir1.install (+1/-0)
src/unity-mir/dbusscreen.cpp (+80/-0)
src/unity-mir/dbusscreen.h (+39/-0)
src/unity-mir/qmirserverapplication.cpp (+25/-4)
src/unity-mir/qmirserverapplication.h (+6/-1)
src/unity-mir/unity-mir.pro (+7/-3)
To merge this branch: bzr merge lp:~gerboland/unity-mir/add-screen-blank
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Ricardo Mendoza (community) Approve
Review via email: mp+187028@code.launchpad.net

Commit message

Adding controller for Display power mode and a DBus API to allow other processes to adjust it

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Need to wait for new Mir release (version 3)

90. By Gerry Boland

Merge trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
91. By Gerry Boland

Register dbus on the system bus, as powerd lives there

92. By Gerry Boland

Add dbus policy file to allow connection to system bus

93. By Gerry Boland

s/org/com/

94. By Gerry Boland

whitespace

95. By Gerry Boland

missed s/org/com/

Revision history for this message
Ricardo Mendoza (ricmm) wrote :

Tested. LGTM.

review: Approve
Revision history for this message
Robert Carr (robertcarr) wrote :

Is this tested on N4 or should I give it a run?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
96. By Gerry Boland

Some review comments addressed

97. By Gerry Boland

Fix usage of Q_D macro in const context

98. By Gerry Boland

Make sure to delete Private class when parent deleted

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'debian/com.canonical.Unity.conf'
2--- debian/com.canonical.Unity.conf 1970-01-01 00:00:00 +0000
3+++ debian/com.canonical.Unity.conf 2013-09-25 09:43:24 +0000
4@@ -0,0 +1,18 @@
5+<!DOCTYPE busconfig PUBLIC
6+ "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
7+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
8+<busconfig>
9+
10+ <policy user="phablet">
11+ <allow own="com.canonical.Unity.Screen"/>
12+ </policy>
13+
14+ <policy context="default">
15+ <deny send_destination="com.canonical.Unity.Screen"/>
16+ </policy>
17+
18+ <policy user="root">
19+ <allow send_destination="com.canonical.Unity.Screen"/>
20+ </policy>
21+
22+</busconfig>
23
24=== modified file 'debian/libunity-mir1.install'
25--- debian/libunity-mir1.install 2013-07-25 13:24:00 +0000
26+++ debian/libunity-mir1.install 2013-09-25 09:43:24 +0000
27@@ -1,2 +1,3 @@
28 usr/lib/*/libunity-mir.so.*
29 usr/lib/*/qt5/*
30+debian/com.canonical.Unity.conf etc/dbus-1/system.d/
31
32=== added file 'src/unity-mir/dbusscreen.cpp'
33--- src/unity-mir/dbusscreen.cpp 1970-01-01 00:00:00 +0000
34+++ src/unity-mir/dbusscreen.cpp 2013-09-25 09:43:24 +0000
35@@ -0,0 +1,80 @@
36+/*
37+ * Copyright (C) 2013 Canonical, Ltd.
38+ *
39+ * This program is free software: you can redistribute it and/or modify it under
40+ * the terms of the GNU Lesser General Public License version 3, as published by
41+ * the Free Software Foundation.
42+ *
43+ * This program is distributed in the hope that it will be useful, but WITHOUT
44+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
45+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
46+ * Lesser General Public License for more details.
47+ *
48+ * You should have received a copy of the GNU Lesser General Public License
49+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
50+ */
51+
52+// mir
53+#include <mir/graphics/display.h>
54+#include <mir/graphics/display_configuration.h>
55+#include <mir_toolkit/common.h>
56+
57+// qt
58+#include <QDBusConnection>
59+#include <QDebug>
60+
61+// local
62+#include "shellserverconfiguration.h"
63+#include "dbusscreen.h"
64+
65+namespace mc = mir::compositor;
66+namespace mg = mir::graphics;
67+
68+// Note: this class should be created only after when the Mir DisplayServer has started
69+DBusScreen::DBusScreen(ShellServerConfiguration *config, QObject *parent)
70+ : QObject(parent)
71+ , m_serverConfig(config)
72+{
73+ QDBusConnection::systemBus().registerService("com.canonical.Unity.Screen");
74+ // TODO ExportScriptableSlots shouldn't be needed but without it I don't get the methods :-/
75+ QDBusConnection::systemBus().registerObject("/com/canonical/Unity/Screen", this,
76+ QDBusConnection::ExportScriptableSlots |
77+ QDBusConnection::ExportScriptableInvokables );
78+}
79+
80+bool DBusScreen::setScreenPowerMode(const QString &mode)
81+{
82+ MirPowerMode newPowerMode;
83+ // Note: the "standby" and "suspend" modes are mostly unused
84+
85+ if (mode == "on") {
86+ newPowerMode = MirPowerMode::mir_power_mode_on;
87+ } else if (mode == "standby") {
88+ newPowerMode = MirPowerMode::mir_power_mode_standby; // higher power "off" mode (fastest resume)
89+ } else if (mode == "suspend") {
90+ newPowerMode = MirPowerMode::mir_power_mode_suspend; // medium power "off" mode
91+ } else if (mode == "off") {
92+ newPowerMode = MirPowerMode::mir_power_mode_off; // lowest power "off" mode (slowest resume)
93+ } else {
94+ qWarning() << "DBusScreen: unknown mode type" << mode;
95+ return false;
96+ }
97+
98+ std::shared_ptr<mg::Display> display = m_serverConfig->the_display();
99+ std::shared_ptr<mg::DisplayConfiguration> displayConfig = display->configuration();
100+
101+ displayConfig->for_each_output([&](const mg::DisplayConfigurationOutput displayConfigOutput) {
102+ if (displayConfigOutput.power_mode != newPowerMode) {
103+ displayConfig->configure_output(
104+ displayConfigOutput.id, //unchanged
105+ displayConfigOutput.used, //unchanged
106+ displayConfigOutput.top_left, //unchanged
107+ displayConfigOutput.current_mode_index, //unchanged
108+ newPowerMode
109+ );
110+ }
111+ });
112+
113+ display->configure(*displayConfig.get());
114+ return true;
115+}
116
117=== added file 'src/unity-mir/dbusscreen.h'
118--- src/unity-mir/dbusscreen.h 1970-01-01 00:00:00 +0000
119+++ src/unity-mir/dbusscreen.h 2013-09-25 09:43:24 +0000
120@@ -0,0 +1,39 @@
121+/*
122+ * Copyright (C) 2013 Canonical, Ltd.
123+ *
124+ * This program is free software: you can redistribute it and/or modify it under
125+ * the terms of the GNU Lesser General Public License version 3, as published by
126+ * the Free Software Foundation.
127+ *
128+ * This program is distributed in the hope that it will be useful, but WITHOUT
129+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
130+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
131+ * Lesser General Public License for more details.
132+ *
133+ * You should have received a copy of the GNU Lesser General Public License
134+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
135+ */
136+
137+#ifndef DBUSSCREEN_H
138+#define DBUSSCREEN_H
139+
140+// qt
141+#include <QObject>
142+
143+class ShellServerConfiguration;
144+
145+class DBusScreen : public QObject
146+{
147+ Q_OBJECT
148+ Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Screen")
149+
150+public:
151+ explicit DBusScreen(ShellServerConfiguration *config, QObject *parent = 0);
152+
153+ Q_INVOKABLE Q_SCRIPTABLE bool setScreenPowerMode(const QString &mode);
154+
155+private:
156+ ShellServerConfiguration *m_serverConfig;
157+};
158+
159+#endif // DBUSSCREEN_H
160
161=== modified file 'src/unity-mir/qmirserverapplication.cpp'
162--- src/unity-mir/qmirserverapplication.cpp 2013-09-09 20:27:47 +0000
163+++ src/unity-mir/qmirserverapplication.cpp 2013-09-25 09:43:24 +0000
164@@ -15,16 +15,38 @@
165 */
166
167 #include "qmirserverapplication.h"
168+#include "dbusscreen.h"
169+
170+class QMirServerApplicationPrivate {
171+public:
172+ QMirServerApplicationPrivate(ShellServerConfiguration* serverConfiguration, QMirServerApplication *qq)
173+ : q_ptr(qq)
174+ , serverConfiguration(serverConfiguration)
175+ , dbusScreen(new DBusScreen(serverConfiguration))
176+ {}
177+
178+ QMirServerApplication * const q_ptr;
179+ ShellServerConfiguration *serverConfiguration;
180+ QScopedPointer<DBusScreen> dbusScreen;
181+ Q_DECLARE_PUBLIC(QMirServerApplication)
182+};
183+
184
185 QMirServerApplication::QMirServerApplication(int &argc, char **argv, ShellServerConfiguration* serverConfiguration)
186 : QGuiApplication(argc, argv)
187- , m_serverConfiguration(serverConfiguration)
188-{
189+ , d_ptr(new QMirServerApplicationPrivate(serverConfiguration, this))
190+{
191+}
192+
193+QMirServerApplication::~QMirServerApplication()
194+{
195+ delete d_ptr;
196 }
197
198 ShellServerConfiguration* QMirServerApplication::server() const
199 {
200- return m_serverConfiguration;
201+ Q_D(const QMirServerApplication);
202+ return d->serverConfiguration;
203 }
204
205 // class factory implemenation
206@@ -41,4 +63,3 @@
207 delete mirServer;
208 }
209 }
210-
211
212=== modified file 'src/unity-mir/qmirserverapplication.h'
213--- src/unity-mir/qmirserverapplication.h 2013-09-09 20:27:47 +0000
214+++ src/unity-mir/qmirserverapplication.h 2013-09-25 09:43:24 +0000
215@@ -20,6 +20,7 @@
216 #include <QGuiApplication>
217
218 class ShellServerConfiguration;
219+class QMirServerApplicationPrivate;
220
221 class QMirServerApplication : public QGuiApplication
222 {
223@@ -27,11 +28,15 @@
224
225 public:
226 explicit QMirServerApplication(int &argc, char **argv, ShellServerConfiguration* serverConfiguration);
227+ ~QMirServerApplication();
228
229 ShellServerConfiguration* server() const;
230
231+protected:
232+ QMirServerApplicationPrivate * const d_ptr;
233+
234 private:
235- ShellServerConfiguration* m_serverConfiguration;
236+ Q_DECLARE_PRIVATE(QMirServerApplication)
237 };
238
239
240
241=== modified file 'src/unity-mir/unity-mir.pro'
242--- src/unity-mir/unity-mir.pro 2013-08-22 15:33:55 +0000
243+++ src/unity-mir/unity-mir.pro 2013-09-25 09:43:24 +0000
244@@ -1,7 +1,7 @@
245 TARGET = unity-mir
246 TEMPLATE = lib
247
248-QT += core quick
249+QT += core quick dbus
250 CONFIG += link_pkgconfig
251
252 # CONFIG += c++11 # only enables C++0x
253@@ -13,7 +13,9 @@
254
255 LIBS += -lubuntu_application_api_mirserver #FIXME platform-api pkgconfig should set this
256
257-SOURCES += initialsurfaceplacementstrategy.cpp \
258+SOURCES += \
259+ dbusscreen.cpp \
260+ initialsurfaceplacementstrategy.cpp \
261 qmirserverapplication.cpp \
262 qmirserver.cpp \
263 sessionauthorizer.cpp \
264@@ -23,7 +25,9 @@
265 surfacesource.cpp \
266 surfaceconfigurator.cpp
267
268-HEADERS += initialsurfaceplacementstrategy.h \
269+HEADERS += \
270+ dbusscreen.h \
271+ initialsurfaceplacementstrategy.h \
272 qmirserverapplication.h \
273 qmirserver.h \
274 sessionauthorizer.h \

Subscribers

People subscribed via source and target branches