diff options
author | Pierre Ossman <ossman@cendio.se> | 2016-01-13 11:32:43 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2016-02-05 10:35:22 +0100 |
commit | 0a0abdf95b3cee1f7c407a4c00a7c4909073b8aa (patch) | |
tree | fe24067adca2d10543ab7c1a8b18514599968aab | |
parent | e4be5cc09850b3e606f9315334b0253467e66655 (diff) | |
download | tigervnc-0a0abdf95b3cee1f7c407a4c00a7c4909073b8aa.tar.gz tigervnc-0a0abdf95b3cee1f7c407a4c00a7c4909073b8aa.zip |
Move selection request handling to a separate function
Makes it easier to do requests from different parts of the code.
-rw-r--r-- | unix/xserver/hw/vnc/vncSelection.c | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/unix/xserver/hw/vnc/vncSelection.c b/unix/xserver/hw/vnc/vncSelection.c index b4a58e38..26bee3d1 100644 --- a/unix/xserver/hw/vnc/vncSelection.c +++ b/unix/xserver/hw/vnc/vncSelection.c @@ -306,6 +306,33 @@ static int vncProcConvertSelection(ClientPtr client) return origProcConvertSelection(client); } +static void vncSelectionRequest(Atom selection, Atom target) +{ + Selection *pSel; + xEvent event; + int rc; + + rc = vncCreateSelectionWindow(); + if (rc != Success) + return; + + LOG_DEBUG("Requesting %s for %s selection", + NameForAtom(target), NameForAtom(selection)); + + rc = dixLookupSelection(&pSel, selection, serverClient, DixGetAttrAccess); + if (rc != Success) + return; + + event.u.u.type = SelectionRequest; + event.u.selectionRequest.owner = pSel->window; + event.u.selectionRequest.time = currentTime.milliseconds; + event.u.selectionRequest.requestor = wid; + event.u.selectionRequest.selection = selection; + event.u.selectionRequest.target = target; + event.u.selectionRequest.property = target; + WriteEventsToClient(pSel->client, 1, &event); +} + static void vncHandleSelection(Atom selection, Atom target, Atom property, Atom requestor, TimeStamp time) @@ -363,9 +390,6 @@ static void vncSelectionCallback(CallbackListPtr *callbacks, { SelectionInfoRec *info = (SelectionInfoRec *) args; - xEvent event; - int rc; - if (info->kind != SelectionSetOwner) return; if (info->client == serverClient) @@ -379,19 +403,5 @@ static void vncSelectionCallback(CallbackListPtr *callbacks, !vncGetSendPrimary()) return; - rc = vncCreateSelectionWindow(); - if (rc != Success) - return; - - LOG_DEBUG("Requesting %s selection", - NameForAtom(info->selection->selection)); - - event.u.u.type = SelectionRequest; - event.u.selectionRequest.owner = info->selection->window; - event.u.selectionRequest.time = currentTime.milliseconds; - event.u.selectionRequest.requestor = wid; - event.u.selectionRequest.selection = info->selection->selection; - event.u.selectionRequest.target = xaSTRING; - event.u.selectionRequest.property = xaSTRING; - WriteEventsToClient(info->client, 1, &event); + vncSelectionRequest(info->selection->selection, xaSTRING); } |