feat(ui): cross-platform screenshot hotkey and portal-based capture

Windows keeps the legacy path; Linux X11 uses a native XGrabKey hotkey (ctypes libX11) with native capture; Wayland captures through xdg-desktop-portal and degrades gracefully with explicit capability-unavailable logs when the portal/protocol is missing.
This commit is contained in:
2026-09-17 16:40:05 +08:00
parent 95024785ae
commit 0a62877cde
6 changed files with 1014 additions and 0 deletions
+7
View File
@@ -60,8 +60,15 @@ class ScreenCaptureOverlay(QtWidgets.QWidget):
"""开始截图:抓取屏幕全图并显示覆盖层"""
screen = QtWidgets.QApplication.primaryScreen()
if not screen:
print("[Screenshot] 无主屏幕 → 截图不可用", flush=True)
return
self._full_pixmap = screen.grabWindow(0)
# P1-04X11 某些 compositor/环境下 grabWindow 可能拿到空图(Wayland 已改走 portal
if self._full_pixmap is None or self._full_pixmap.isNull() or self._full_pixmap.width() == 0:
print("[Screenshot] 屏幕抓取返回空画面(当前 compositor/环境限制)→ 本次截图取消;"
"聊天与其他功能不受影响", flush=True)
self._full_pixmap = None
return
self.setGeometry(screen.geometry())
self.show()
self.activateWindow()