Merge pull request #7060 from symless/SYNERGY-1088-Clients-ignore-prevent-sleeping-option
Synergy 1088 clients ignore prevent sleeping option
This commit is contained in:
commit
e0bd2d1baa
13 changed files with 299 additions and 72 deletions
|
|
@ -14,7 +14,7 @@ Bug fixes:
|
||||||
- #7057 | #7058 Fix copy paste logic, when OS reported about clipboard update too late
|
- #7057 | #7058 Fix copy paste logic, when OS reported about clipboard update too late
|
||||||
- #7055 Add secure input notification on Linux
|
- #7055 Add secure input notification on Linux
|
||||||
- #7052 Add secure input notification on Windows
|
- #7052 Add secure input notification on Windows
|
||||||
- #7047 Fix prevent sleep option on Mac and Windows
|
- #7047 | #7060 Fix prevent sleep option on Mac and Windows
|
||||||
|
|
||||||
Enhancements:
|
Enhancements:
|
||||||
- #6998 Remove functionality related to the screen saver synchronisation
|
- #6998 Remove functionality related to the screen saver synchronisation
|
||||||
|
|
|
||||||
37
src/lib/platform/MSWindowsPowerManager.cpp
Normal file
37
src/lib/platform/MSWindowsPowerManager.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2012-2021 Symless Ltd.
|
||||||
|
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
||||||
|
*
|
||||||
|
* This package is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* found in the file LICENSE that should have accompanied this file.
|
||||||
|
*
|
||||||
|
* This package 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "MSWindowsPowerManager.h"
|
||||||
|
#include "arch/win32/ArchMiscWindows.h"
|
||||||
|
|
||||||
|
MSWindowsPowerManager::~MSWindowsPowerManager()
|
||||||
|
{
|
||||||
|
enableSleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MSWindowsPowerManager::disableSleep()
|
||||||
|
{
|
||||||
|
ArchMiscWindows::addBusyState(ArchMiscWindows::kSYSTEM);
|
||||||
|
ArchMiscWindows::addBusyState(ArchMiscWindows::kDISPLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MSWindowsPowerManager::enableSleep()
|
||||||
|
{
|
||||||
|
// allow the system to enter power saving mode
|
||||||
|
ArchMiscWindows::removeBusyState(ArchMiscWindows::kSYSTEM);
|
||||||
|
ArchMiscWindows::removeBusyState(ArchMiscWindows::kDISPLAY);
|
||||||
|
}
|
||||||
38
src/lib/platform/MSWindowsPowerManager.h
Normal file
38
src/lib/platform/MSWindowsPowerManager.h
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2012-2021 Symless Ltd.
|
||||||
|
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
||||||
|
*
|
||||||
|
* This package is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* found in the file LICENSE that should have accompanied this file.
|
||||||
|
*
|
||||||
|
* This package 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef MSWINDOWSPOWERMANAGER_H
|
||||||
|
#define MSWINDOWSPOWERMANAGER_H
|
||||||
|
|
||||||
|
|
||||||
|
class MSWindowsPowerManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
~MSWindowsPowerManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prevents the system from sleep automatically
|
||||||
|
*/
|
||||||
|
void disableSleep();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable automatically sleeping
|
||||||
|
*/
|
||||||
|
void enableSleep();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MSWINDOWSPOWERMANAGER_H
|
||||||
|
|
@ -164,6 +164,10 @@ MSWindowsScreen::MSWindowsScreen(
|
||||||
LOG((CLOG_ERR "failed to get desktop path, no drop target available, error=%d", GetLastError()));
|
LOG((CLOG_ERR "failed to get desktop path, no drop target available, error=%d", GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (App::instance().argsBase().m_preventSleep) {
|
||||||
|
m_powerManager.disableSleep();
|
||||||
|
}
|
||||||
|
|
||||||
OleInitialize(0);
|
OleInitialize(0);
|
||||||
m_dropWindow = createDropWindow(m_class, "DropWindow");
|
m_dropWindow = createDropWindow(m_class, "DropWindow");
|
||||||
m_dropTarget = new MSWindowsDropTarget();
|
m_dropTarget = new MSWindowsDropTarget();
|
||||||
|
|
@ -248,11 +252,6 @@ MSWindowsScreen::enable()
|
||||||
// watch jump zones
|
// watch jump zones
|
||||||
m_hook.setMode(kHOOK_WATCH_JUMP_ZONE);
|
m_hook.setMode(kHOOK_WATCH_JUMP_ZONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (App::instance().argsBase().m_preventSleep) {
|
|
||||||
ArchMiscWindows::addBusyState(ArchMiscWindows::kSYSTEM);
|
|
||||||
ArchMiscWindows::addBusyState(ArchMiscWindows::kDISPLAY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -268,11 +267,6 @@ MSWindowsScreen::disable()
|
||||||
// enable special key sequences on win95 family
|
// enable special key sequences on win95 family
|
||||||
enableSpecialKeys(true);
|
enableSpecialKeys(true);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// allow the system to enter power saving mode
|
|
||||||
ArchMiscWindows::removeBusyState(ArchMiscWindows::kSYSTEM);
|
|
||||||
ArchMiscWindows::removeBusyState(ArchMiscWindows::kDISPLAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
// tell key state
|
// tell key state
|
||||||
m_keyState->disable();
|
m_keyState->disable();
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "platform/MSWindowsHook.h"
|
#include "platform/MSWindowsHook.h"
|
||||||
|
#include "platform/MSWindowsPowerManager.h"
|
||||||
#include "synergy/PlatformScreen.h"
|
#include "synergy/PlatformScreen.h"
|
||||||
#include "synergy/DragInformation.h"
|
#include "synergy/DragInformation.h"
|
||||||
#include "platform/synwinhk.h"
|
#include "platform/synwinhk.h"
|
||||||
|
|
@ -374,4 +375,5 @@ private:
|
||||||
// -1 for natural scrolling direction, 1 otherwise
|
// -1 for natural scrolling direction, 1 otherwise
|
||||||
SInt32 m_scrollDirectionMouse = 1;
|
SInt32 m_scrollDirectionMouse = 1;
|
||||||
SInt32 m_scrollDirectionTouchpad = 1;
|
SInt32 m_scrollDirectionTouchpad = 1;
|
||||||
|
MSWindowsPowerManager m_powerManager;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
50
src/lib/platform/OSXPowerManager.cpp
Normal file
50
src/lib/platform/OSXPowerManager.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2012-2021 Symless Ltd.
|
||||||
|
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
||||||
|
*
|
||||||
|
* This package is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* found in the file LICENSE that should have accompanied this file.
|
||||||
|
*
|
||||||
|
* This package 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "OSXPowerManager.h"
|
||||||
|
#include "base/Log.h"
|
||||||
|
|
||||||
|
OSXPowerManager::OSXPowerManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
OSXPowerManager::~OSXPowerManager()
|
||||||
|
{
|
||||||
|
enableSleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OSXPowerManager::disableSleep()
|
||||||
|
{
|
||||||
|
if (!m_sleepPreventionAssertionID) {
|
||||||
|
CFStringRef reasonForActivity = CFSTR("Synergy application");
|
||||||
|
IOReturn result = IOPMAssertionCreateWithName(kIOPMAssertPreventUserIdleDisplaySleep,
|
||||||
|
kIOPMAssertionLevelOn, reasonForActivity,
|
||||||
|
&m_sleepPreventionAssertionID);
|
||||||
|
if (result != kIOReturnSuccess) {
|
||||||
|
m_sleepPreventionAssertionID = 0;
|
||||||
|
LOG((CLOG_ERR "failed to disable system idle sleep"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OSXPowerManager::enableSleep()
|
||||||
|
{
|
||||||
|
if (m_sleepPreventionAssertionID) {
|
||||||
|
IOPMAssertionRelease(m_sleepPreventionAssertionID);
|
||||||
|
}
|
||||||
|
}
|
||||||
48
src/lib/platform/OSXPowerManager.h
Normal file
48
src/lib/platform/OSXPowerManager.h
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2012-2021 Symless Ltd.
|
||||||
|
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
||||||
|
*
|
||||||
|
* This package is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* found in the file LICENSE that should have accompanied this file.
|
||||||
|
*
|
||||||
|
* This package 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OSXPOWERMANAGER_H
|
||||||
|
#define OSXPOWERMANAGER_H
|
||||||
|
|
||||||
|
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||||
|
|
||||||
|
class OSXPowerManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OSXPowerManager();
|
||||||
|
~OSXPowerManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prevents the system from sleep automatically
|
||||||
|
*/
|
||||||
|
void disableSleep();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable automatically sleeping
|
||||||
|
*/
|
||||||
|
void enableSleep();
|
||||||
|
|
||||||
|
OSXPowerManager(const OSXPowerManager&) = delete;
|
||||||
|
OSXPowerManager& operator=(const OSXPowerManager&) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// handler for assertion preventing the system from going to sleep
|
||||||
|
IOPMAssertionID m_sleepPreventionAssertionID = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OSXPOWERMANAGER_H
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "platform/OSXClipboard.h"
|
#include "platform/OSXClipboard.h"
|
||||||
|
#include "platform/OSXPowerManager.h"
|
||||||
#include "synergy/PlatformScreen.h"
|
#include "synergy/PlatformScreen.h"
|
||||||
#include "synergy/DragInformation.h"
|
#include "synergy/DragInformation.h"
|
||||||
#include "base/EventTypes.h"
|
#include "base/EventTypes.h"
|
||||||
|
|
@ -30,7 +31,6 @@
|
||||||
#include <mach/mach_port.h>
|
#include <mach/mach_port.h>
|
||||||
#include <mach/mach_interface.h>
|
#include <mach/mach_interface.h>
|
||||||
#include <mach/mach_init.h>
|
#include <mach/mach_init.h>
|
||||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
|
||||||
#include <IOKit/IOMessage.h>
|
#include <IOKit/IOMessage.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
@ -347,8 +347,7 @@ private:
|
||||||
CondVar<bool>* m_carbonLoopReady;
|
CondVar<bool>* m_carbonLoopReady;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// handler for assertion preventing the system from going to sleep
|
OSXPowerManager m_powerManager;
|
||||||
IOPMAssertionID m_sleepPreventionAssertionID = 0;
|
|
||||||
|
|
||||||
class OSXScreenImpl* m_impl;
|
class OSXScreenImpl* m_impl;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,10 @@ OSXScreen::OSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCurso
|
||||||
m_screensaver = new OSXScreenSaver(m_events, getEventTarget());
|
m_screensaver = new OSXScreenSaver(m_events, getEventTarget());
|
||||||
m_keyState = new OSXKeyState(m_events);
|
m_keyState = new OSXKeyState(m_events);
|
||||||
|
|
||||||
|
if (App::instance().argsBase().m_preventSleep) {
|
||||||
|
m_powerManager.disableSleep();
|
||||||
|
}
|
||||||
|
|
||||||
// only needed when running as a server.
|
// only needed when running as a server.
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
|
|
||||||
|
|
@ -195,6 +199,7 @@ OSXScreen::OSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCurso
|
||||||
OSXScreen::~OSXScreen()
|
OSXScreen::~OSXScreen()
|
||||||
{
|
{
|
||||||
disable();
|
disable();
|
||||||
|
|
||||||
m_events->adoptBuffer(NULL);
|
m_events->adoptBuffer(NULL);
|
||||||
m_events->removeHandler(Event::kSystem, m_events->getSystemTarget());
|
m_events->removeHandler(Event::kSystem, m_events->getSystemTarget());
|
||||||
|
|
||||||
|
|
@ -754,18 +759,6 @@ OSXScreen::hideCursor()
|
||||||
void
|
void
|
||||||
OSXScreen::enable()
|
OSXScreen::enable()
|
||||||
{
|
{
|
||||||
if(App::instance().argsBase().m_preventSleep) {
|
|
||||||
CFStringRef reasonForActivity = CFSTR("Synergy application");
|
|
||||||
|
|
||||||
IOReturn result = IOPMAssertionCreateWithName(kIOPMAssertPreventUserIdleDisplaySleep,
|
|
||||||
kIOPMAssertionLevelOn, reasonForActivity,
|
|
||||||
&m_sleepPreventionAssertionID);
|
|
||||||
if(result != kIOReturnSuccess) {
|
|
||||||
m_sleepPreventionAssertionID = 0;
|
|
||||||
LOG((CLOG_ERR "failed to disable system idle sleep"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// watch the clipboard
|
// watch the clipboard
|
||||||
m_clipboardTimer = m_events->newTimer(1.0, NULL);
|
m_clipboardTimer = m_events->newTimer(1.0, NULL);
|
||||||
m_events->adoptHandler(Event::kTimer, m_clipboardTimer,
|
m_events->adoptHandler(Event::kTimer, m_clipboardTimer,
|
||||||
|
|
@ -815,10 +808,6 @@ OSXScreen::enable()
|
||||||
void
|
void
|
||||||
OSXScreen::disable()
|
OSXScreen::disable()
|
||||||
{
|
{
|
||||||
if(App::instance().argsBase().m_preventSleep && m_sleepPreventionAssertionID) {
|
|
||||||
IOPMAssertionRelease(m_sleepPreventionAssertionID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_autoShowHideCursor) {
|
if (m_autoShowHideCursor) {
|
||||||
showCursor();
|
showCursor();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
60
src/lib/platform/XWindowsPowerManager.cpp
Normal file
60
src/lib/platform/XWindowsPowerManager.cpp
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2012-2016 Symless Ltd.
|
||||||
|
* Copyright (C) 2002 Chris Schoeneman
|
||||||
|
*
|
||||||
|
* This package is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* found in the file LICENSE that should have accompanied this file.
|
||||||
|
*
|
||||||
|
* This package 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "XWindowsPowerManager.h"
|
||||||
|
#include "arch/Arch.h"
|
||||||
|
#include "base/Log.h"
|
||||||
|
|
||||||
|
namespace{
|
||||||
|
|
||||||
|
bool sleepInhibitCall(bool state, ArchSystemUnix::InhibitScreenServices serviceID)
|
||||||
|
{
|
||||||
|
std::string error;
|
||||||
|
|
||||||
|
if (!ArchSystemUnix::DBusInhibitScreenCall(serviceID, state, error))
|
||||||
|
{
|
||||||
|
LOG((CLOG_DEBUG "DBus inhibit error %s", error.c_str()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
XWindowsPowerManager::~XWindowsPowerManager()
|
||||||
|
{
|
||||||
|
enableSleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
void XWindowsPowerManager::disableSleep() const
|
||||||
|
{
|
||||||
|
if (!sleepInhibitCall(true, ArchSystemUnix::InhibitScreenServices::kScreenSaver) &&
|
||||||
|
!sleepInhibitCall(true, ArchSystemUnix::InhibitScreenServices::kSessionManager))
|
||||||
|
{
|
||||||
|
LOG((CLOG_INFO "Failed to prevent system from going to sleep"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void XWindowsPowerManager::enableSleep() const
|
||||||
|
{
|
||||||
|
if (!sleepInhibitCall(false, ArchSystemUnix::InhibitScreenServices::kScreenSaver) &&
|
||||||
|
!sleepInhibitCall(false, ArchSystemUnix::InhibitScreenServices::kSessionManager))
|
||||||
|
{
|
||||||
|
LOG((CLOG_INFO "Failed to enable system idle sleep"));
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/lib/platform/XWindowsPowerManager.h
Normal file
42
src/lib/platform/XWindowsPowerManager.h
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2012-2016 Symless Ltd.
|
||||||
|
* Copyright (C) 2002 Chris Schoeneman
|
||||||
|
*
|
||||||
|
* This package is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* found in the file LICENSE that should have accompanied this file.
|
||||||
|
*
|
||||||
|
* This package 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef XWINDOWSPOWERMANAGER_H
|
||||||
|
#define XWINDOWSPOWERMANAGER_H
|
||||||
|
|
||||||
|
|
||||||
|
class XWindowsPowerManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
XWindowsPowerManager() = default;
|
||||||
|
~XWindowsPowerManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prevent the system from sleep
|
||||||
|
*/
|
||||||
|
void disableSleep() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables automatical sleep
|
||||||
|
*/
|
||||||
|
void enableSleep() const;
|
||||||
|
|
||||||
|
XWindowsPowerManager(const XWindowsPowerManager&) = delete;
|
||||||
|
XWindowsPowerManager& operator=(const XWindowsPowerManager&) = delete;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // XWINDOWSPOWERMANAGER_H
|
||||||
|
|
@ -182,6 +182,11 @@ XWindowsScreen::XWindowsScreen(
|
||||||
XTestGrabControl(m_display, True);
|
XTestGrabControl(m_display, True);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// disable sleep if the flag is set
|
||||||
|
if (App::instance().argsBase().m_preventSleep) {
|
||||||
|
m_powerManager.disableSleep();
|
||||||
|
}
|
||||||
|
|
||||||
// initialize the clipboards
|
// initialize the clipboards
|
||||||
for (ClipboardID id = 0; id < kClipboardEnd; ++id) {
|
for (ClipboardID id = 0; id < kClipboardEnd; ++id) {
|
||||||
m_clipboard[id] = new XWindowsClipboard(m_display, m_window, id);
|
m_clipboard[id] = new XWindowsClipboard(m_display, m_window, id);
|
||||||
|
|
@ -247,12 +252,6 @@ XWindowsScreen::enable()
|
||||||
// warp the mouse to the cursor center
|
// warp the mouse to the cursor center
|
||||||
fakeMouseMove(m_xCenter, m_yCenter);
|
fakeMouseMove(m_xCenter, m_yCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable sleep if the flag is set
|
|
||||||
if (App::instance().argsBase().m_preventSleep &&
|
|
||||||
!disableIdleSleep()) {
|
|
||||||
LOG((CLOG_INFO "Failed to prevent system from going to sleep"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -271,12 +270,6 @@ XWindowsScreen::disable()
|
||||||
if (!m_isPrimary && m_autoRepeat) {
|
if (!m_isPrimary && m_autoRepeat) {
|
||||||
//XAutoRepeatOn(m_display);
|
//XAutoRepeatOn(m_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable sleep when the display is disabled
|
|
||||||
if (App::instance().argsBase().m_preventSleep &&
|
|
||||||
!enableIdleSleep()) {
|
|
||||||
LOG((CLOG_INFO "Failed to enable system idle sleep"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -2201,25 +2194,3 @@ XWindowsScreen::updateScrollDirection()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XWindowsScreen::sleepInhibitCall(bool state, ArchSystemUnix::InhibitScreenServices serviceID)
|
|
||||||
{
|
|
||||||
std::string error;
|
|
||||||
if(!ArchSystemUnix::DBusInhibitScreenCall(serviceID, state, error))
|
|
||||||
{
|
|
||||||
LOG((CLOG_DEBUG "DBus inhibit error %s", error.c_str()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XWindowsScreen::disableIdleSleep()
|
|
||||||
{
|
|
||||||
return sleepInhibitCall(true, ArchSystemUnix::InhibitScreenServices::kScreenSaver) ||
|
|
||||||
sleepInhibitCall(true, ArchSystemUnix::InhibitScreenServices::kSessionManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XWindowsScreen::enableIdleSleep()
|
|
||||||
{
|
|
||||||
return sleepInhibitCall(false, ArchSystemUnix::InhibitScreenServices::kScreenSaver) ||
|
|
||||||
sleepInhibitCall(false, ArchSystemUnix::InhibitScreenServices::kSessionManager);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include "synergy/KeyMap.h"
|
#include "synergy/KeyMap.h"
|
||||||
#include "common/stdset.h"
|
#include "common/stdset.h"
|
||||||
#include "common/stdvector.h"
|
#include "common/stdvector.h"
|
||||||
|
#include "platform/XWindowsPowerManager.h"
|
||||||
|
|
||||||
#if X_DISPLAY_MISSING
|
#if X_DISPLAY_MISSING
|
||||||
# error X11 is required to build synergy
|
# error X11 is required to build synergy
|
||||||
|
|
@ -118,11 +119,6 @@ private:
|
||||||
void onError();
|
void onError();
|
||||||
static int ioErrorHandler(Display*);
|
static int ioErrorHandler(Display*);
|
||||||
|
|
||||||
// sleep management
|
|
||||||
static bool sleepInhibitCall(bool state, ArchSystemUnix::InhibitScreenServices serviceID);
|
|
||||||
static bool disableIdleSleep();
|
|
||||||
static bool enableIdleSleep();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class KeyEventFilter {
|
class KeyEventFilter {
|
||||||
public:
|
public:
|
||||||
|
|
@ -263,4 +259,5 @@ private:
|
||||||
// -1 for natural scrolling direction, 1 otherwise
|
// -1 for natural scrolling direction, 1 otherwise
|
||||||
SInt32 m_scrollDirectionMouse = 1;
|
SInt32 m_scrollDirectionMouse = 1;
|
||||||
SInt32 m_scrollDirectionTouchpad = 1;
|
SInt32 m_scrollDirectionTouchpad = 1;
|
||||||
|
XWindowsPowerManager m_powerManager;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue