From fe044cfab1c02b5d0b17059a7d341132e5538186 Mon Sep 17 00:00:00 2001 From: crs Date: Wed, 27 Oct 2004 21:22:36 +0000 Subject: [PATCH] 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. --- lib/platform/COSXScreen.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/platform/COSXScreen.cpp b/lib/platform/COSXScreen.cpp index cb6cd223..e9f2bda4 100644 --- a/lib/platform/COSXScreen.cpp +++ b/lib/platform/COSXScreen.cpp @@ -52,7 +52,7 @@ COSXScreen::COSXScreen(bool isPrimary) : Rect bounds = { 100, 100, 101, 101 }; // 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 // moves. On the other hand the Window event target will only // get events when the mouse moves over the window. @@ -428,7 +428,6 @@ COSXScreen::leave() updateKeys(); // warp to center - // FIXME -- this should be the center of the main monitor warpCursor(m_xCenter, m_yCenter); // capture events @@ -940,16 +939,14 @@ COSXScreen::updateScreenShape() return; } - CGDirectDisplayID* displays = - (CGDirectDisplayID*)malloc(displayCount * sizeof(CGDirectDisplayID)); - + CGDirectDisplayID* displays = new CGDirectDisplayID[displayCount]; if (displays == NULL) { return; } if (CGGetActiveDisplayList(displayCount, displays, &displayCount) != CGDisplayNoErr) { - free(displays); + delete[] displays; return; } @@ -967,11 +964,18 @@ COSXScreen::updateScreenShape() m_h = (SInt32)totalBounds.size.height; // get center of default screen - // XXX -- this should compute the center of displays[0] - m_xCenter = m_x + (m_w >> 1); - m_yCenter = m_y + (m_h >> 1); + GDHandle mainScreen = GetMainDevice(); + if (mainScreen != NULL) { + 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")); }