mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-05-30 21:38:03 -04:00
osc: implement OSC-5522, kitty's extended version of OSC-52
OSC-5522[^1] gives the terminal application access to all offered mime-types when reading the clipboard, and allows setting multiple mime-types when writing to the clipboard (with different contents, if it so wishes). In addition to the base protocol, we also implement the _event extension_[^2], where a paste action (e.g. ctrl+shift+v) results in an unsolicited mime-type listing being sent to the terminal application (as if it had issued a mime-type query itself), instead of the clipboard content being pasted directly. The application follows up with an explicit read request (or chooses to ignore the event). The protocol supports "passwords", as a way of bypassing terminal popups asking the user for approval, after the first popup has been approved by the user. Foot doesn't implement this kind of user approval, but all read and write requests are denied with EPERM if the user has disabled OSC copy/pasting with the security.osc52 configuration option. In addition, if disabled, event reporting cannot be enabled at all (i.e. 'CSI ? 5522 h' is ignored). [^1]: https://sw.kovidgoyal.net/kitty/clipboard/ [^2]: https://rockorager.dev/misc/bracketed-paste-mime/
This commit is contained in:
parent
4bc8a39d6c
commit
c366e322eb
13 changed files with 839 additions and 126 deletions
36
wayland.h
36
wayland.h
|
|
@ -51,6 +51,8 @@ enum data_offer_mime_type {
|
|||
DATA_OFFER_MIME_TEXT_TEXT,
|
||||
DATA_OFFER_MIME_TEXT_STRING,
|
||||
DATA_OFFER_MIME_TEXT_UTF8_STRING,
|
||||
|
||||
DATA_OFFER_MIME_TYPE_CUSTOM,
|
||||
};
|
||||
|
||||
enum touch_state {
|
||||
|
|
@ -76,22 +78,52 @@ struct wayl_sub_surface {
|
|||
struct wl_subsurface *sub;
|
||||
};
|
||||
|
||||
typedef tll(char *) mime_list_t;
|
||||
struct mime_data_map {
|
||||
char *mime_type;
|
||||
size_t data_idx;
|
||||
};
|
||||
|
||||
/* OSC-5522: kitty's extended OSC-52, with explicit mime-type support */
|
||||
struct kitty_clipboard_offer {
|
||||
/*
|
||||
* - data[] is an array of contents
|
||||
* - data_len[] is an array of the same size as data[], each element
|
||||
* denoting the size of the corresponding data[] element
|
||||
* - mime_data_map[] is an array mapping mime-types to an entry in data[]
|
||||
*/
|
||||
uint8_t **data;
|
||||
size_t *data_len;
|
||||
size_t data_count;
|
||||
|
||||
struct mime_data_map *mime_data_map;
|
||||
size_t mime_data_map_count;
|
||||
};
|
||||
|
||||
|
||||
struct wl_window;
|
||||
struct wl_clipboard {
|
||||
struct wl_window *window; /* For DnD */
|
||||
struct wl_data_source *data_source;
|
||||
struct wl_data_offer *data_offer;
|
||||
enum data_offer_mime_type mime_type;
|
||||
enum data_offer_mime_type mime_type; /* Preferred mime-type */
|
||||
mime_list_t all_mime_types; /* List of all offered mime-types (for OSC-5522) */
|
||||
char *text;
|
||||
uint32_t serial;
|
||||
|
||||
struct kitty_clipboard_offer kitty;
|
||||
};
|
||||
|
||||
struct wl_primary {
|
||||
struct zwp_primary_selection_source_v1 *data_source;
|
||||
struct zwp_primary_selection_offer_v1 *data_offer;
|
||||
enum data_offer_mime_type mime_type;
|
||||
enum data_offer_mime_type mime_type; /* Preferred mime-type */
|
||||
mime_list_t all_mime_types; /* List of all offered mime-types (for OSC-5522) */
|
||||
|
||||
char *text;
|
||||
uint32_t serial;
|
||||
|
||||
struct kitty_clipboard_offer kitty;
|
||||
};
|
||||
|
||||
/* Maps a mouse button to its "owning" surface */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue