Fix: Align macOS mouse coordinates with the captured display
The macOS client derived its logical screen size from [NSScreen mainScreen] while it captured CGMainDisplayID. In clamshell mode with an external display the former can still report the disabled built-in panel (1470x956) while the captured frame is 1280x1024, so every injected point was scaled by logical/encode and drifted linearly with the distance from the top left corner, independently on each axis. Take the logical size from CGDisplayBounds of the captured display instead, and report the same bounds in the login resolution. For hosts that still run the old client, the remote desktop dialog gains a per-host mouse calibration in its system menu. The factors are stored by client ID together with the reported resolution and the captured frame size, so they stop applying once the client is upgraded or a different display is captured, and come back automatically when the original display returns. When no calibration has been saved the dialog pre-fills the factors from frame/reported, but only for macOS clients, because the other clients derive their conversion from the captured display itself and a mismatching report there would be misleading. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
38cd207f5d
commit
3ae6298746
7 files changed
+250
-12
No files matched your search
+7
-4
@@ -271,11 +271,14 @@ static std::string normalizeExePathLower(const std::string& path)
|
||||
// Get screen resolution
|
||||
static std::string getScreenResolution()
|
||||
{
|
||||
NSScreen* mainScreen = [NSScreen mainScreen];
|
||||
if (mainScreen) {
|
||||
NSRect frame = [mainScreen frame];
|
||||
// 用主显示器的全局显示坐标(points),与 CGEvent 注入坐标同一空间,也和
|
||||
// ScreenHandler 抓屏所用的 CGMainDisplayID 保持一致。
|
||||
// [NSScreen mainScreen] 在合盖接外置显示器时仍可能返回内置屏(如 1470x956),
|
||||
// 上报后会让服务端以为主机分辨率是内置屏尺寸。
|
||||
CGRect bounds = CGDisplayBounds(CGMainDisplayID());
|
||||
if (bounds.size.width > 0 && bounds.size.height > 0) {
|
||||
return [NSString stringWithFormat:@"1:%dx%d",
|
||||
(int)frame.size.width, (int)frame.size.height].UTF8String;
|
||||
(int)(bounds.size.width + 0.5), (int)(bounds.size.height + 0.5)].UTF8String;
|
||||
}
|
||||
return "0:0x0";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user