diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2011-02-18 19:22:48 +0100 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2011-03-31 13:34:28 +0200 |
commit | 40396a5a88de0e9f17cf708c2755ec7f049587ac (patch) | |
tree | f41f5cbd20ade10c763f81f904527dc97121166c | |
parent | c7c55c7162e9934823566cfdc716f56f64a82fd6 (diff) | |
download | vd_agent-40396a5a88de0e9f17cf708c2755ec7f049587ac.tar.gz vd_agent-40396a5a88de0e9f17cf708c2755ec7f049587ac.tar.xz vd_agent-40396a5a88de0e9f17cf708c2755ec7f049587ac.zip |
x11: add a few helper functions for multi-clipboard
https://bugs.freedesktop.org/show_bug.cgi?id=34878
-rw-r--r-- | vdagent-x11.c | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/vdagent-x11.c b/vdagent-x11.c index a0bdeb6..728568c 100644 --- a/vdagent-x11.c +++ b/vdagent-x11.c @@ -258,7 +258,7 @@ static void vdagent_x11_set_clipboard_owner(struct vdagent_x11 *x11, if (x11->selection_request) { fprintf(x11->errfile, "selection requests pending on clipboard ownership change, " - "clearing"); + "clearing\n"); while (x11->selection_request) { vdagent_x11_send_selection_notify(x11, None, 0); vdagent_x11_next_selection_request(x11); @@ -267,7 +267,7 @@ static void vdagent_x11_set_clipboard_owner(struct vdagent_x11 *x11, if (x11->clipboard_request_target != None) { fprintf(x11->errfile, "client clipboard request pending on clipboard ownership " - "change, clearing"); + "change, clearing\n"); udscs_write(x11->vdagentd, VDAGENTD_CLIPBOARD_DATA, VD_AGENT_CLIPBOARD_NONE, NULL, 0); x11->clipboard_request_target = None; @@ -286,6 +286,49 @@ static void vdagent_x11_set_clipboard_owner(struct vdagent_x11 *x11, x11->clipboard_owner = new_owner; } +static int vdagent_x11_get_clipboard_atom(struct vdagent_x11 *x11, uint8_t selection, Atom* clipboard) +{ + if (selection == VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD) { + *clipboard = x11->clipboard_atom; + } else if (selection == VD_AGENT_CLIPBOARD_SELECTION_PRIMARY) { + *clipboard = x11->clipboard_primary_atom; + } else { + fprintf(x11->errfile, "selection_get_grab: unknown selection\n"); + return -1; + } + + return 0; +} + +static int vdagent_x11_get_clipboard_selection(struct vdagent_x11 *x11, + XEvent *event, uint8_t *selection) +{ + Atom atom; + + if (event->type == x11->xfixes_event_base) { + XFixesSelectionNotifyEvent *xfev = (XFixesSelectionNotifyEvent *)event; + atom = xfev->selection; + } else if (event->type == SelectionNotify) { + atom = event->xselection.selection; + } else if (event->type == SelectionRequest) { + atom = event->xselectionrequest.selection; + } else { + fprintf(x11->errfile, "get_clipboard_selection: unknown event type\n"); + return -1; + } + + if (atom == x11->clipboard_atom) { + *selection = VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD; + } else if (atom == x11->clipboard_primary_atom) { + *selection = VD_AGENT_CLIPBOARD_SELECTION_PRIMARY; + } else { + fprintf(x11->errfile, "get_clipboard_selection: unknown selection\n"); + return -1; + } + + return 0; +} + static void vdagent_x11_handle_event(struct vdagent_x11 *x11, XEvent event) { int handled = 0; |