Changeset View
Changeset View
Standalone View
Standalone View
ui/presentationwidget.cpp
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Line(s) | 135 | { | |||
---|---|---|---|---|---|
137 | e->accept(); | 137 | e->accept(); | ||
138 | } | 138 | } | ||
139 | }; | 139 | }; | ||
140 | 140 | | |||
141 | 141 | | |||
142 | PresentationWidget::PresentationWidget( QWidget * parent, Okular::Document * doc, DrawingToolActions * drawingToolActions, KActionCollection * collection ) | 142 | PresentationWidget::PresentationWidget( QWidget * parent, Okular::Document * doc, DrawingToolActions * drawingToolActions, KActionCollection * collection ) | ||
143 | : QWidget( nullptr /* must be null, to have an independent widget */, Qt::FramelessWindowHint ), | 143 | : QWidget( nullptr /* must be null, to have an independent widget */, Qt::FramelessWindowHint ), | ||
144 | m_pressedLink( nullptr ), m_handCursor( false ), m_drawingEngine( nullptr ), | 144 | m_pressedLink( nullptr ), m_handCursor( false ), m_drawingEngine( nullptr ), | ||
145 | m_screenInhibitCookie(0), m_sleepInhibitCookie(0), | 145 | m_screenInhibitCookie(0), m_sleepInhibitFd(-1), | ||
146 | m_parentWidget( parent ), | 146 | m_parentWidget( parent ), | ||
147 | m_document( doc ), m_frameIndex( -1 ), m_topBar( nullptr ), m_pagesEdit( nullptr ), m_searchBar( nullptr ), | 147 | m_document( doc ), m_frameIndex( -1 ), m_topBar( nullptr ), m_pagesEdit( nullptr ), m_searchBar( nullptr ), | ||
148 | m_ac( collection ), m_screenSelect( nullptr ), m_isSetup( false ), m_blockNotifications( false ), m_inBlackScreenMode( false ), | 148 | m_ac( collection ), m_screenSelect( nullptr ), m_isSetup( false ), m_blockNotifications( false ), m_inBlackScreenMode( false ), | ||
149 | m_showSummaryView( Okular::Settings::slidesShowSummary() ), | 149 | m_showSummaryView( Okular::Settings::slidesShowSummary() ), | ||
150 | m_advanceSlides( Okular::SettingsCore::slidesAdvance() ), | 150 | m_advanceSlides( Okular::SettingsCore::slidesAdvance() ), | ||
151 | m_goToNextPageOnRelease( false ) | 151 | m_goToNextPageOnRelease( false ) | ||
152 | { | 152 | { | ||
153 | Q_UNUSED( parent ) | 153 | Q_UNUSED( parent ) | ||
▲ Show 20 Lines • Show All 1576 Lines • ▼ Show 20 Line(s) | 1722 | if (!m_screenInhibitCookie) { | |||
1730 | if (reply.isValid()) { | 1730 | if (reply.isValid()) { | ||
1731 | m_screenInhibitCookie = reply.value(); | 1731 | m_screenInhibitCookie = reply.value(); | ||
1732 | qCDebug(OkularUiDebug) << "Screen inhibition cookie" << m_screenInhibitCookie; | 1732 | qCDebug(OkularUiDebug) << "Screen inhibition cookie" << m_screenInhibitCookie; | ||
1733 | } else { | 1733 | } else { | ||
1734 | qCWarning(OkularUiDebug) << "Unable to inhibit screensaver" << reply.error(); | 1734 | qCWarning(OkularUiDebug) << "Unable to inhibit screensaver" << reply.error(); | ||
1735 | } | 1735 | } | ||
1736 | } | 1736 | } | ||
1737 | 1737 | | |||
1738 | if (!m_sleepInhibitCookie) { | 1738 | if (m_sleepInhibitFd != -1) { | ||
1739 | QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.login1"), | 1739 | QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.login1"), | ||
1740 | QStringLiteral("/org/freedesktop/login1"), | 1740 | QStringLiteral("/org/freedesktop/login1"), | ||
1741 | QStringLiteral("org.freedesktop.login1.Manager"), | 1741 | QStringLiteral("org.freedesktop.login1.Manager"), | ||
1742 | QStringLiteral("Inhibit") | 1742 | QStringLiteral("Inhibit") | ||
1743 | ); | 1743 | ); | ||
1744 | message << QStringLiteral("sleep"); | 1744 | message << QStringLiteral("sleep"); | ||
1745 | message << QCoreApplication::applicationName(); | 1745 | message << QCoreApplication::applicationName(); | ||
1746 | message << reason; | 1746 | message << reason; | ||
1747 | message << QStringLiteral("block"); | 1747 | message << QStringLiteral("block"); | ||
1748 | 1748 | | |||
1749 | QDBusPendingReply<QDBusUnixFileDescriptor> reply = QDBusConnection::systemBus().asyncCall(message); | 1749 | QDBusPendingReply<QDBusUnixFileDescriptor> reply = QDBusConnection::systemBus().asyncCall(message); | ||
1750 | reply.waitForFinished(); | 1750 | reply.waitForFinished(); | ||
1751 | if (reply.isValid()) { | 1751 | if (reply.isValid()) { | ||
1752 | m_sleepInhibitCookie = reply.value().fileDescriptor(); | 1752 | m_sleepInhibitFd = dup(reply.value().fileDescriptor()); | ||
1753 | } else { | 1753 | } else { | ||
1754 | qCWarning(OkularUiDebug) << "Unable to inhibit sleep" << reply.error(); | 1754 | qCWarning(OkularUiDebug) << "Unable to inhibit sleep" << reply.error(); | ||
1755 | } | 1755 | } | ||
1756 | } | 1756 | } | ||
1757 | #endif | 1757 | #endif | ||
1758 | } | 1758 | } | ||
1759 | 1759 | | |||
1760 | void PresentationWidget::allowPowerManagement() | 1760 | void PresentationWidget::allowPowerManagement() | ||
1761 | { | 1761 | { | ||
1762 | #ifdef Q_OS_LINUX | 1762 | #ifdef Q_OS_LINUX | ||
1763 | if (m_sleepInhibitCookie) { | 1763 | if (m_sleepInhibitFd != -1) { | ||
1764 | ::close(m_sleepInhibitCookie); | 1764 | ::close(m_sleepInhibitFd); | ||
1765 | m_sleepInhibitCookie = 0; | 1765 | m_sleepInhibitFd = -1; | ||
anthonyfieroni: It should be != -1 | |||||
tobiasdeiminger: You're right, thanks | |||||
1766 | } | 1766 | } | ||
1767 | 1767 | | |||
1768 | if (m_screenInhibitCookie) { | 1768 | if (m_screenInhibitCookie) { | ||
1769 | QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.ScreenSaver", "/ScreenSaver", | 1769 | QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.ScreenSaver", "/ScreenSaver", | ||
1770 | "org.freedesktop.ScreenSaver", "UnInhibit"); | 1770 | "org.freedesktop.ScreenSaver", "UnInhibit"); | ||
1771 | message << m_screenInhibitCookie; | 1771 | message << m_screenInhibitCookie; | ||
1772 | 1772 | | |||
1773 | QDBusPendingReply<uint> reply = QDBusConnection::sessionBus().asyncCall(message); | 1773 | QDBusPendingReply<uint> reply = QDBusConnection::sessionBus().asyncCall(message); | ||
▲ Show 20 Lines • Show All 684 Lines • Show Last 20 Lines |
It should be != -1