Compare commits

..

11 Commits

Author SHA1 Message Date
Andrew Nelless
b70b8e0fc4 Merge pull request #6276 from symless/issue6267-linux-switch
#6267 Stop detecting mouse movement for local input
2018-03-19 11:25:17 +00:00
Andrew Nelless
47137952f4 Revert "#4288 Remove auto Alt+Printscreen on Windows"
This reverts commit 3d3b7ca881.
2018-03-15 11:27:26 +00:00
Andrew Nelless
cd403562cd Merge pull request #6268 from erikd/topic/fixes
Minor fixes reported by AddressSanitizer
2018-03-14 13:36:29 +00:00
Andrew Nelless
2204828746 Make macOS screen shape detection code more robust 2018-03-14 13:35:42 +00:00
Erik de Castro Lopo
d2f6e56e53 Fix a memory leak 2018-03-12 10:41:31 +11:00
Erik de Castro Lopo
a0616a54be Update .gitignore
Ignore generated cmake files and directories.
2018-03-12 10:41:31 +11:00
Erik de Castro Lopo
d2a331c376 Fix compile error 2018-03-12 10:41:31 +11:00
Erik de Castro Lopo
cbd742ebb5 Fix -Wreorder warnings 2018-03-11 14:00:08 +11:00
Danielle Church
ffb0a5e1ed Initialize XWindowsScreen to offscreen for secondary displays (#6249)
XWindowsScreen::m_isOnScreen currently initializes to true for all
screens, meaning that every screen assumes it currently has control of
the shared mouse pointer when it starts up. For the primary (server)
screen, this is appropriate; when synergy starts, the local mouse should
still move the cursor on the local screen.

However, for secondary screens, this is incorrect; when the client
connects, it does _not_ have control of the shared mouse pointer, as the
server's mouse still moves the server's cursor.

This doesn't make much difference in most cases, as the secondary screen
behaves almost identically whether m_isOnScreen is true or false;
however, the local input detection code will only fire if the variable
is false, meaning that once the client connects, it first has to gain
the cursor and then lose it before it will detect local input.

Since the Synergy 2.0 service relies on synergy-core's local input
detection to determine when to switch to server mode, this means that a
Linux desktop can only ever claim primary if the shared cursor has at
some point moved to that screen, then left it.

This fixes the bug so that local input on a Linux desktop can reclaim
the primary role immediately after losing it.

Fixes #6248.
2018-03-09 15:27:56 +00:00
Jerry (Xinyu Hou)
ec3e0b2f71 #6267 Stop detecting mouse movement for local input 2018-03-08 16:40:23 +00:00
Jerry (Xinyu Hou)
ea5be67b27 #6266 Tweek log level for debugging display reconfiguration on Mac 2018-03-08 16:35:03 +00:00
9 changed files with 42 additions and 29 deletions

4
.gitignore vendored
View File

@@ -2,6 +2,7 @@ config.h
.DS_Store
*.pyc
*.o
*.a
*~
\.*.swp
*build-gui-Desktop_Qt*
@@ -20,3 +21,6 @@ src/gui/.rnd
src/setup/win32/synergy.suo
CMakeCache.txt
CMakeLists.txt.user
Makefile
cmake_install.cmake
CMakeFiles/

View File

@@ -150,6 +150,7 @@ ArchMultithreadPosix::~ArchMultithreadPosix()
closeMutex(m_threadMutex);
s_instance = nullptr;
delete m_mainThread;
}
void

View File

@@ -175,7 +175,7 @@ App::initApp(int argc, const char** argv)
// this is a simple way to allow the core process to talk to X. this avoids
// the "WARNING: primary screen unavailable: unable to open screen" error.
// a better way would be to use xauth cookie and dbus to get access to X.
if (static_cast<int>((!(argsBase().m_runAsUid) == 0 != -1))) {
if (argsBase().m_runAsUid >= 0) {
if (setuid(argsBase().m_runAsUid) == 0) {
LOG((CLOG_DEBUG "process uid was set to: %d", argsBase().m_runAsUid));
}

View File

@@ -27,10 +27,6 @@ m_stopOnDeskSwitch(false),
#else
m_daemon(true), // backward compatibility for unix (daemon by default)
#endif
#if WINAPI_XWINDOWS
m_disableXInitThreads(false),
m_runAsUid(-1),
#endif
m_backend(false),
m_restartable(true),
m_noHooks(false),
@@ -39,6 +35,10 @@ m_logFilter(nullptr),
m_logFile(nullptr),
m_display(nullptr),
m_enableDragDrop(false),
#if WINAPI_XWINDOWS
m_disableXInitThreads(false),
m_runAsUid(-1),
#endif
m_shouldExit(false),
m_profileDirectory(""),
m_pluginDirectory("")

View File

@@ -1075,6 +1075,11 @@ MSWindowsKeyState::getKeyMap(synergy::KeyMap& keyMap)
}
}
// add alt+printscreen
if (m_buttonToVK[0x54u] == 0) {
m_buttonToVK[0x54u] = VK_SNAPSHOT;
}
// set virtual key to button table
if (activeLayout == m_groups[g]) {
for (KeyButton i = 0; i < 512; ++i) {

View File

@@ -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

View File

@@ -108,9 +108,12 @@ OSXScreen::OSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCurso
m_getDropTargetThread(NULL),
m_impl(NULL)
{
m_displayID = CGMainDisplayID();
if (!updateScreenShape(m_displayID, 0)) {
throw std::runtime_error ("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);
@@ -1175,12 +1178,13 @@ OSXScreen::displayReconfigurationCallback(CGDirectDisplayID displayID, CGDisplay
kCGDisplayMirrorFlag | kCGDisplayUnMirrorFlag |
kCGDisplayDesktopShapeChangedFlag;
LOG((CLOG_DEBUG1 "event: display was reconfigured: %x %x %x", flags, mask, flags & mask));
LOG((CLOG_DEBUG "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"));
}
}
}
@@ -1484,35 +1488,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
@@ -1541,6 +1544,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 -

View File

@@ -54,10 +54,10 @@ class EventQueueTimer { };
XWindowsEventQueueBuffer::XWindowsEventQueueBuffer(
Display* display, Window window, IEventQueue* events) :
m_events(events),
m_display(display),
m_window(window),
m_waiting(false)
m_waiting(false),
m_events(events)
{
assert(m_display != NULL);
assert(m_window != None);

View File

@@ -97,12 +97,13 @@ XWindowsScreen::XWindowsScreen(
bool disableXInitThreads,
int mouseScrollDelta,
IEventQueue* events) :
PlatformScreen(events),
m_isPrimary(isPrimary),
m_mouseScrollDelta(mouseScrollDelta),
m_display(nullptr),
m_root(None),
m_window(None),
m_isOnScreen(true),
m_isOnScreen(isPrimary),
m_x(0), m_y(0),
m_w(0), m_h(0),
m_xCenter(0), m_yCenter(0),
@@ -121,8 +122,7 @@ XWindowsScreen::XWindowsScreen(
m_xkb(false),
m_xi2detected(false),
m_xrandr(false),
m_events(events),
PlatformScreen(events)
m_events(events)
{
assert(s_screen == NULL);
@@ -1391,8 +1391,6 @@ XWindowsScreen::handleSystemEvent(const Event& event, void* /*unused*/)
case MotionNotify:
if (m_isPrimary) {
onMouseMove(xevent->xmotion);
} else if (!m_isOnScreen && (xevent->xmotion.send_event == False)) {
LOG ((CLOG_INFO "local input detected"));
}
return;
@@ -1415,8 +1413,8 @@ XWindowsScreen::handleSystemEvent(const Event& event, void* /*unused*/)
#if HAVE_X11_EXTENSIONS_XRANDR_H
if (m_xrandr) {
if (xevent->type == m_xrandrEventBase + RRScreenChangeNotify
|| xevent->type == m_xrandrEventBase + RRNotify
if ((xevent->type == m_xrandrEventBase + RRScreenChangeNotify
|| xevent->type == m_xrandrEventBase + RRNotify)
&& reinterpret_cast<XRRNotifyEvent *>(xevent)->subtype == RRNotify_CrtcChange) {
LOG((CLOG_INFO "XRRScreenChangeNotifyEvent or RRNotify_CrtcChange received"));