~ubuntu-branches/ubuntu/wily/qtsystems-opensource-src/wily

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Description: Allow apps to keep the screen on
Forwarded: not-needed
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1462489
Author: Michael Zanetti <michael.zanetti@canonical.com>

=== modified file 'src/systeminfo/linux/qscreensaver_linux.cpp'
--- a/src/systeminfo/linux/qscreensaver_linux.cpp	2013-06-14 10:32:13 +0000
+++ b/src/systeminfo/linux/qscreensaver_linux.cpp	2015-07-06 08:37:04 +0000
@@ -41,6 +41,12 @@
 
 #include "qscreensaver_linux_p.h"
 
+#ifdef UBUNTU_UNITY
+#include <QDBusConnection>
+#include <QDBusInterface>
+#include <QDBusPendingCall>
+#endif
+
 #if !defined(QT_NO_X11)
 #include <X11/Xlib.h>
 #endif // QT_NO_X11
@@ -49,12 +55,20 @@
 
 QScreenSaverPrivate::QScreenSaverPrivate(QScreenSaver *parent)
     : q_ptr(parent)
-{
+#ifdef UBUNTU_UNITY
+    , m_keepDisplayOnRequest(-1)
+{
+    m_iface = new QDBusInterface("com.canonical.Unity.Screen", "/com/canonical/Unity/Screen", "com.canonical.Unity.Screen", QDBusConnection::systemBus());
+#else
+{
+#endif
 }
 
 bool QScreenSaverPrivate::screenSaverEnabled()
 {
-#if !defined(QT_NO_X11)
+#ifdef UBUNTU_UNITY
+    return m_keepDisplayOnRequest == -1;
+#elif !defined(QT_NO_X11)
     int timeout = 0;
     int interval = 0;
     int preferBlanking = 0;
@@ -70,7 +84,19 @@
 
 void QScreenSaverPrivate::setScreenSaverEnabled(bool enabled)
 {
-#if !defined(QT_NO_X11)
+#ifdef UBUNTU_UNITY
+    if (m_keepDisplayOnRequest == -1 && !enabled) {
+        // set request
+        QDBusMessage reply = m_iface->call("keepDisplayOn");
+        if (reply.arguments().count() > 0) {
+            m_keepDisplayOnRequest = reply.arguments().first().toInt();
+        }
+    } else if (m_keepDisplayOnRequest != -1 && enabled) {
+        // clear request
+        m_iface->asyncCall("removeDisplayOnRequest", m_keepDisplayOnRequest);
+        m_keepDisplayOnRequest = -1;
+    }
+#elif !defined(QT_NO_X11)
     int timeout = 0;
     int interval = 0;
     int preferBlanking = 0;

=== modified file 'src/systeminfo/linux/qscreensaver_linux_p.h'
--- a/src/systeminfo/linux/qscreensaver_linux_p.h	2013-06-14 10:32:13 +0000
+++ b/src/systeminfo/linux/qscreensaver_linux_p.h	2015-07-03 11:14:26 +0000
@@ -57,6 +57,10 @@
 
 QT_BEGIN_NAMESPACE
 
+#if defined(UBUNTU_UNITY)
+class QDBusInterface;
+#endif
+
 class QScreenSaverPrivate
 {
 public:
@@ -68,6 +72,11 @@
 private:
     QScreenSaver * const q_ptr;
     Q_DECLARE_PUBLIC(QScreenSaver)
+
+#if defined(UBUNTU_UNITY)
+    int m_keepDisplayOnRequest;
+    QDBusInterface *m_iface;
+#endif
 };
 
 QT_END_NAMESPACE

=== modified file 'src/systeminfo/systeminfo.pro'
--- a/src/systeminfo/systeminfo.pro	2015-02-13 06:45:19 +0000
+++ b/src/systeminfo/systeminfo.pro	2015-07-03 11:15:49 +0000
@@ -64,6 +64,8 @@
                linux/qnetworkinfo_linux.cpp \
                linux/qscreensaver_linux.cpp
 
+    DEFINES += UBUNTU_UNITY
+
     x11|config_x11: !contains(CONFIG,nox11option) {
         CONFIG += link_pkgconfig
         PKGCONFIG += x11