fixed wrong code style around cursor show/hide, made secondary input event handling look more readable, cut down on cursor shown/hidden state usage (to make sure the cursor is shown and hidden when needed), added check after show/hide to make sure that it actually happened
This commit is contained in:
parent
0502e3b3d6
commit
240c5a781d
|
@ -643,22 +643,51 @@ COSXScreen::fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const
|
||||||
void
|
void
|
||||||
COSXScreen::showCursor()
|
COSXScreen::showCursor()
|
||||||
{
|
{
|
||||||
LOG((CLOG_DEBUG "showing cursor"));
|
LOG((CLOG_DEBUG "showing cursor, display=%d", m_displayID));
|
||||||
|
|
||||||
CGDisplayShowCursor(m_displayID);
|
CGDisplayShowCursor(m_displayID);
|
||||||
CFStringRef propertyString = CFStringCreateWithCString(NULL, "SetsCursorInBackground", kCFStringEncodingMacRoman);
|
CFStringRef propertyString = CFStringCreateWithCString(NULL, "SetsCursorInBackground", kCFStringEncodingMacRoman);
|
||||||
CGSSetConnectionProperty(_CGSDefaultConnection(), _CGSDefaultConnection(), propertyString, kCFBooleanFalse);
|
CGSSetConnectionProperty(_CGSDefaultConnection(), _CGSDefaultConnection(), propertyString, kCFBooleanFalse);
|
||||||
CFRelease(propertyString);
|
CFRelease(propertyString);
|
||||||
|
|
||||||
|
// interestingly, CGDisplayShowCursor was removed in favor of only using
|
||||||
|
// the above. this could have caused the intermittent issue:
|
||||||
|
//
|
||||||
|
// Bug #2855 - Mouse cursor remains hidden on Mac client.
|
||||||
|
//
|
||||||
|
// ... seems like it might be a good idea to add it back in (it's hard
|
||||||
|
// to prove for or against since the bug is so random).
|
||||||
|
CGError error = CGDisplayShowCursor(m_displayID);
|
||||||
|
if (error != kCGErrorSuccess) {
|
||||||
|
LOG((CLOG_ERR "failed to show cursor, error=%d", error));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CGCursorIsVisible()) {
|
||||||
|
LOG((CLOG_ERR "cursor was not shown"));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_cursorHidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
COSXScreen::hideCursor()
|
COSXScreen::hideCursor()
|
||||||
{
|
{
|
||||||
|
LOG((CLOG_DEBUG "hiding cursor, display=%d", m_displayID));
|
||||||
|
|
||||||
CFStringRef propertyString = CFStringCreateWithCString(NULL, "SetsCursorInBackground", kCFStringEncodingMacRoman);
|
CFStringRef propertyString = CFStringCreateWithCString(NULL, "SetsCursorInBackground", kCFStringEncodingMacRoman);
|
||||||
CGSSetConnectionProperty(_CGSDefaultConnection(), _CGSDefaultConnection(), propertyString, kCFBooleanTrue);
|
CGSSetConnectionProperty(_CGSDefaultConnection(), _CGSDefaultConnection(), propertyString, kCFBooleanTrue);
|
||||||
CFRelease(propertyString);
|
CFRelease(propertyString);
|
||||||
|
|
||||||
LOG((CLOG_DEBUG "hiding cursor"));
|
CGError error = CGDisplayHideCursor(m_displayID);
|
||||||
CGDisplayHideCursor(m_displayID);
|
if (error != kCGErrorSuccess) {
|
||||||
|
LOG((CLOG_ERR "failed to hide cursor, error=%d", error));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CGCursorIsVisible()) {
|
||||||
|
LOG((CLOG_ERR "cursor was not hidden"));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_cursorHidden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -682,11 +711,7 @@ COSXScreen::enable()
|
||||||
else {
|
else {
|
||||||
// FIXME -- prevent system from entering power save mode
|
// FIXME -- prevent system from entering power save mode
|
||||||
|
|
||||||
// hide cursor
|
|
||||||
if (!m_cursorHidden) {
|
|
||||||
hideCursor();
|
hideCursor();
|
||||||
m_cursorHidden = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// warp the mouse to the cursor center
|
// warp the mouse to the cursor center
|
||||||
fakeMouseMove(m_xCenter, m_yCenter);
|
fakeMouseMove(m_xCenter, m_yCenter);
|
||||||
|
@ -712,11 +737,7 @@ COSXScreen::enable()
|
||||||
void
|
void
|
||||||
COSXScreen::disable()
|
COSXScreen::disable()
|
||||||
{
|
{
|
||||||
// show cursor if hidden
|
|
||||||
if (m_cursorHidden) {
|
|
||||||
showCursor();
|
showCursor();
|
||||||
m_cursorHidden = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME -- stop watching jump zones, stop capturing input
|
// FIXME -- stop watching jump zones, stop capturing input
|
||||||
|
|
||||||
|
@ -747,11 +768,8 @@ COSXScreen::disable()
|
||||||
void
|
void
|
||||||
COSXScreen::enter()
|
COSXScreen::enter()
|
||||||
{
|
{
|
||||||
// show cursor
|
|
||||||
if (m_cursorHidden) {
|
|
||||||
showCursor();
|
showCursor();
|
||||||
m_cursorHidden = false;
|
|
||||||
}
|
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
CGSetLocalEventsSuppressionInterval(0.0);
|
CGSetLocalEventsSuppressionInterval(0.0);
|
||||||
|
|
||||||
|
@ -780,11 +798,7 @@ COSXScreen::enter()
|
||||||
bool
|
bool
|
||||||
COSXScreen::leave()
|
COSXScreen::leave()
|
||||||
{
|
{
|
||||||
// hide cursor
|
|
||||||
if (!m_cursorHidden) {
|
|
||||||
hideCursor();
|
hideCursor();
|
||||||
m_cursorHidden = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
// warp to center
|
// warp to center
|
||||||
|
@ -1760,28 +1774,25 @@ COSXScreen::CHotKeyItem::operator<(const CHotKeyItem& x) const
|
||||||
(m_keycode == x.m_keycode && m_mask < x.m_mask));
|
(m_keycode == x.m_keycode && m_mask < x.m_mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quartz event tap support for the secondary display. This make sure that we
|
// Quartz event tap support for the secondary display. This makes sure that we
|
||||||
// will show the cursor if a local event comes in while synergy has the cursor off the screen.
|
// will show the cursor if a local event comes in while synergy has the cursor
|
||||||
|
// off the screen.
|
||||||
CGEventRef
|
CGEventRef
|
||||||
COSXScreen::handleCGInputEventSecondary(CGEventTapProxy proxy,
|
COSXScreen::handleCGInputEventSecondary(
|
||||||
|
CGEventTapProxy proxy,
|
||||||
CGEventType type,
|
CGEventType type,
|
||||||
CGEventRef event,
|
CGEventRef event,
|
||||||
void* refcon)
|
void* refcon)
|
||||||
{
|
{
|
||||||
COSXScreen* screen = (COSXScreen*)refcon;
|
COSXScreen* screen = (COSXScreen*)refcon;
|
||||||
if (screen->m_cursorHidden) {
|
if (screen->m_cursorHidden && type == kCGEventMouseMoved) {
|
||||||
CGPoint pos;
|
|
||||||
bool showCursor = true;
|
CGPoint pos = CGEventGetLocation(event);
|
||||||
if (type == kCGEventMouseMoved) {
|
if (pos.x != screen->m_xCenter || pos.y != screen->m_yCenter) {
|
||||||
pos = CGEventGetLocation(event);
|
|
||||||
if (pos.x == screen->m_xCenter && pos.y == screen->m_yCenter) {
|
LOG((CLOG_DEBUG "show cursor on secondary, type=%d pos=%d,%d",
|
||||||
showCursor = false;
|
type, pos.x, pos.y));
|
||||||
}
|
|
||||||
}
|
|
||||||
if (showCursor) {
|
|
||||||
LOG((CLOG_DEBUG "show cursor, event type %d", type));
|
|
||||||
screen->showCursor();
|
screen->showCursor();
|
||||||
screen->m_cursorHidden = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return event;
|
return event;
|
||||||
|
|
Loading…
Reference in New Issue