SYNERGY-1088 Windows client ignores prevent sleeping option
This commit is contained in:
parent
8dd68abf56
commit
1dfafb03dc
4 changed files with 82 additions and 11 deletions
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;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue