mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 02:12:50 +00:00
kdeui: drop KNotificationRestrictions class
most of the functionality is not implemented, the rest can be done via Solid::PowerManagement::beginSuppressingScreenPowerManagement() and Solid::PowerManagement::stopSuppressingScreenPowerManagement() Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
6f0e672758
commit
3ce3fcf34b
9 changed files with 0 additions and 311 deletions
|
@ -156,13 +156,11 @@ if(NOT X11_XSync_FOUND AND NOT X11_Xscreensaver_FOUND)
|
|||
endif()
|
||||
|
||||
# optional features
|
||||
kde4_bool_to_01(X11_XTest_FOUND HAVE_XTEST)
|
||||
kde4_bool_to_01(X11_Xcursor_FOUND HAVE_XCURSOR)
|
||||
kde4_bool_to_01(X11_Xfixes_FOUND HAVE_XFIXES)
|
||||
kde4_bool_to_01(X11_Xscreensaver_FOUND HAVE_XSCREENSAVER)
|
||||
kde4_bool_to_01(X11_XSync_FOUND HAVE_XSYNC)
|
||||
|
||||
add_feature_info("X Test Extension (libXTest)" HAVE_XTEST "Support for notfication restriction")
|
||||
add_feature_info("X Cursor Extension (Xcursor)" HAVE_XCURSOR "Support for loading cursors depending on theme")
|
||||
add_feature_info("X Fixes Extension (libXfixes)" HAVE_XFIXES "Support for damage/fixes cursor and window management")
|
||||
add_feature_info("X Screensaver Extension (libXss)" HAVE_XSCREENSAVER "Support for KIdleTime (fallback mode)")
|
||||
|
|
|
@ -33,7 +33,6 @@ check_include_files("sys/param.h;sys/mount.h" HAVE_SYS_MOUNT_H) # kio, kd
|
|||
check_include_files(paths.h HAVE_PATHS_H) # kdecore
|
||||
|
||||
# TODO: separate to config-x11.h
|
||||
kde4_bool_to_01(X11_XTest_FOUND HAVE_XTEST) # kdecore
|
||||
kde4_bool_to_01(X11_Xcursor_FOUND HAVE_XCURSOR) # kdeui
|
||||
kde4_bool_to_01(X11_Xfixes_FOUND HAVE_XFIXES) # kdeui
|
||||
kde4_bool_to_01(X11_Xscreensaver_FOUND HAVE_XSCREENSAVER) # kidletime
|
||||
|
|
|
@ -22,9 +22,6 @@
|
|||
#cmakedefine HAVE_SETMNTENT 1
|
||||
#cmakedefine HAVE_STRMODE 1
|
||||
|
||||
/* Define to 1 if you have the Xtest extension */
|
||||
#cmakedefine HAVE_XTEST 1
|
||||
|
||||
/* Define to 1 if you have the Xcursor library */
|
||||
#cmakedefine HAVE_XCURSOR 1
|
||||
|
||||
|
|
|
@ -187,7 +187,6 @@ install(
|
|||
KNewFileMenu
|
||||
KNewPasswordDialog
|
||||
KNotification
|
||||
KNotificationRestrictions
|
||||
KNotificationConfigWidget
|
||||
KNumInput
|
||||
KOpenWithDialog
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include "../knotificationrestrictions.h"
|
|
@ -27,7 +27,6 @@
|
|||
264 kdeui (KIconLoader)
|
||||
265 kdeui (KIconEffect)
|
||||
283 kdeui (K*Gesture*)
|
||||
297 kdeui (KNotificationRestrictions)
|
||||
299 kdeui (KNotification)
|
||||
300 kdeui (KConfigDialogManager)
|
||||
700 kutils (KSettings::Dialog)
|
||||
|
|
|
@ -152,7 +152,6 @@ set(kdeui_LIB_SRCS
|
|||
kernel/ktoolinvocation_x11.cpp
|
||||
notifications/knotification.cpp
|
||||
notifications/knotificationconfigwidget.cpp
|
||||
notifications/knotificationrestrictions.cpp
|
||||
paged/kpagedialog.cpp
|
||||
paged/kpageview.cpp
|
||||
paged/kpageview_p.cpp
|
||||
|
@ -286,7 +285,6 @@ set_source_files_properties(
|
|||
${CMAKE_SOURCE_DIR}/kdeui/kernel/kuniqueapplication.cpp
|
||||
${CMAKE_SOURCE_DIR}/kdeui/kernel/ktoolinvocation.cpp
|
||||
${CMAKE_SOURCE_DIR}/kdeui/kernel/ktoolinvocation_x11.cpp
|
||||
${CMAKE_SOURCE_DIR}/kdeui/notifications/knotificationrestrictions.cpp
|
||||
${CMAKE_SOURCE_DIR}/kdeui/util/kcrash.cpp
|
||||
${CMAKE_SOURCE_DIR}/kdeui/util/kcursor.cpp
|
||||
${CMAKE_SOURCE_DIR}/kdeui/util/kkeyserver_x11.cpp
|
||||
|
@ -315,10 +313,6 @@ target_link_libraries(kdeui PUBLIC
|
|||
kdecore
|
||||
)
|
||||
|
||||
if(X11_XTest_FOUND)
|
||||
target_link_libraries(kdeui PRIVATE ${X11_XTest_LIB})
|
||||
endif()
|
||||
|
||||
if(X11_Xcursor_FOUND)
|
||||
target_link_libraries(kdeui PRIVATE ${X11_Xcursor_LIB})
|
||||
endif()
|
||||
|
@ -444,7 +438,6 @@ install(
|
|||
kernel/ktoolinvocation.h
|
||||
notifications/knotification.h
|
||||
notifications/knotificationconfigwidget.h
|
||||
notifications/knotificationrestrictions.h
|
||||
paged/kpagedialog.h
|
||||
paged/kpageview.h
|
||||
paged/kpagewidget.h
|
||||
|
|
|
@ -1,185 +0,0 @@
|
|||
/* This file is part of the KDE libraries
|
||||
Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "knotificationrestrictions.h"
|
||||
|
||||
#include <kaboutdata.h>
|
||||
#include <kcomponentdata.h>
|
||||
#include <kdebug.h>
|
||||
#include <kglobal.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusReply>
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef HAVE_XTEST
|
||||
#include <QTimer>
|
||||
#include <QtGui/qx11info_x11.h>
|
||||
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/extensions/XTest.h>
|
||||
#endif // HAVE_XTEST
|
||||
|
||||
class KNotificationRestrictions::Private
|
||||
{
|
||||
public:
|
||||
Private( KNotificationRestrictions* qq, Services c )
|
||||
: q( qq ),
|
||||
control(c)
|
||||
, screenSaverDbusCookie(-1)
|
||||
#ifdef HAVE_XTEST
|
||||
,screensaverTimer(0),
|
||||
haveXTest(0),
|
||||
XTestKeyCode(0)
|
||||
#endif // HAVE_XTEST
|
||||
{
|
||||
}
|
||||
|
||||
void screensaverFakeKeyEvent();
|
||||
void startScreenSaverPrevention();
|
||||
void stopScreenSaverPrevention();
|
||||
|
||||
static QString determineProgramName();
|
||||
|
||||
KNotificationRestrictions* q;
|
||||
Services control;
|
||||
int screenSaverDbusCookie;
|
||||
QString reason;
|
||||
#ifdef HAVE_XTEST
|
||||
QTimer* screensaverTimer;
|
||||
int haveXTest;
|
||||
int XTestKeyCode;
|
||||
#endif // HAVE_XTEST
|
||||
};
|
||||
|
||||
KNotificationRestrictions::KNotificationRestrictions( Services control,
|
||||
QObject* parent )
|
||||
: QObject(parent),
|
||||
d( new Private( this, control ) )
|
||||
{
|
||||
if (d->control & ScreenSaver) {
|
||||
d->startScreenSaverPrevention();
|
||||
}
|
||||
}
|
||||
|
||||
KNotificationRestrictions::~KNotificationRestrictions()
|
||||
{
|
||||
if (d->control & ScreenSaver) {
|
||||
d->stopScreenSaverPrevention();
|
||||
}
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
void KNotificationRestrictions::Private::screensaverFakeKeyEvent()
|
||||
{
|
||||
kDebug(297);
|
||||
#ifdef HAVE_XTEST
|
||||
kDebug(297) << "---- using XTestFakeKeyEvent";
|
||||
Display* display = QX11Info::display();
|
||||
XTestFakeKeyEvent(display, XTestKeyCode, true, CurrentTime);
|
||||
XTestFakeKeyEvent(display, XTestKeyCode, false, CurrentTime);
|
||||
XSync(display, false);
|
||||
#endif // HAVE_XTEST
|
||||
}
|
||||
|
||||
void KNotificationRestrictions::Private::startScreenSaverPrevention()
|
||||
{
|
||||
kDebug(297);
|
||||
|
||||
QDBusMessage message = QDBusMessage::createMethodCall(
|
||||
"org.freedesktop.ScreenSaver", "/ScreenSaver", "org.freedesktop.ScreenSaver", "Inhibit");
|
||||
message << determineProgramName();
|
||||
message << reason;
|
||||
QDBusReply<uint> reply = QDBusConnection::sessionBus().call(message);
|
||||
if (reply.isValid()) {
|
||||
screenSaverDbusCookie = reply.value();
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_XTEST
|
||||
if ( !haveXTest ) {
|
||||
int a,b,c,e;
|
||||
haveXTest = XTestQueryExtension(QX11Info::display(), &a, &b, &c, &e);
|
||||
|
||||
if ( !haveXTest ) {
|
||||
kDebug(297) << "--- No XTEST!";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !XTestKeyCode ) {
|
||||
XTestKeyCode = XKeysymToKeycode(QX11Info::display(), XK_Shift_L);
|
||||
|
||||
if ( !XTestKeyCode ) {
|
||||
kDebug(297) << "--- No XKeyCode for XK_Shift_L!";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !screensaverTimer ) {
|
||||
screensaverTimer = new QTimer( q );
|
||||
connect( screensaverTimer, SIGNAL(timeout()),
|
||||
q, SLOT(screensaverFakeKeyEvent()) );
|
||||
}
|
||||
|
||||
kDebug(297) << "---- using XTest";
|
||||
// send a fake event right away in case this got started after a period of
|
||||
// innactivity leading to the screensaver set to activate in <55s
|
||||
screensaverFakeKeyEvent();
|
||||
screensaverTimer->start( 55000 );
|
||||
#endif // HAVE_XTEST
|
||||
}
|
||||
|
||||
void KNotificationRestrictions::Private::stopScreenSaverPrevention()
|
||||
{
|
||||
|
||||
if (screenSaverDbusCookie != -1) {
|
||||
QDBusMessage message = QDBusMessage::createMethodCall(
|
||||
"org.freedesktop.ScreenSaver", "/ScreenSaver", "org.freedesktop.ScreenSaver", "UnInhibit");
|
||||
message << static_cast<uint>(screenSaverDbusCookie);
|
||||
screenSaverDbusCookie = -1;
|
||||
if (QDBusConnection::sessionBus().send(message)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_XTEST
|
||||
delete screensaverTimer;
|
||||
screensaverTimer = 0;
|
||||
#endif // HAVE_XTEST
|
||||
}
|
||||
|
||||
QString KNotificationRestrictions::Private::determineProgramName()
|
||||
{
|
||||
QString appName;
|
||||
if (KGlobal::mainComponent().isValid()) {
|
||||
appName = KGlobal::mainComponent().aboutData()->programName();
|
||||
}
|
||||
if (appName.isEmpty() && qApp) {
|
||||
appName = QCoreApplication::applicationName();
|
||||
}
|
||||
if (appName.isEmpty()) {
|
||||
appName = i18n("Unknown Application");
|
||||
}
|
||||
return appName;
|
||||
}
|
||||
|
||||
#include "moc_knotificationrestrictions.cpp"
|
|
@ -1,110 +0,0 @@
|
|||
/* This file is part of the KDE libraries
|
||||
Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KDELIBS_KNOTIFICATIONRESTRICTIONS_H
|
||||
#define KDELIBS_KNOTIFICATIONRESTRICTIONS_H
|
||||
|
||||
#include <kdeui_export.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
/**
|
||||
* KNotificationRestrictions provides a simple mechanism to avoid disruptions
|
||||
* during full screen presentations or other use cases where the screensaver or
|
||||
* desktop notifcations are inappropriate.
|
||||
*
|
||||
* Using KNotificationRestrictions is quite straightforward: create an instance
|
||||
* of KNotificationRestrictions, passing in the set of or'd flags representing
|
||||
* the services that should be prevented from interrupting the user. When done
|
||||
* (for instance when the presentation is complete) simply delete the
|
||||
* KNotificationRestrictions object.
|
||||
*
|
||||
* Example: to ensure the screensaver does not turn on during a presentation:
|
||||
* @code
|
||||
* void MyApp::doPresentation()
|
||||
* {
|
||||
* KNotificationRestrictions restrict(KNotificationRestrictions::ScreenSaver);
|
||||
* // show presentation
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
class KDEUI_EXPORT KNotificationRestrictions : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* @enum Service
|
||||
*/
|
||||
enum Service
|
||||
{
|
||||
/**
|
||||
* The baseline "don't disable anything" value.
|
||||
*/
|
||||
NoServices = 0,
|
||||
/**
|
||||
* Causes the screensaver to be prevented from automatically
|
||||
* turning on.
|
||||
*/
|
||||
ScreenSaver = 1,
|
||||
/**
|
||||
* Causes instant messaging and email notifications to not appear.
|
||||
*
|
||||
* @note <b>not implemented yet</b>
|
||||
*/
|
||||
MessagingPopups = 2,
|
||||
/**
|
||||
* Causes non-critical desktop messages to be suppressed.
|
||||
*
|
||||
* @note <b>not implemented yet</b>
|
||||
*/
|
||||
Notifications = 4,
|
||||
/**
|
||||
* Causes all desktop notifications, including critical ones
|
||||
* (such as as "battery low" warnings) to be suppressed.
|
||||
*
|
||||
* @note <b>not implemented yet</b>
|
||||
*/
|
||||
CriticalNotifications = 8,
|
||||
NonCriticalServices = ScreenSaver |
|
||||
MessagingPopups |
|
||||
Notifications,
|
||||
AllServices = NonCriticalServices | CriticalNotifications
|
||||
};
|
||||
Q_DECLARE_FLAGS(Services, Service)
|
||||
|
||||
/**
|
||||
* Constructs a new service for restrict some services.
|
||||
*
|
||||
* @param control the services to be restricted
|
||||
* @param parent the parent of this object
|
||||
*/
|
||||
explicit KNotificationRestrictions(Services control = NonCriticalServices,
|
||||
QObject* parent = 0);
|
||||
virtual ~KNotificationRestrictions();
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private * const d;
|
||||
|
||||
Q_PRIVATE_SLOT( d, void screensaverFakeKeyEvent() )
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(KNotificationRestrictions::Services)
|
||||
#endif
|
Loading…
Add table
Reference in a new issue