summaryrefslogtreecommitdiffstats
path: root/src/systeminfo/linux/qscreensaver_linux.cpp
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@jollamobile.com>2013-05-09 07:51:50 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-09 07:43:28 +0200
commite70d49413c9e01cfad27156c6264e627cec2a919 (patch)
tree58cba2a6aee49361ad172b7fced449531d461c64 /src/systeminfo/linux/qscreensaver_linux.cpp
parent701442ad6358b9f27978aafae82074124468f88c (diff)
refactor the dir structure
putting system specific files into their own directories makes it look nicer and easier to work on. Change-Id: I485640a93d8fda8d60f6e92b34834f877f19f5b6 Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
Diffstat (limited to 'src/systeminfo/linux/qscreensaver_linux.cpp')
-rw-r--r--src/systeminfo/linux/qscreensaver_linux.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/systeminfo/linux/qscreensaver_linux.cpp b/src/systeminfo/linux/qscreensaver_linux.cpp
new file mode 100644
index 00000000..bd3b1fd3
--- /dev/null
+++ b/src/systeminfo/linux/qscreensaver_linux.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtSystems module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qscreensaver_linux_p.h"
+
+#if !defined(QT_NO_X11)
+#include <X11/Xlib.h>
+#endif // QT_NO_X11
+
+QT_BEGIN_NAMESPACE
+
+QScreenSaverPrivate::QScreenSaverPrivate(QScreenSaver *parent)
+ : q_ptr(parent)
+{
+}
+
+bool QScreenSaverPrivate::screenSaverEnabled()
+{
+#if !defined(QT_NO_X11)
+ int timeout = 0;
+ int interval = 0;
+ int preferBlanking = 0;
+ int allowExposures = 0;
+ Display *display = XOpenDisplay(0);
+ XGetScreenSaver(display, &timeout, &interval, &preferBlanking, &allowExposures);
+ XCloseDisplay(display);
+ return (timeout > 0);
+#else
+ return false;
+#endif
+}
+
+void QScreenSaverPrivate::setScreenSaverEnabled(bool enabled)
+{
+#if !defined(QT_NO_X11)
+ int timeout = 0;
+ int interval = 0;
+ int preferBlanking = 0;
+ int allowExposures = 0;
+ Display *display = XOpenDisplay(0);
+ XGetScreenSaver(display, &timeout, &interval, &preferBlanking, &allowExposures);
+
+ if (enabled && timeout > 0)
+ XSetScreenSaver(display, -1, interval, preferBlanking, allowExposures);
+ else if (!enabled && timeout != 0)
+ XSetScreenSaver(display, 0, interval, preferBlanking, allowExposures);
+
+ XCloseDisplay(display);
+#else
+ Q_UNUSED(enabled)
+#endif
+}
+
+QT_END_NAMESPACE