Prevent unpriveleged mouse-drag on macOS from conflicting with priveleged case.

This commit is contained in:
Jack Andersen 2019-11-25 16:49:17 -10:00
parent 842c72ac45
commit 94bdd70cb3
2 changed files with 12 additions and 5 deletions

View File

@ -270,17 +270,23 @@ void CBasicViewport::ProcessInput()
if (IsMouseInputActive()) if (IsMouseInputActive())
{ {
float XMovement, YMovement;
#ifdef __APPLE__ #ifdef __APPLE__
// QCursor::setPos only works on macOS when the user permits PWE // QCursor::setPos only works on macOS when the user permits PWE
// to control the computer via Universal Access. // to control the computer via Universal Access.
// As an alternative to relying on the delta of a warped mouse, // As an alternative to relying on the delta of a warped mouse,
// use the accumulated delta directly reported by AppKit. // use the accumulated delta directly reported by AppKit.
float XMovement = gpMouseDragCocoaEventFilter->claimX() * 0.01f; if (!AXIsProcessTrusted())
float YMovement = gpMouseDragCocoaEventFilter->claimY() * 0.01f; {
#else XMovement = gpMouseDragCocoaEventFilter->claimX() * 0.01f;
float XMovement = (QCursor::pos().x() - mLastMousePos.x()) * 0.01f; YMovement = gpMouseDragCocoaEventFilter->claimY() * 0.01f;
float YMovement = (QCursor::pos().y() - mLastMousePos.y()) * 0.01f; }
else
#endif #endif
{
XMovement = (QCursor::pos().x() - mLastMousePos.x()) * 0.01f;
YMovement = (QCursor::pos().y() - mLastMousePos.y()) * 0.01f;
}
if ((XMovement != 0) || (YMovement != 0)) if ((XMovement != 0) || (YMovement != 0))
{ {

View File

@ -3,6 +3,7 @@
#ifdef __APPLE__ #ifdef __APPLE__
#include <CoreGraphics/CGBase.h> #include <CoreGraphics/CGBase.h>
extern "C" Boolean AXIsProcessTrusted(void);
#include <QAbstractNativeEventFilter> #include <QAbstractNativeEventFilter>
#include <QString> #include <QString>