mirror of
https://github.com/debauchee/barrier.git
synced 2025-06-19 19:21:41 +02:00
merge 1.4 r887:888 into trunk
This commit is contained in:
parent
76c47c2346
commit
cc520f08d8
10 changed files with 360 additions and 119 deletions
|
@ -97,9 +97,17 @@ COSXScreen::COSXScreen(bool isPrimary) :
|
|||
LOG((CLOG_ERR "Synergy server requires accessibility API enabled. Please check the option for \"Enable access for assistive devices\" in the Universal Access System Preferences panel. Unintentional key-replication will occur until this is fixed."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// install display manager notification handler
|
||||
#if defined(MAC_OS_X_VERSION_10_5)
|
||||
CGDisplayRegisterReconfigurationCallback(displayReconfigurationCallback, this);
|
||||
#else
|
||||
m_displayManagerNotificationUPP =
|
||||
NewDMExtendedNotificationUPP(displayManagerCallback);
|
||||
OSStatus err = GetCurrentProcess(&m_PSN);
|
||||
err = DMRegisterExtendedNotifyProc(m_displayManagerNotificationUPP,
|
||||
this, 0, &m_PSN);
|
||||
#endif
|
||||
|
||||
// install fast user switching event handler
|
||||
EventTypeSpec switchEventTypes[2];
|
||||
|
@ -132,7 +140,24 @@ COSXScreen::COSXScreen(bool isPrimary) :
|
|||
if (m_switchEventHandlerRef != 0) {
|
||||
RemoveEventHandler(m_switchEventHandlerRef);
|
||||
}
|
||||
#if defined(MAC_OS_X_VERSION_10_5)
|
||||
CGDisplayRemoveReconfigurationCallback(displayReconfigurationCallback, this);
|
||||
#else
|
||||
if (m_displayManagerNotificationUPP != NULL) {
|
||||
DMRemoveExtendedNotifyProc(m_displayManagerNotificationUPP,
|
||||
NULL, &m_PSN, 0);
|
||||
}
|
||||
|
||||
if (m_hiddenWindow) {
|
||||
ReleaseWindow(m_hiddenWindow);
|
||||
m_hiddenWindow = NULL;
|
||||
}
|
||||
|
||||
if (m_userInputWindow) {
|
||||
ReleaseWindow(m_userInputWindow);
|
||||
m_userInputWindow = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
delete m_keyState;
|
||||
delete m_screensaver;
|
||||
|
@ -178,7 +203,22 @@ COSXScreen::~COSXScreen()
|
|||
|
||||
RemoveEventHandler(m_switchEventHandlerRef);
|
||||
|
||||
#if defined(MAC_OS_X_VERSION_10_5)
|
||||
CGDisplayRemoveReconfigurationCallback(displayReconfigurationCallback, this);
|
||||
#else
|
||||
DMRemoveExtendedNotifyProc(m_displayManagerNotificationUPP,
|
||||
NULL, &m_PSN, 0);
|
||||
|
||||
if (m_hiddenWindow) {
|
||||
ReleaseWindow(m_hiddenWindow);
|
||||
m_hiddenWindow = NULL;
|
||||
}
|
||||
|
||||
if (m_userInputWindow) {
|
||||
ReleaseWindow(m_userInputWindow);
|
||||
m_userInputWindow = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
delete m_keyState;
|
||||
delete m_screensaver;
|
||||
|
@ -526,17 +566,22 @@ void
|
|||
COSXScreen::fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const
|
||||
{
|
||||
if (xDelta != 0 || yDelta != 0) {
|
||||
#if defined(MAC_OS_X_VERSION_10_5)
|
||||
// create a scroll event, post it and release it. not sure if kCGScrollEventUnitLine
|
||||
// is the right choice here over kCGScrollEventUnitPixel
|
||||
CGEventRef scrollEvent = CGEventCreateScrollWheelEvent(NULL,
|
||||
kCGScrollEventUnitLine,
|
||||
2,
|
||||
mapScrollWheelFromSynergy(yDelta),
|
||||
-mapScrollWheelFromSynergy(xDelta));
|
||||
CGEventRef scrollEvent = CGEventCreateScrollWheelEvent(
|
||||
NULL, kCGScrollEventUnitLine, 2,
|
||||
mapScrollWheelFromSynergy(yDelta),
|
||||
-mapScrollWheelFromSynergy(xDelta));
|
||||
|
||||
CGEventPost(kCGHIDEventTap, scrollEvent);
|
||||
|
||||
CFRelease(scrollEvent);
|
||||
#else
|
||||
|
||||
CGPostScrollWheelEvent(
|
||||
2, mapScrollWheelFromSynergy(yDelta),
|
||||
-mapScrollWheelFromSynergy(xDelta));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -988,6 +1033,42 @@ COSXScreen::handleClipboardCheck(const CEvent&, void*)
|
|||
checkClipboards();
|
||||
}
|
||||
|
||||
#if !defined(MAC_OS_X_VERSION_10_5)
|
||||
pascal void
|
||||
COSXScreen::displayManagerCallback(void* inUserData, SInt16 inMessage, void*)
|
||||
{
|
||||
COSXScreen* screen = (COSXScreen*)inUserData;
|
||||
|
||||
if (inMessage == kDMNotifyEvent) {
|
||||
screen->onDisplayChange();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
COSXScreen::onDisplayChange()
|
||||
{
|
||||
// screen resolution may have changed. save old shape.
|
||||
SInt32 xOld = m_x, yOld = m_y, wOld = m_w, hOld = m_h;
|
||||
|
||||
// update shape
|
||||
updateScreenShape();
|
||||
|
||||
// do nothing if resolution hasn't changed
|
||||
if (xOld != m_x || yOld != m_y || wOld != m_w || hOld != m_h) {
|
||||
if (m_isPrimary) {
|
||||
// warp mouse to center if off screen
|
||||
if (!m_isOnScreen) {
|
||||
warpCursor(m_xCenter, m_yCenter);
|
||||
}
|
||||
}
|
||||
|
||||
// send new screen info
|
||||
sendEvent(getShapeChangedEvent());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
void
|
||||
COSXScreen::displayReconfigurationCallback(CGDirectDisplayID displayID, CGDisplayChangeSummaryFlags flags, void* inUserData)
|
||||
{
|
||||
|
@ -1007,6 +1088,7 @@ COSXScreen::displayReconfigurationCallback(CGDirectDisplayID displayID, CGDispla
|
|||
screen->updateScreenShape(displayID, flags);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool
|
||||
COSXScreen::onKey(CGEventRef event)
|
||||
|
@ -1275,7 +1357,12 @@ COSXScreen::getKeyState() const
|
|||
void
|
||||
COSXScreen::updateScreenShape(const CGDirectDisplayID, const CGDisplayChangeSummaryFlags flags)
|
||||
{
|
||||
|
||||
updateScreenShape();
|
||||
}
|
||||
|
||||
void
|
||||
COSXScreen::updateScreenShape()
|
||||
{
|
||||
// get info for each display
|
||||
CGDisplayCount displayCount = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue