Skip to content

Commit 1475664

Browse files
committed
fix camera on mac
1 parent 38baa91 commit 1475664

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

1.9.camera/camera.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,31 @@
88

99
#include <cmath>
1010

11+
#ifdef Q_OS_MAC
12+
#include <ApplicationServices/ApplicationServices.h>
13+
#endif
14+
15+
void CheckIfProcessTrusted() {
16+
#ifdef Q_OS_MAC
17+
CFStringRef keys[] = { kAXTrustedCheckOptionPrompt };
18+
CFTypeRef values[] = { kCFBooleanTrue };
19+
CFDictionaryRef options = CFDictionaryCreate(NULL,
20+
(const void **)&keys,
21+
(const void **)&values,
22+
sizeof(keys) / sizeof(keys[0]),
23+
&kCFTypeDictionaryKeyCallBacks,
24+
&kCFTypeDictionaryValueCallBacks);
25+
if (!AXIsProcessTrustedWithOptions(options)) {
26+
throw std::runtime_error("not a trusted trusted accessibility client");
27+
}
28+
CFRelease(options);
29+
#endif
30+
}
31+
1132
Camera::Camera(QObjectPointer parent)
1233
: QObject(parent)
1334
{
35+
CheckIfProcessTrusted();
1436
m_timer = startTimer(25);
1537
}
1638

@@ -159,7 +181,7 @@ void Camera::mouseMoveEvent(QMouseEvent *event)
159181

160182
const auto size = m_window->geometry().size();
161183
const auto center = QPointF(size.width() / 2.0, size.height() / 2.0);
162-
const auto delta = event->localPos() - center;
184+
const auto delta = event->position() - center;
163185
const auto deltax = delta.x() * m_sensitivity;
164186
const auto deltay = delta.y() * m_sensitivity;
165187
m_yaw += deltax;

0 commit comments

Comments
 (0)