diff --git a/CMakeLists.txt b/CMakeLists.txt index da840940..0f317163 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)") diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 5bcea148..225c8093 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -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 diff --git a/config.h.cmake b/config.h.cmake index 683aa8b4..ba450bb6 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -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 diff --git a/includes/CMakeLists.txt b/includes/CMakeLists.txt index 8bad2b1e..0ad18f25 100644 --- a/includes/CMakeLists.txt +++ b/includes/CMakeLists.txt @@ -187,7 +187,6 @@ install( KNewFileMenu KNewPasswordDialog KNotification - KNotificationRestrictions KNotificationConfigWidget KNumInput KOpenWithDialog diff --git a/includes/KNotificationRestrictions b/includes/KNotificationRestrictions deleted file mode 100644 index 0d88db47..00000000 --- a/includes/KNotificationRestrictions +++ /dev/null @@ -1 +0,0 @@ -#include "../knotificationrestrictions.h" diff --git a/kdecore/kdebug.areas b/kdecore/kdebug.areas index 5f9c72ed..4609df7b 100644 --- a/kdecore/kdebug.areas +++ b/kdecore/kdebug.areas @@ -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) diff --git a/kdeui/CMakeLists.txt b/kdeui/CMakeLists.txt index 0547fac4..c9930477 100644 --- a/kdeui/CMakeLists.txt +++ b/kdeui/CMakeLists.txt @@ -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 diff --git a/kdeui/notifications/knotificationrestrictions.cpp b/kdeui/notifications/knotificationrestrictions.cpp deleted file mode 100644 index ec3c8efb..00000000 --- a/kdeui/notifications/knotificationrestrictions.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2006 Aaron Seigo - - 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 -#include -#include -#include -#include - -#include -#include -#include - -#include - -#ifdef HAVE_XTEST -#include -#include - -#include -#include -#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 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(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" diff --git a/kdeui/notifications/knotificationrestrictions.h b/kdeui/notifications/knotificationrestrictions.h deleted file mode 100644 index 7b83d25c..00000000 --- a/kdeui/notifications/knotificationrestrictions.h +++ /dev/null @@ -1,110 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2006 Aaron Seigo - - 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 - -#include - -/** - * 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 not implemented yet - */ - MessagingPopups = 2, - /** - * Causes non-critical desktop messages to be suppressed. - * - * @note not implemented yet - */ - Notifications = 4, - /** - * Causes all desktop notifications, including critical ones - * (such as as "battery low" warnings) to be suppressed. - * - * @note not implemented yet - */ - 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