Agent-Hellboy / Agent-Hellboy/hcp

Add support for Wayland display server

未关闭
#17 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C++
星标
9
派生
0
PR 合并指标
30 天内没有已合并 PR

描述

## Background

Our clipboard manager currently uses **X11 APIs** to poll clipboard content and store history. However, modern Linux distros like **Ubuntu 25.10+** are transitioning to **Wayland-only sessions**, where:

- Background clipboard access is **not allowed**
- All access must go through **`xdg-desktop-portal`** via **D-Bus**
- User permission is required to read clipboard data

## Goal

Enable Wayland-compatible clipboard history support using `xdg-desktop-portal` with a **one-time permission grant** flow (`hcp permission`), then run **automatic background saves** on each clipboard change until logout/reboot.

## Tasks

- [ ] Detect current session type via `$XDG_SESSION_TYPE`
- [ ] Continue existing X11 polling logic when in an `x11` session
- [ ] In `wayland` sessions:
- [ ] Implement `hcp permission` subcommand to call `org.freedesktop.portal.Clipboard` → triggers user’s consent dialog
- [ ] Cache returned `handle_token` for the login session
- [ ] Subscribe to `SelectionOwnerChanged` signals over D-Bus
- [ ] On each signal, call `SelectionRead` to fetch new clipboard data and append to history
- [ ] Provide clear fallback messaging if portal access is denied or unavailable

## Clipboard Access Flow on Wayland

```text
[Your App] [xdg-desktop-portal]
│ │
│ ClaimClipboard (hcp permission) │
├─────────────────────────────────────────▶│
│ permission dialog pops
│◀─────────────────────────────────────────┤
│ handle_token returned │
│ │
│ SelectionOwnerChanged signal │
├─────────────────────────────────────────▶│
│ │
│ SelectionRead request │
├─────────────────────────────────────────▶│
│ clipboard data │
◀─────────────────────────────────────────┤
│ │
Save to history │
```

## Clipboard Access Flow on Wayland

```text
[Your App]

│ D-Bus Request (e.g., GetClipboard)

[xdg-desktop-portal] <-- MAIN PORTAL SERVICE

├──> Talks to GNOME: `xdg-desktop-portal-gtk`
├──> Talks to KDE: `xdg-desktop-portal-kde`
└──> Talks to other backends (Wlroots, Flatpak, etc.)
```

## Permission Popup Flow

```text
User hits Ctrl+C

[Your App detects event or uses tray menu]

Show popup: "Allow clipboard manager to access clipboard content?"

If user clicks "Allow"

Make D-Bus call to `xdg-desktop-portal`

Save content to clipboard history
```

> Wayland does not permit global key interception for background apps. A manual tray icon or user-triggered button may be required as an alternative to capture clipboard updates.

## Suggested Popup Implementation

Use the `org.freedesktop.Notifications` D-Bus interface to show system-wide notifications:

- Display permission request with buttons (e.g., “Allow” / “Deny”)
- Handle `ActionInvoked` signal to know which button user clicked
- Continue only if user grants permission

For more control, full GUI dialogs (via GTK or Qt) can be used if a GUI is available.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。