@sonicloud/dsh-sonicloud-device 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/CHANGELOG.zh.md +44 -0
- package/README.md +81 -86
- package/README.zh.md +135 -0
- package/dist/build.json +1 -1
- package/dist/client.js +202 -28
- package/docs/contributing/development.md +51 -28
- package/docs/images/plugin-install.png +0 -0
- package/docs/images/sonicloud-device.png +0 -0
- package/docs/specs/ci-cd.md +24 -37
- package/docs/specs/mouse-settings.md +7 -34
- package/docs/specs/smart-mouse-plugin.md +51 -32
- package/native/README.md +4 -0
- package/native/desktop/VOICE_SOURCE.json +16 -0
- package/native/desktop/VoicePanel.cs +191 -59
- package/native/desktop/VoicePanel.swift +27 -0
- package/native/desktop/darwin-arm64/Sonicloud Voice.app/Contents/MacOS/sonicloud-voice +0 -0
- package/native/desktop/darwin-arm64/Sonicloud Voice.app/Contents/_CodeSignature/CodeResources +115 -0
- package/native/desktop/typer.dll +0 -0
- package/native/desktop/windows.ps1 +1 -1
- package/native/screenshot/README.md +34 -0
- package/native/screenshot/SOURCE.json +218 -0
- package/native/screenshot/darwin-arm64/screentool-macos-1.2.2.zip +0 -0
- package/native/screenshot/patches/hide-cloud-actions.patch +202 -0
- package/native/screenshot/patches/mac-permissions.patch +545 -0
- package/native/screenshot/patches/upstream-files.json +22 -0
- package/native/screenshot/win32-x64/PixPinScrollCapture.dll +0 -0
- package/native/screenshot/win32-x64/Qt5Core.dll +0 -0
- package/native/screenshot/win32-x64/Qt5Gui.dll +0 -0
- package/native/screenshot/win32-x64/Qt5Network.dll +0 -0
- package/native/screenshot/win32-x64/Qt5Svg.dll +0 -0
- package/native/screenshot/win32-x64/Qt5Widgets.dll +0 -0
- package/native/screenshot/win32-x64/iconengines/qsvgicon.dll +0 -0
- package/native/screenshot/win32-x64/imageformats/qjpeg.dll +0 -0
- package/native/screenshot/win32-x64/imageformats/qsvg.dll +0 -0
- package/native/screenshot/win32-x64/libcrypto-1_1-x64.dll +0 -0
- package/native/screenshot/win32-x64/libssl-1_1-x64.dll +0 -0
- package/native/screenshot/win32-x64/msvcp140.dll +0 -0
- package/native/screenshot/win32-x64/platforms/qwindows.dll +0 -0
- package/native/screenshot/win32-x64/qwindowsvistastyle.dll +0 -0
- package/native/screenshot/win32-x64/screenhelper.exe +0 -0
- package/native/screenshot/win32-x64/screentool.dll +0 -0
- package/native/screenshot/win32-x64/vcruntime140.dll +0 -0
- package/native/screenshot/win32-x64/vcruntime140_1.dll +0 -0
- package/package.json +2 -1
- package/src/desktop/presentation.mjs +18 -4
- package/src/desktop/screenshot-worker.mjs +225 -0
- package/src/desktop/screenshot.mjs +185 -0
- package/src/devices/actions.mjs +7 -1
- package/src/devices/manager.mjs +145 -81
- package/src/host/index.mjs +5 -1
- package/src/shared/remote.mjs +5 -0
- /package/{src/client/assets → docs/images}/contact-wechat.jpg +0 -0
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
--- a/ipc/helper_gateway.h
|
|
2
|
+
+++ b/ipc/helper_gateway.h
|
|
3
|
+
@@ -28,6 +28,7 @@
|
|
4
|
+
// 中继宿主),relay 应答经 ocr_result 命令回流 deliverResult
|
|
5
|
+
class HelperGateway : public QObject
|
|
6
|
+
{
|
|
7
|
+
+ friend class TestMacPermissions;
|
|
8
|
+
Q_OBJECT
|
|
9
|
+
public:
|
|
10
|
+
explicit HelperGateway(QObject* parent = nullptr);
|
|
11
|
+
@@ -60,9 +61,18 @@
|
|
12
|
+
void onPinEdited(quintptr id, const PinDocument& doc);
|
|
13
|
+
void onPinEditCancelled(quintptr id);
|
|
14
|
+
|
|
15
|
+
+protected:
|
|
16
|
+
+ virtual bool screenPermissionGranted() const;
|
|
17
|
+
+ virtual bool accessibilityPermissionGranted() const;
|
|
18
|
+
+ virtual void promptScreenPermission();
|
|
19
|
+
+ virtual void promptAccessibilityPermission();
|
|
20
|
+
+ virtual void beginCapture();
|
|
21
|
+
+ virtual void sendEvent(const QJsonObject& header, const QByteArray& payload = QByteArray());
|
|
22
|
+
+
|
|
23
|
+
private:
|
|
24
|
+
void ensureLabel();
|
|
25
|
+
- void sendEvent(const QJsonObject& header, const QByteArray& payload = QByteArray());
|
|
26
|
+
+ void sendStateReport();
|
|
27
|
+
+ void requestPermission(const QString& permission);
|
|
28
|
+
// [FOLLOW-ANCHOR] 上报截图会话锚定屏参数(start_capture 与跟屏重锚共用)
|
|
29
|
+
void sendSessionStarted();
|
|
30
|
+
void enterDetached();
|
|
31
|
+
--- a/ipc/helper_gateway.cpp
|
|
32
|
+
+++ b/ipc/helper_gateway.cpp
|
|
33
|
+
@@ -25,11 +25,14 @@
|
|
34
|
+
#include <QLocalSocket>
|
|
35
|
+
#include <QScreen>
|
|
36
|
+
#include <QTimer>
|
|
37
|
+
+#include <QSignalBlocker>
|
|
38
|
+
#ifdef Q_OS_MAC
|
|
39
|
+
// [MAC-PERM-GUIDE] state_report 权限字段:AXIsProcessTrusted/
|
|
40
|
+
// CGPreflightScreenCaptureAccess(ApplicationServices)
|
|
41
|
+
#include <ApplicationServices/ApplicationServices.h>
|
|
42
|
+
#include <QDir>
|
|
43
|
+
+#include <QDesktopServices>
|
|
44
|
+
+#include <QUrl>
|
|
45
|
+
#endif
|
|
46
|
+
|
|
47
|
+
#ifndef SCREENHELPER_VERSION
|
|
48
|
+
@@ -186,6 +189,9 @@
|
|
49
|
+
#ifdef ENABLE_PIXPIN_SCROLL_CAPTURE
|
|
50
|
+
caps.append(QStringLiteral("scroll_capture"));
|
|
51
|
+
#endif
|
|
52
|
+
+#ifdef Q_OS_MAC
|
|
53
|
+
+ caps.append(QStringLiteral("permission_preflight"));
|
|
54
|
+
+#endif
|
|
55
|
+
sendEvent(QJsonObject{{"type", "hello_ack"},
|
|
56
|
+
{"proto_ver", Ipc::kProtoVer},
|
|
57
|
+
{"helper_ver", QLatin1String(SCREENHELPER_VERSION)},
|
|
58
|
+
@@ -196,6 +202,11 @@
|
|
59
|
+
}
|
|
60
|
+
else if (type == QStringLiteral("set_config"))
|
|
61
|
+
{
|
|
62
|
+
+ if (header.contains(QStringLiteral("permission_request")))
|
|
63
|
+
+ {
|
|
64
|
+
+ requestPermission(header.value(QStringLiteral("permission_request")).toString());
|
|
65
|
+
+ return;
|
|
66
|
+
+ }
|
|
67
|
+
const QString oldLang = HelperConfig::instance().lang();
|
|
68
|
+
const QString oldTheme = HelperConfig::instance().uiTheme();
|
|
69
|
+
const QString oldIcon = HelperConfig::instance().uiIcon();
|
|
70
|
+
@@ -242,17 +253,25 @@
|
|
71
|
+
}
|
|
72
|
+
else if (type == QStringLiteral("start_capture"))
|
|
73
|
+
{
|
|
74
|
+
- // [PIN-EDIT M2] 冲突规则:编辑会话被截图抢占 → 先取消(贴图恢复原样)
|
|
75
|
+
- if (m_pinEditing)
|
|
76
|
+
- cancelPinEdit();
|
|
77
|
+
- ensureLabel();
|
|
78
|
+
- if (m_capturing)
|
|
79
|
+
- m_label->stopScreenshot(); // 重复下发先复位会话
|
|
80
|
+
- m_label->showScreen();
|
|
81
|
+
- m_capturing = true;
|
|
82
|
+
- // [FOLLOW-ANCHOR] 会话启动即报锚定屏;此后蒙层跟屏重锚(光标换屏、
|
|
83
|
+
- // 首次按下前)由 screenReanchored → sendSessionStarted 补发刷新参数
|
|
84
|
+
- sendSessionStarted();
|
|
85
|
+
+ // Check before creating a capture window or reading pixels.
|
|
86
|
+
+ if (!screenPermissionGranted())
|
|
87
|
+
+ {
|
|
88
|
+
+ if (m_label && m_capturing)
|
|
89
|
+
+ {
|
|
90
|
+
+ const QSignalBlocker blocker(m_label);
|
|
91
|
+
+ m_label->stopScreenshot(QStringLiteral("permission_required"));
|
|
92
|
+
+ }
|
|
93
|
+
+ m_capturing = false;
|
|
94
|
+
+ sendStateReport();
|
|
95
|
+
+ // End the pending request so the client watchdog does not relaunch us.
|
|
96
|
+
+ sendEvent(QJsonObject{{"type", "session_ended"},
|
|
97
|
+
+ {"reason", QStringLiteral("permission_required")}});
|
|
98
|
+
+ sendEvent(QJsonObject{{"type", "error"},
|
|
99
|
+
+ {"code", QStringLiteral("permission_screen_required")},
|
|
100
|
+
+ {"message", QStringLiteral("Screen Recording permission is required before capture")}});
|
|
101
|
+
+ return;
|
|
102
|
+
+ }
|
|
103
|
+
+ beginCapture();
|
|
104
|
+
}
|
|
105
|
+
else if (type == QStringLiteral("cancel_capture"))
|
|
106
|
+
{
|
|
107
|
+
@@ -261,6 +280,114 @@
|
|
108
|
+
}
|
|
109
|
+
else if (type == QStringLiteral("query_state"))
|
|
110
|
+
{
|
|
111
|
+
+ sendStateReport();
|
|
112
|
+
+ }
|
|
113
|
+
+ else if (type == QStringLiteral("shutdown"))
|
|
114
|
+
+ {
|
|
115
|
+
+ m_shutdownByHost = true;
|
|
116
|
+
+ const QString policy = header.value(QStringLiteral("pins_policy")).toString(QStringLiteral("close_now"));
|
|
117
|
+
+ if (policy == QLatin1String("keep_detached"))
|
|
118
|
+
+ {
|
|
119
|
+
+ enterDetached();
|
|
120
|
+
+ }
|
|
121
|
+
+ else
|
|
122
|
+
+ {
|
|
123
|
+
+ emit shutdownRequested(); // close_now:helper_main 直接退出
|
|
124
|
+
+ }
|
|
125
|
+
+ }
|
|
126
|
+
+ else
|
|
127
|
+
+ {
|
|
128
|
+
+ sendEvent(QJsonObject{{"type", "error"},
|
|
129
|
+
+ {"code", "unknown_type"},
|
|
130
|
+
+ {"message", type}});
|
|
131
|
+
+ }
|
|
132
|
+
+}
|
|
133
|
+
+
|
|
134
|
+
+bool HelperGateway::screenPermissionGranted() const
|
|
135
|
+
+{
|
|
136
|
+
+#ifdef Q_OS_MAC
|
|
137
|
+
+ return CGPreflightScreenCaptureAccess();
|
|
138
|
+
+#else
|
|
139
|
+
+ return true;
|
|
140
|
+
+#endif
|
|
141
|
+
+}
|
|
142
|
+
+
|
|
143
|
+
+bool HelperGateway::accessibilityPermissionGranted() const
|
|
144
|
+
+{
|
|
145
|
+
+#ifdef Q_OS_MAC
|
|
146
|
+
+ return AXIsProcessTrusted();
|
|
147
|
+
+#else
|
|
148
|
+
+ return true;
|
|
149
|
+
+#endif
|
|
150
|
+
+}
|
|
151
|
+
+
|
|
152
|
+
+void HelperGateway::promptScreenPermission()
|
|
153
|
+
+{
|
|
154
|
+
+#ifdef Q_OS_MAC
|
|
155
|
+
+ CGRequestScreenCaptureAccess();
|
|
156
|
+
+ QDesktopServices::openUrl(QUrl(QStringLiteral(
|
|
157
|
+
+ "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture")));
|
|
158
|
+
+#endif
|
|
159
|
+
+}
|
|
160
|
+
+
|
|
161
|
+
+void HelperGateway::promptAccessibilityPermission()
|
|
162
|
+
+{
|
|
163
|
+
+#ifdef Q_OS_MAC
|
|
164
|
+
+ const void* keys[] = { kAXTrustedCheckOptionPrompt };
|
|
165
|
+
+ const void* values[] = { kCFBooleanTrue };
|
|
166
|
+
+ CFDictionaryRef options = CFDictionaryCreate(kCFAllocatorDefault, keys, values, 1,
|
|
167
|
+
+ &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
|
168
|
+
+ AXIsProcessTrustedWithOptions(options);
|
|
169
|
+
+ CFRelease(options);
|
|
170
|
+
+ QDesktopServices::openUrl(QUrl(QStringLiteral(
|
|
171
|
+
+ "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")));
|
|
172
|
+
+#endif
|
|
173
|
+
+}
|
|
174
|
+
+
|
|
175
|
+
+void HelperGateway::requestPermission(const QString& permission)
|
|
176
|
+
+{
|
|
177
|
+
+ if (permission != QLatin1String("screen") && permission != QLatin1String("accessibility"))
|
|
178
|
+
+ {
|
|
179
|
+
+ sendEvent(QJsonObject{{"type", "error"},
|
|
180
|
+
+ {"code", QStringLiteral("permission_request_invalid")},
|
|
181
|
+
+ {"message", QStringLiteral("Unknown permission request")}});
|
|
182
|
+
+ return;
|
|
183
|
+
+ }
|
|
184
|
+
+ if (m_capturing || m_pinEditing)
|
|
185
|
+
+ {
|
|
186
|
+
+ sendStateReport();
|
|
187
|
+
+ sendEvent(QJsonObject{{"type", "error"},
|
|
188
|
+
+ {"code", QStringLiteral("permission_request_busy")},
|
|
189
|
+
+ {"message", QStringLiteral("Finish capture or pin editing before permission setup")}});
|
|
190
|
+
+ return;
|
|
191
|
+
+ }
|
|
192
|
+
+#ifdef Q_OS_MAC
|
|
193
|
+
+ QTimer::singleShot(0, this, [this, permission] {
|
|
194
|
+
+ // A capture can start between receiving the command and this callback.
|
|
195
|
+
+ if (m_capturing || m_pinEditing)
|
|
196
|
+
+ {
|
|
197
|
+
+ sendStateReport();
|
|
198
|
+
+ sendEvent(QJsonObject{{"type", "error"},
|
|
199
|
+
+ {"code", QStringLiteral("permission_request_busy")},
|
|
200
|
+
+ {"message", QStringLiteral("Finish capture or pin editing before permission setup")}});
|
|
201
|
+
+ return;
|
|
202
|
+
+ }
|
|
203
|
+
+ if (permission == QLatin1String("screen") && !screenPermissionGranted())
|
|
204
|
+
+ promptScreenPermission();
|
|
205
|
+
+ else if (permission == QLatin1String("accessibility") && !accessibilityPermissionGranted())
|
|
206
|
+
+ promptAccessibilityPermission();
|
|
207
|
+
+ // Requesting is asynchronous; this reports status, never a grant promise.
|
|
208
|
+
+ sendStateReport();
|
|
209
|
+
+ });
|
|
210
|
+
+#else
|
|
211
|
+
+ sendEvent(QJsonObject{{"type", "error"},
|
|
212
|
+
+ {"code", QStringLiteral("permission_request_unsupported")},
|
|
213
|
+
+ {"message", QStringLiteral("Permission setup is only available on macOS")}});
|
|
214
|
+
+#endif
|
|
215
|
+
+}
|
|
216
|
+
+
|
|
217
|
+
+void HelperGateway::sendStateReport()
|
|
218
|
+
+{
|
|
219
|
+
// [MAC-PERM-GUIDE] mac 下附加权限实测字段:宿主启动引导用(helper 是
|
|
220
|
+
// 屏幕录制/辅助功能的权限主体,宿主自身无法代查)。旧宿主忽略未知
|
|
221
|
+
// 字段;新宿主按 helper_ver>=1.2.2 判定字段可用。win 不附加(宿主
|
|
222
|
+
@@ -268,6 +395,7 @@
|
|
223
|
+
QJsonObject rep{{"type", "state_report"},
|
|
224
|
+
{"pins_alive", m_pinMap.size()},
|
|
225
|
+
{"capturing", m_capturing},
|
|
226
|
+
+ {"pin_editing", m_pinEditing},
|
|
227
|
+
{"helper_ver", QLatin1String(SCREENHELPER_VERSION)},
|
|
228
|
+
{"ui_theme", ThemeManager::instance().currentName()}};
|
|
229
|
+
#ifdef Q_OS_MAC
|
|
230
|
+
@@ -279,30 +407,22 @@
|
|
231
|
+
if (d.cdUp() && d.cdUp() && d.dirName().endsWith(QLatin1String(".app")))
|
|
232
|
+
rep.insert(QStringLiteral("helper_app"), d.absolutePath());
|
|
233
|
+
}
|
|
234
|
+
- rep.insert(QStringLiteral("perm_a11y"), AXIsProcessTrusted());
|
|
235
|
+
- rep.insert(QStringLiteral("perm_screen"), CGPreflightScreenCaptureAccess());
|
|
236
|
+
+ rep.insert(QStringLiteral("perm_a11y"), accessibilityPermissionGranted());
|
|
237
|
+
+ rep.insert(QStringLiteral("perm_screen"), screenPermissionGranted());
|
|
238
|
+
#endif
|
|
239
|
+
sendEvent(rep);
|
|
240
|
+
- }
|
|
241
|
+
- else if (type == QStringLiteral("shutdown"))
|
|
242
|
+
- {
|
|
243
|
+
- m_shutdownByHost = true;
|
|
244
|
+
- const QString policy = header.value(QStringLiteral("pins_policy")).toString(QStringLiteral("close_now"));
|
|
245
|
+
- if (policy == QLatin1String("keep_detached"))
|
|
246
|
+
- {
|
|
247
|
+
- enterDetached();
|
|
248
|
+
- }
|
|
249
|
+
- else
|
|
250
|
+
- {
|
|
251
|
+
- emit shutdownRequested(); // close_now:helper_main 直接退出
|
|
252
|
+
- }
|
|
253
|
+
- }
|
|
254
|
+
- else
|
|
255
|
+
- {
|
|
256
|
+
- sendEvent(QJsonObject{{"type", "error"},
|
|
257
|
+
- {"code", "unknown_type"},
|
|
258
|
+
- {"message", type}});
|
|
259
|
+
- }
|
|
260
|
+
+}
|
|
261
|
+
+
|
|
262
|
+
+void HelperGateway::beginCapture()
|
|
263
|
+
+{
|
|
264
|
+
+ if (m_pinEditing)
|
|
265
|
+
+ cancelPinEdit();
|
|
266
|
+
+ ensureLabel();
|
|
267
|
+
+ if (m_capturing)
|
|
268
|
+
+ m_label->stopScreenshot();
|
|
269
|
+
+ m_label->showScreen();
|
|
270
|
+
+ m_capturing = true;
|
|
271
|
+
+ sendSessionStarted();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
void HelperGateway::ensureLabel()
|
|
275
|
+
@@ -314,6 +434,12 @@
|
|
276
|
+
connect(m_label, &ScreenLabel::signalOCRMap, this, &HelperGateway::onOcrMap);
|
|
277
|
+
connect(m_label, &ScreenLabel::convertImage, this, &HelperGateway::onConvertImage);
|
|
278
|
+
connect(m_label, &ScreenLabel::sessionFinished, this, &HelperGateway::onSessionFinished);
|
|
279
|
+
+ connect(m_label, &ScreenLabel::screenPermissionRequired, this, [this] {
|
|
280
|
+
+ sendStateReport();
|
|
281
|
+
+ sendEvent(QJsonObject{{"type", "error"},
|
|
282
|
+
+ {"code", QStringLiteral("permission_screen_required")},
|
|
283
|
+
+ {"message", QStringLiteral("Screen Recording permission is required before capture")}});
|
|
284
|
+
+ });
|
|
285
|
+
connect(m_label, &ScreenLabel::pinCreated, this, &HelperGateway::onPinCreated);
|
|
286
|
+
// [FOLLOW-ANCHOR] 跟屏重锚 → 补发 session_started 刷新锚定屏参数
|
|
287
|
+
connect(m_label, &ScreenLabel::screenReanchored, this, [this]() {
|
|
288
|
+
--- a/core/screen_label.h
|
|
289
|
+
+++ b/core/screen_label.h
|
|
290
|
+
@@ -108,7 +108,7 @@
|
|
291
|
+
|
|
292
|
+
void showScreen(); // interface
|
|
293
|
+
void updateUiLanguage();
|
|
294
|
+
- void stopScreenshot();
|
|
295
|
+
+ void stopScreenshot(const QString& reason = QStringLiteral("canceled"));
|
|
296
|
+
// [PIN-EDIT M2] 贴图编辑模式:入口/查询/取消(网关冲突规则调用 cancel)
|
|
297
|
+
// [R4-1] 原窗口编辑:编辑器作为子部件嵌入宿主贴图窗口(对齐参考 EnterEdit
|
|
298
|
+
// 的"贴图窗口自身变画布"),覆盖其内容区,全程只有一个窗口
|
|
299
|
+
@@ -258,6 +258,7 @@
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
signals:
|
|
303
|
+
+ void screenPermissionRequired();
|
|
304
|
+
void signalCutMap(const QPixmap); //获取截图
|
|
305
|
+
void signalOCRMap(const QPixmap, const QString& source); // [PIN-EDIT M2] 增 source(region/scroll/pin)
|
|
306
|
+
void captureFinished();
|
|
307
|
+
--- a/core/screen_label.cpp
|
|
308
|
+
+++ b/core/screen_label.cpp
|
|
309
|
+
@@ -319,7 +319,7 @@
|
|
310
|
+
#endif
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
-void ScreenLabel::stopScreenshot()
|
|
314
|
+
+void ScreenLabel::stopScreenshot(const QString& reason)
|
|
315
|
+
{
|
|
316
|
+
if (capturing_)
|
|
317
|
+
{
|
|
318
|
+
@@ -338,7 +338,7 @@
|
|
319
|
+
#endif
|
|
320
|
+
close();
|
|
321
|
+
// [HELPER-IPC] 宿主 cancel_capture 路径
|
|
322
|
+
- emit sessionFinished(QStringLiteral("canceled"));
|
|
323
|
+
+ emit sessionFinished(reason);
|
|
324
|
+
}
|
|
325
|
+
// [FOLLOW-ANCHOR] 会话结束停跟屏(tick 亦有自守卫,此处显式停更直观)
|
|
326
|
+
m_followTimer->stop();
|
|
327
|
+
@@ -1522,54 +1522,14 @@
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
#ifdef Q_OS_MAC
|
|
331
|
+
- // [MAC-A11Y] 双权限自检(每进程各提醒一次,授权后不再出现;弹窗在
|
|
332
|
+
- // hide()/PixPin UI 之前完成,不进长截图画面):
|
|
333
|
+
- // 1) 辅助功能——PixPin 工具条"自动滚动"注入的合成滚轮事件会被未授权
|
|
334
|
+
- // 进程静默丢弃(2026-09-17 实证:未授权连发滚轮无效;真实鼠标手动
|
|
335
|
+
- // 滚动不受影响);
|
|
336
|
+
- // 2) 屏幕录制——PixPin 拼接帧走 CGDisplay 旧采集 API,无此权限只回
|
|
337
|
+
- // 壁纸:成图黑底(2026-09-20 实证亮度 37-48 vs 186 双态)。
|
|
338
|
+
- qInfo() << "[MAC-A11Y] AXIsProcessTrusted =" << AXIsProcessTrusted()
|
|
339
|
+
- << " ScreenCapturePreflight =" << CGPreflightScreenCaptureAccess();
|
|
340
|
+
- // [MAC-A11Y] 引导文案中的 app 路径必须给真实路径:helper 的部署形态
|
|
341
|
+
- // 有两种(独立 deps/screenTool/ 与 electron 包内 Resources/deps/
|
|
342
|
+
- // screenTool/),写死任一都会误导另一种形态的用户(2026-09-20 实证:
|
|
343
|
+
- // electron 用户照 deps 路径找不到 app)。从自身可执行文件位置回推
|
|
344
|
+
- // bundle 根展示。
|
|
345
|
+
- const QString helperAppPath = [] {
|
|
346
|
+
- QDir dir(QCoreApplication::applicationDirPath());
|
|
347
|
+
- dir.cdUp(); dir.cdUp(); // MacOS/ → Contents/ → screenhelper.app/
|
|
348
|
+
- return dir.absolutePath();
|
|
349
|
+
- }();
|
|
350
|
+
- static bool s_a11yPrompted = false;
|
|
351
|
+
- if (!s_a11yPrompted && !AXIsProcessTrusted())
|
|
352
|
+
- {
|
|
353
|
+
- s_a11yPrompted = true;
|
|
354
|
+
- if (QMessageBox::question(nullptr, tr("辅助功能权限"),
|
|
355
|
+
- tr("滚动截图的“自动滚动”需要辅助功能权限(手动滚动不受影响)。\n\n"
|
|
356
|
+
- "请到 系统设置 → 隐私与安全性 → 辅助功能,点“+”添加并勾选\n"
|
|
357
|
+
- "screenhelper.app(路径:%1,可在弹窗里按 Cmd+Shift+G\n"
|
|
358
|
+
- "粘贴上面的路径定位),添加后无需重启即生效。\n\n"
|
|
359
|
+
- "现在打开系统设置?").arg(helperAppPath)) == QMessageBox::Yes)
|
|
360
|
+
- {
|
|
361
|
+
- QDesktopServices::openUrl(QUrl(QStringLiteral(
|
|
362
|
+
- "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")));
|
|
363
|
+
- }
|
|
364
|
+
- }
|
|
365
|
+
- static bool s_srPrompted = false;
|
|
366
|
+
- if (!s_srPrompted && !CGPreflightScreenCaptureAccess())
|
|
367
|
+
- {
|
|
368
|
+
- s_srPrompted = true;
|
|
369
|
+
- if (QMessageBox::question(nullptr, tr("屏幕录制权限"),
|
|
370
|
+
- tr("滚动截图需要屏幕录制权限,否则长图内容会是黑色背景。\n\n"
|
|
371
|
+
- "请到 系统设置 → 隐私与安全性 → 屏幕录制,点“+”添加并勾选\n"
|
|
372
|
+
- "screenhelper.app(路径:%1,可在弹窗里按 Cmd+Shift+G\n"
|
|
373
|
+
- "粘贴上面的路径定位),添加后需重启 screenhelper 生效。\n\n"
|
|
374
|
+
- "现在打开系统设置?").arg(helperAppPath)) == QMessageBox::Yes)
|
|
375
|
+
- {
|
|
376
|
+
- QDesktopServices::openUrl(QUrl(QStringLiteral(
|
|
377
|
+
- "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture")));
|
|
378
|
+
- }
|
|
379
|
+
+ qInfo() << "[MAC-PERMISSIONS] a11y =" << AXIsProcessTrusted()
|
|
380
|
+
+ << " screen =" << CGPreflightScreenCaptureAccess();
|
|
381
|
+
+ // Optional Accessibility must not interrupt manual scrolling. No dialogs here.
|
|
382
|
+
+ if (!CGPreflightScreenCaptureAccess())
|
|
383
|
+
+ {
|
|
384
|
+
+ stopScreenshot(QStringLiteral("permission_required"));
|
|
385
|
+
+ emit screenPermissionRequired();
|
|
386
|
+
+ return;
|
|
387
|
+
}
|
|
388
|
+
#endif
|
|
389
|
+
m_scrollCaptureParams.captureRect = cutRect.toRect();
|
|
390
|
+
--- a/CMakeLists.txt
|
|
391
|
+
+++ b/CMakeLists.txt
|
|
392
|
+
@@ -257,6 +257,11 @@
|
|
393
|
+
add_executable(test_helper_config tests/test_helper_config.cpp)
|
|
394
|
+
target_link_libraries(test_helper_config PRIVATE ${QT_LINK}::Test screentool_core)
|
|
395
|
+
add_test(NAME helper_config COMMAND test_helper_config)
|
|
396
|
+
+ if(APPLE)
|
|
397
|
+
+ add_executable(test_mac_permissions tests/test_mac_permissions.cpp)
|
|
398
|
+
+ target_link_libraries(test_mac_permissions PRIVATE ${QT_LINK}::Test ${QT_LINK}::Widgets screentool_ipc)
|
|
399
|
+
+ add_test(NAME mac_permissions COMMAND test_mac_permissions)
|
|
400
|
+
+ endif()
|
|
401
|
+
if(TARGET PixPinScrollCapture)
|
|
402
|
+
add_executable(test_cloud_actions tests/test_cloud_actions.cpp)
|
|
403
|
+
target_link_libraries(test_cloud_actions PRIVATE ${QT_LINK}::Test ${QT_LINK}::Widgets screentool_core)
|
|
404
|
+
--- /dev/null
|
|
405
|
+
+++ b/tests/test_mac_permissions.cpp
|
|
406
|
+
@@ -0,0 +1,139 @@
|
|
407
|
+
+#include <QtTest/QtTest>
|
|
408
|
+
+#include <QJsonArray>
|
|
409
|
+
+#include <QJsonObject>
|
|
410
|
+
+#include "../ipc/helper_gateway.h"
|
|
411
|
+
+
|
|
412
|
+
+class PermissionGateway : public HelperGateway
|
|
413
|
+
+{
|
|
414
|
+
+public:
|
|
415
|
+
+ bool screen = false;
|
|
416
|
+
+ bool accessibility = false;
|
|
417
|
+
+ int screenRequests = 0;
|
|
418
|
+
+ int accessibilityRequests = 0;
|
|
419
|
+
+ int captureStarts = 0;
|
|
420
|
+
+ QList<QJsonObject> events;
|
|
421
|
+
+ void dispatch(const QJsonObject& value)
|
|
422
|
+
+ {
|
|
423
|
+
+ QVERIFY(QMetaObject::invokeMethod(this, "onFrame", Qt::DirectConnection,
|
|
424
|
+
+ Q_ARG(QJsonObject, value), Q_ARG(QByteArray, QByteArray())));
|
|
425
|
+
+ }
|
|
426
|
+
+ QJsonObject last(const QString& type) const
|
|
427
|
+
+ {
|
|
428
|
+
+ for (auto i = events.crbegin(); i != events.crend(); ++i)
|
|
429
|
+
+ if (i->value("type").toString() == type) return *i;
|
|
430
|
+
+ return {};
|
|
431
|
+
+ }
|
|
432
|
+
+protected:
|
|
433
|
+
+ bool screenPermissionGranted() const override { return screen; }
|
|
434
|
+
+ bool accessibilityPermissionGranted() const override { return accessibility; }
|
|
435
|
+
+ void promptScreenPermission() override { ++screenRequests; }
|
|
436
|
+
+ void promptAccessibilityPermission() override { ++accessibilityRequests; }
|
|
437
|
+
+ void beginCapture() override { ++captureStarts; sendEvent(QJsonObject{{"type", "session_started"}}); }
|
|
438
|
+
+ void sendEvent(const QJsonObject& header, const QByteArray& = QByteArray()) override { events.append(header); }
|
|
439
|
+
+};
|
|
440
|
+
+
|
|
441
|
+
+class TestMacPermissions : public QObject
|
|
442
|
+
+{
|
|
443
|
+
+ Q_OBJECT
|
|
444
|
+
+private slots:
|
|
445
|
+
+ void missingScreenNeverCreatesOverlay();
|
|
446
|
+
+ void optionalAccessibilityDoesNotBlockCapture();
|
|
447
|
+
+ void stateAndCapabilityReport();
|
|
448
|
+
+ void requestValidationAndBusyGuard();
|
|
449
|
+
+ void explicitRequestsNeverPretendGranted();
|
|
450
|
+
+ void busyRaceDoesNotPrompt();
|
|
451
|
+
+};
|
|
452
|
+
+
|
|
453
|
+
+void TestMacPermissions::missingScreenNeverCreatesOverlay()
|
|
454
|
+
+{
|
|
455
|
+
+ PermissionGateway gateway;
|
|
456
|
+
+ gateway.dispatch(QJsonObject{{"type", "start_capture"}});
|
|
457
|
+
+ QCOMPARE(gateway.captureStarts, 0);
|
|
458
|
+
+ QVERIFY(gateway.m_label == nullptr);
|
|
459
|
+
+ QVERIFY(!gateway.m_capturing);
|
|
460
|
+
+ QVERIFY(gateway.last("session_started").isEmpty());
|
|
461
|
+
+ QCOMPARE(gateway.last("session_ended").value("reason").toString(), QStringLiteral("permission_required"));
|
|
462
|
+
+ QCOMPARE(gateway.last("error").value("code").toString(), QStringLiteral("permission_screen_required"));
|
|
463
|
+
+ QVERIFY(!gateway.last("state_report").value("perm_screen").toBool());
|
|
464
|
+
+}
|
|
465
|
+
+
|
|
466
|
+
+void TestMacPermissions::optionalAccessibilityDoesNotBlockCapture()
|
|
467
|
+
+{
|
|
468
|
+
+ PermissionGateway gateway;
|
|
469
|
+
+ gateway.screen = true;
|
|
470
|
+
+ gateway.accessibility = false;
|
|
471
|
+
+ gateway.dispatch(QJsonObject{{"type", "start_capture"}});
|
|
472
|
+
+ QCOMPARE(gateway.captureStarts, 1);
|
|
473
|
+
+ QVERIFY(gateway.last("error").isEmpty());
|
|
474
|
+
+ QCOMPARE(gateway.accessibilityRequests, 0);
|
|
475
|
+
+}
|
|
476
|
+
+
|
|
477
|
+
+void TestMacPermissions::stateAndCapabilityReport()
|
|
478
|
+
+{
|
|
479
|
+
+ PermissionGateway gateway;
|
|
480
|
+
+ gateway.dispatch(QJsonObject{{"type", "hello"}});
|
|
481
|
+
+ QVERIFY(gateway.last("hello_ack").value("capabilities").toArray().contains(QStringLiteral("permission_preflight")));
|
|
482
|
+
+ gateway.m_pinEditing = true;
|
|
483
|
+
+ gateway.dispatch(QJsonObject{{"type", "query_state"}});
|
|
484
|
+
+ const auto report = gateway.last("state_report");
|
|
485
|
+
+ QVERIFY(report.contains("perm_screen"));
|
|
486
|
+
+ QVERIFY(report.contains("perm_a11y"));
|
|
487
|
+
+ QVERIFY(report.value("pin_editing").toBool());
|
|
488
|
+
+ QVERIFY(gateway.m_label == nullptr);
|
|
489
|
+
+ gateway.m_pinEditing = false;
|
|
490
|
+
+}
|
|
491
|
+
+
|
|
492
|
+
+void TestMacPermissions::requestValidationAndBusyGuard()
|
|
493
|
+
+{
|
|
494
|
+
+ PermissionGateway gateway;
|
|
495
|
+
+ for (const auto& value : QList<QJsonValue>{QJsonValue(""), QJsonValue("both"), QJsonValue(true), QJsonValue(1), QJsonValue(QJsonObject{})})
|
|
496
|
+
+ {
|
|
497
|
+
+ gateway.dispatch(QJsonObject{{"type", "set_config"}, {"permission_request", value}});
|
|
498
|
+
+ QCOMPARE(gateway.last("error").value("code").toString(), QStringLiteral("permission_request_invalid"));
|
|
499
|
+
+ }
|
|
500
|
+
+ for (const bool editing : {false, true})
|
|
501
|
+
+ {
|
|
502
|
+
+ gateway.m_capturing = !editing;
|
|
503
|
+
+ gateway.m_pinEditing = editing;
|
|
504
|
+
+ gateway.dispatch(QJsonObject{{"type", "set_config"}, {"permission_request", "screen"}});
|
|
505
|
+
+ QCOMPARE(gateway.last("error").value("code").toString(), QStringLiteral("permission_request_busy"));
|
|
506
|
+
+ }
|
|
507
|
+
+ gateway.m_capturing = false;
|
|
508
|
+
+ gateway.m_pinEditing = false;
|
|
509
|
+
+ QCoreApplication::processEvents();
|
|
510
|
+
+ QCOMPARE(gateway.screenRequests, 0);
|
|
511
|
+
+ QCOMPARE(gateway.accessibilityRequests, 0);
|
|
512
|
+
+ QVERIFY(gateway.m_label == nullptr);
|
|
513
|
+
+}
|
|
514
|
+
+
|
|
515
|
+
+void TestMacPermissions::explicitRequestsNeverPretendGranted()
|
|
516
|
+
+{
|
|
517
|
+
+ PermissionGateway gateway;
|
|
518
|
+
+ gateway.dispatch(QJsonObject{{"type", "set_config"}, {"permission_request", "screen"}});
|
|
519
|
+
+ QTRY_COMPARE(gateway.screenRequests, 1);
|
|
520
|
+
+ QVERIFY(!gateway.last("state_report").value("perm_screen").toBool());
|
|
521
|
+
+ gateway.dispatch(QJsonObject{{"type", "set_config"}, {"permission_request", "accessibility"}});
|
|
522
|
+
+ QTRY_COMPARE(gateway.accessibilityRequests, 1);
|
|
523
|
+
+ QVERIFY(!gateway.last("state_report").value("perm_a11y").toBool());
|
|
524
|
+
+ QCOMPARE(gateway.captureStarts, 0);
|
|
525
|
+
+ QVERIFY(gateway.m_label == nullptr);
|
|
526
|
+
+ gateway.screen = true;
|
|
527
|
+
+ gateway.dispatch(QJsonObject{{"type", "set_config"}, {"permission_request", "screen"}});
|
|
528
|
+
+ QCoreApplication::processEvents();
|
|
529
|
+
+ QCOMPARE(gateway.screenRequests, 1);
|
|
530
|
+
+ QVERIFY(gateway.last("state_report").value("perm_screen").toBool());
|
|
531
|
+
+}
|
|
532
|
+
+
|
|
533
|
+
+void TestMacPermissions::busyRaceDoesNotPrompt()
|
|
534
|
+
+{
|
|
535
|
+
+ PermissionGateway gateway;
|
|
536
|
+
+ gateway.dispatch(QJsonObject{{"type", "set_config"}, {"permission_request", "screen"}});
|
|
537
|
+
+ gateway.m_capturing = true;
|
|
538
|
+
+ QCoreApplication::processEvents();
|
|
539
|
+
+ QCOMPARE(gateway.screenRequests, 0);
|
|
540
|
+
+ QCOMPARE(gateway.last("error").value("code").toString(), QStringLiteral("permission_request_busy"));
|
|
541
|
+
+ gateway.m_capturing = false;
|
|
542
|
+
+}
|
|
543
|
+
+
|
|
544
|
+
+QTEST_MAIN(TestMacPermissions)
|
|
545
|
+
+#include "test_mac_permissions.moc"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"path": "core/screen_tool_bar.cpp",
|
|
4
|
+
"sha256": "0b7553a9100bb4e3766328c8188c4900cd1b5aff5488f0488765e9350893a2fa"
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
"path": "core/screen_label.h",
|
|
8
|
+
"sha256": "b0105929067c2e3648cac46eaf668e2778b8e93a1084b947d2525e3900d47de8"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"path": "core/screen_label.cpp",
|
|
12
|
+
"sha256": "efc6d031df62be1e102d8c0954a4064e24240d68985fad0dcea28d8b4d12ca3f"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "ipc/helper_gateway.cpp",
|
|
16
|
+
"sha256": "42c352b33a521807ff19960eda168b5bf7b58a240e19b1d71c3e8c977d4659a8"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "CMakeLists.txt",
|
|
20
|
+
"sha256": "907778a37e319d1fe8e475f74e532c0f51c79b517b6eae85325d42211a505d49"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonicloud/dsh-sonicloud-device",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "DeepSeek Harness 智能鼠标、多设备设置与共享语音服务",
|
|
5
5
|
"icon": "./src/client/assets/sonicloud.png",
|
|
6
6
|
"type": "module",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"dist",
|
|
19
19
|
"cordis.patch.yml",
|
|
20
20
|
"README.md",
|
|
21
|
+
"README.zh.md",
|
|
21
22
|
"src/devices",
|
|
22
23
|
"src/desktop",
|
|
23
24
|
"native",
|