Merge pull request #6278 from symless/v1.9-macsleep
@mrsixw #5964 Can't click on client after sleep
This commit is contained in:
commit
b46714957f
|
@ -19,3 +19,6 @@ src/gui/gui.pro.user*
|
|||
src/gui/.qmake.stash
|
||||
src/gui/.rnd
|
||||
src/setup/win32/synergy.suo
|
||||
/.idea
|
||||
/cmake-build-debug
|
||||
/CMakeLists.txt.user
|
||||
|
|
|
@ -109,8 +109,8 @@ protected:
|
|||
virtual IKeyState* getKeyState() const;
|
||||
|
||||
private:
|
||||
void updateScreenShape();
|
||||
void updateScreenShape(const CGDirectDisplayID, const CGDisplayChangeSummaryFlags);
|
||||
bool updateScreenShape();
|
||||
bool updateScreenShape(const CGDirectDisplayID, const CGDisplayChangeSummaryFlags);
|
||||
void postMouseEvent(CGPoint&) const;
|
||||
|
||||
// convenience function to send events
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "base/IEventQueue.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "synergy/DisplayInvalidException.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <mach-o/dyld.h>
|
||||
|
@ -105,9 +106,12 @@ OSXScreen::OSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCurso
|
|||
m_getDropTargetThread(NULL),
|
||||
m_impl(NULL)
|
||||
{
|
||||
m_displayID = CGMainDisplayID();
|
||||
if (!updateScreenShape(m_displayID, 0)) {
|
||||
throw DisplayInvalidException ("failed to initialize screen shape");
|
||||
}
|
||||
|
||||
try {
|
||||
m_displayID = CGMainDisplayID();
|
||||
updateScreenShape(m_displayID, 0);
|
||||
m_screensaver = new OSXScreenSaver(m_events, getEventTarget());
|
||||
m_keyState = new OSXKeyState(m_events);
|
||||
|
||||
|
@ -1212,9 +1216,10 @@ OSXScreen::displayReconfigurationCallback(CGDirectDisplayID displayID, CGDisplay
|
|||
LOG((CLOG_DEBUG1 "event: display was reconfigured: %x %x %x", flags, mask, flags & mask));
|
||||
|
||||
if (flags & mask) { /* Something actually did change */
|
||||
|
||||
LOG((CLOG_DEBUG1 "event: screen changed shape; refreshing dimensions"));
|
||||
screen->updateScreenShape(displayID, flags);
|
||||
if (!screen->updateScreenShape(displayID, flags)) {
|
||||
LOG((CLOG_ERR "failed to update screen shape during display reconfiguration"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1518,35 +1523,34 @@ OSXScreen::getKeyState() const
|
|||
return m_keyState;
|
||||
}
|
||||
|
||||
void
|
||||
OSXScreen::updateScreenShape(const CGDirectDisplayID, const CGDisplayChangeSummaryFlags flags)
|
||||
bool OSXScreen::updateScreenShape(const CGDirectDisplayID, const CGDisplayChangeSummaryFlags flags)
|
||||
{
|
||||
updateScreenShape();
|
||||
return updateScreenShape();
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
OSXScreen::updateScreenShape()
|
||||
{
|
||||
// get info for each display
|
||||
CGDisplayCount displayCount = 0;
|
||||
|
||||
if (CGGetActiveDisplayList(0, NULL, &displayCount) != CGDisplayNoErr) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (displayCount == 0) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
CGDirectDisplayID* displays = new CGDirectDisplayID[displayCount];
|
||||
if (displays == NULL) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (CGGetActiveDisplayList(displayCount,
|
||||
displays, &displayCount) != CGDisplayNoErr) {
|
||||
delete[] displays;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// get smallest rect enclosing all display rects
|
||||
|
@ -1575,6 +1579,8 @@ OSXScreen::updateScreenShape()
|
|||
LOG((CLOG_DEBUG "screen shape: center=%d,%d size=%dx%d on %u %s",
|
||||
m_x, m_y, m_w, m_h, displayCount,
|
||||
(displayCount == 1) ? "display" : "displays"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "ipc/IpcMessage.h"
|
||||
#include "ipc/Ipc.h"
|
||||
#include "base/EventQueue.h"
|
||||
#include "DisplayInvalidException.h"
|
||||
|
||||
#if SYSAPI_WIN32
|
||||
#include "arch/win32/ArchMiscWindows.h"
|
||||
|
@ -50,6 +51,7 @@
|
|||
#include "platform/OSXDragSimulator.h"
|
||||
#endif
|
||||
|
||||
|
||||
App* App::s_instance = nullptr;
|
||||
|
||||
//
|
||||
|
@ -125,6 +127,15 @@ App::run(int argc, char** argv)
|
|||
// using the exit(int) function!
|
||||
result = e.getCode();
|
||||
}
|
||||
catch (DisplayInvalidException& die) {
|
||||
LOG((CLOG_CRIT "A display invalid exception error occurred: %s\n", die.what()));
|
||||
// display invalid exceptions can occur when going to sleep. When this process exits, the
|
||||
// UI will restart us instantly. We don't really want that behevior, so we quies for a bit
|
||||
ARCH->sleep(10);
|
||||
}
|
||||
catch (std::runtime_error& re) {
|
||||
LOG((CLOG_CRIT "A runtime error occurred: %s\n", re.what()));
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
LOG((CLOG_CRIT "An error occurred: %s\n", e.what()));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2018 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 SYNERGY_DISPLAYINVALIDEXCEPTION_H
|
||||
#define SYNERGY_DISPLAYINVALIDEXCEPTION_H
|
||||
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
class DisplayInvalidException : public std::runtime_error {
|
||||
public:
|
||||
DisplayInvalidException(const char* msg):
|
||||
std::runtime_error(msg)
|
||||
{
|
||||
}
|
||||
|
||||
DisplayInvalidException(std::string msg):
|
||||
std::runtime_error(msg)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif //SYNERGY_DISPLAYINVALIDEXCEPTION_H
|
Loading…
Reference in New Issue