-
-
Notifications
You must be signed in to change notification settings - Fork 54
Allow shortcut for multiple use of clipboard data #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -976,7 +976,7 @@ static Time get_clipboard_xevent_timestamp(bool logging) { | |
|
|
||
| /* fetch clippboard content from file */ | ||
| /* lock already taken in is_special_keypress() */ | ||
| static void get_qubes_clipboard(Ghandles *g, char **data, int *len) | ||
| static void get_qubes_clipboard(Ghandles *g, char **data, int *len, bool multipaste) | ||
| { | ||
| FILE *file; | ||
| *len = 0; | ||
|
|
@@ -1041,7 +1041,16 @@ static void get_qubes_clipboard(Ghandles *g, char **data, int *len) | |
| fclose(file); | ||
| metadata.sent_size = *len; | ||
| metadata.successful = true; | ||
| clear_clipboard(&metadata); | ||
| if (multipaste) { | ||
| // triggering notification by updating file modification time | ||
| if (utimensat(0, QUBES_CLIPBOARD_FILENAME, NULL, 0) == -1) { | ||
| show_error_message(g, "secure multi-paste: failed to update modification time of file " QUBES_CLIPBOARD_FILENAME); | ||
| } else { | ||
| metadata.cleared = false; | ||
| save_clipboard_metadata(&metadata); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be quite confusing IMO. Here, you save metadata as after paste operation (paste_action=1), but later this will use it as after copy operation for another paste. The confusion is especially about "vmname" field, as it no longer matches the source of the current clipboard content. As it's written right now, it incidentally works, because you gui-daemon still uses the separate "source" file for policy evaluation, but it's very easy to miss this subtle difference (for example if gui-daemon or something else would be modified to use metadata file for the source vm information when pasting). Maybe for multipaste it should leave most of the metadata unchanged (just update xevent_timestamp)? Or do not reuse "vmname" field for the name where the clipboard was pasted and instead add a new field for that (used also for paste+wipe)? The latter will potentially allow even more informative notification, as you'll have both source and target name at the same time. As for copy_action / paste_action fields, I'm not sure how multi-paste should handle them. One of the options is to set both to true in this case. But I guess if properly documented, copy_action=false, paste_action=true may also work (together with cleared=false) may also work. Or even change this to a single "last_action" field? Anyway, it would be good to write down somewhere (extend QubesOS/qubes-doc#1434? or a comment in xside.h?) all possible states, and what values different fields may have at that time and what do they mean. And also specify which fields may be missing and how to interpret it (see below). IIUC there are the following states:
Right now I see for example that copy made by gui-daemon and by qui-clipboard widgets result in a different metadata files (widget doesn't set "oversized_request"). This may be okay if we have documentation what that means (in this case, that it should be interpreted as oversized_request=false). |
||
| } | ||
| } else | ||
| clear_clipboard(&metadata); | ||
| } | ||
|
|
||
| /* This is specific to Microsoft Windows and non-X11 compliant OS */ | ||
|
|
@@ -1513,8 +1522,13 @@ static int is_special_keypress(Ghandles * g, const XKeyEvent * ev, XID remote_wi | |
| } | ||
|
|
||
| /* paste */ | ||
| if (((int)ev->state & SPECIAL_KEYS_MASK) == g->paste_seq_mask | ||
| && ev->keycode == XKeysymToKeycode(g->display, g->paste_seq_key)) { | ||
| bool multipaste = false; | ||
| if (((int)ev->state & SPECIAL_KEYS_MASK) == g->multipaste_seq_mask | ||
| && ev->keycode == XKeysymToKeycode(g->display, g->multipaste_seq_key)) { | ||
| multipaste = true; | ||
| } | ||
| if (multipaste || (((int)ev->state & SPECIAL_KEYS_MASK) == g->paste_seq_mask | ||
| && ev->keycode == XKeysymToKeycode(g->display, g->paste_seq_key))) { | ||
| if (ev->type != KeyPress) | ||
| return 1; | ||
| inter_appviewer_lock(g, 1); | ||
|
|
@@ -1541,7 +1555,7 @@ static int is_special_keypress(Ghandles * g, const XKeyEvent * ev, XID remote_wi | |
| hdr.type = MSG_CLIPBOARD_DATA; | ||
| if (g->log_level > 0) | ||
| fprintf(stderr, "secure paste\n"); | ||
| get_qubes_clipboard(g, &data, &len); | ||
| get_qubes_clipboard(g, &data, &len, multipaste); | ||
| if (len > 0) { | ||
| /* MSG_CLIPBOARD_DATA used to use the window field to pass the length | ||
| of the blob, be aware when working with old implementations. */ | ||
|
|
@@ -4345,6 +4359,8 @@ static void load_default_config_values(Ghandles * g) | |
| g->copy_seq_key = XK_c; | ||
| g->paste_seq_mask = ControlMask | ShiftMask; | ||
| g->paste_seq_key = XK_v; | ||
| g->multipaste_seq_mask = 0; | ||
| g->multipaste_seq_key = NoSymbol; | ||
| g->clipboard_buffer_size = DEFAULT_CLIPBOARD_BUFFER_SIZE; | ||
| g->allow_fullscreen = 0; | ||
| g->override_redirect_protection = 1; | ||
|
|
@@ -4416,6 +4432,11 @@ static void parse_vm_config(Ghandles * g, config_setting_t * group) | |
| parse_key_sequence(config_setting_get_string(setting), | ||
| &g->paste_seq_mask, &g->paste_seq_key); | ||
| } | ||
| if ((setting = | ||
| config_setting_get_member(group, "secure_multipaste_sequence"))) { | ||
| parse_key_sequence(config_setting_get_string(setting), | ||
| &g->multipaste_seq_mask, &g->multipaste_seq_key); | ||
| } | ||
|
|
||
| if ((setting = | ||
| config_setting_get_member(group, "max_clipboard_size"))) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.