Commit 1a31dffc authored by Dario Freddi's avatar Dario Freddi
Browse files

Make Okular inhibit sleep and screen power management when in Presentation mode

REVIEW:103713
parent 2c912219
......@@ -189,7 +189,7 @@ qt4_add_dbus_interfaces(okularpart_SRCS ${KDE4_DBUS_INTERFACES_DIR}/org.kde.KSpe
kde4_add_plugin(okularpart ${okularpart_SRCS})
target_link_libraries(okularpart okularcore ${KDE4_KPARTS_LIBS} ${KDE4_KPRINTUTILS_LIBS} ${MATH_LIB} ${QIMAGEBLITZ_LIBRARIES} ${KDE4_PHONON_LIBRARY})
target_link_libraries(okularpart okularcore ${KDE4_KPARTS_LIBS} ${KDE4_KPRINTUTILS_LIBS} ${MATH_LIB} ${QIMAGEBLITZ_LIBRARIES} ${KDE4_PHONON_LIBRARY} ${KDE4_SOLID_LIBRARY})
install(TARGETS okularpart DESTINATION ${PLUGIN_INSTALL_DIR})
......
......@@ -41,6 +41,8 @@
#include <kshortcut.h>
#include <kdialog.h>
#include <Solid/PowerManagement>
// system includes
#include <stdlib.h>
#include <math.h>
......@@ -1391,14 +1393,19 @@ void PresentationWidget::applyNewScreenSize( const QSize & oldSize )
void PresentationWidget::inhibitScreenSaver()
{
QString reason = i18nc( "Reason for inhibiting the screensaver activation, when the presentation mode is active", "Giving a presentation" );
QDBusMessage message = QDBusMessage::createMethodCall( "org.freedesktop.ScreenSaver", "/ScreenSaver",
"org.freedesktop.ScreenSaver", "Inhibit" );
message << QString( "Okular" );
message << i18nc( "Reason for inhibiting the screensaver activation, when the presentation mode is active", "Giving a presentation" );
message << reason;
QDBusReply<uint> reply = QDBusConnection::sessionBus().call( message );
if ( reply.isValid() )
m_screenSaverCookie = reply.value();
// Inhibit screen and sleep
m_screenInhibitCookie = Solid::PowerManagement::beginSuppressingScreenPowerManagement(reason);
m_sleepInhibitCookie = Solid::PowerManagement::beginSuppressingSleep(reason);
}
void PresentationWidget::allowScreenSaver()
......@@ -1410,6 +1417,10 @@ void PresentationWidget::allowScreenSaver()
message << (uint)m_screenSaverCookie;
QDBusConnection::sessionBus().send( message );
}
// Remove cookies
Solid::PowerManagement::stopSuppressingScreenPowerManagement(m_screenInhibitCookie);
Solid::PowerManagement::stopSuppressingSleep(m_sleepInhibitCookie);
}
void PresentationWidget::showTopBar( bool show )
......
......@@ -105,6 +105,8 @@ class PresentationWidget : public QWidget, public Okular::DocumentObserver
QRect m_drawingRect;
int m_screen;
int m_screenSaverCookie;
int m_screenInhibitCookie;
int m_sleepInhibitCookie;
// transition related
QTimer * m_transitionTimer;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment