Fixed problem with multimonitor on OS X. The bug was simply that

the cursor wasn't being parked in the center of the main screen
but instead at the center of the total display surface.  This could
place it off or dangerously close to the edge of the transparent
window that covers the main screen and prevent synergy from capturing
mouse motion.
This commit is contained in:
crs 2004-10-27 21:22:36 +00:00
parent 7c7b41d751
commit fe044cfab1
1 changed files with 14 additions and 10 deletions

View File

@ -52,7 +52,7 @@ COSXScreen::COSXScreen(bool isPrimary) :
Rect bounds = { 100, 100, 101, 101 }; Rect bounds = { 100, 100, 101, 101 };
// m_hiddenWindow is a window meant to let us get mouse moves // m_hiddenWindow is a window meant to let us get mouse moves
// when the focus is on this computer. If you get your event // when the focus is on another computer. If you get your event
// from the application event target you'll get every mouse // from the application event target you'll get every mouse
// moves. On the other hand the Window event target will only // moves. On the other hand the Window event target will only
// get events when the mouse moves over the window. // get events when the mouse moves over the window.
@ -428,7 +428,6 @@ COSXScreen::leave()
updateKeys(); updateKeys();
// warp to center // warp to center
// FIXME -- this should be the center of the main monitor
warpCursor(m_xCenter, m_yCenter); warpCursor(m_xCenter, m_yCenter);
// capture events // capture events
@ -940,16 +939,14 @@ COSXScreen::updateScreenShape()
return; return;
} }
CGDirectDisplayID* displays = CGDirectDisplayID* displays = new CGDirectDisplayID[displayCount];
(CGDirectDisplayID*)malloc(displayCount * sizeof(CGDirectDisplayID));
if (displays == NULL) { if (displays == NULL) {
return; return;
} }
if (CGGetActiveDisplayList(displayCount, if (CGGetActiveDisplayList(displayCount,
displays, &displayCount) != CGDisplayNoErr) { displays, &displayCount) != CGDisplayNoErr) {
free(displays); delete[] displays;
return; return;
} }
@ -967,11 +964,18 @@ COSXScreen::updateScreenShape()
m_h = (SInt32)totalBounds.size.height; m_h = (SInt32)totalBounds.size.height;
// get center of default screen // get center of default screen
// XXX -- this should compute the center of displays[0] GDHandle mainScreen = GetMainDevice();
m_xCenter = m_x + (m_w >> 1); if (mainScreen != NULL) {
m_yCenter = m_y + (m_h >> 1); const Rect& rect = (*mainScreen)->gdRect;
m_xCenter = (rect.left + rect.right) / 2;
m_yCenter = (rect.top + rect.bottom) / 2;
}
else {
m_xCenter = m_x + (m_w >> 1);
m_yCenter = m_y + (m_h >> 1);
}
free(displays); delete[] displays;
LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d on %u %s", m_x, m_y, m_w, m_h, displayCount, (displayCount == 1) ? "display" : "displays")); LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d on %u %s", m_x, m_y, m_w, m_h, displayCount, (displayCount == 1) ? "display" : "displays"));
} }