Commit 7d068370 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Clipboard.c: introduce SendSelectionNotifyEventToClient helper

parent c233eec5
...@@ -406,6 +406,27 @@ int SendEventToClient(ClientPtr client, xEvent *pEvents) ...@@ -406,6 +406,27 @@ int SendEventToClient(ClientPtr client, xEvent *pEvents)
return TryClientEvents (client, pEvents, 1, NoEventMask, NoEventMask, NullGrab); return TryClientEvents (client, pEvents, 1, NoEventMask, NoEventMask, NullGrab);
} }
int SendSelectionNotifyEventToClient(ClientPtr client,
Time time,
Window requestor,
Atom selection,
Atom target,
Atom property)
{
#ifdef DEBUG
fprintf (stderr, "%s: Sending event to client [%d].\n", __func__, client -> index);
#endif
xEvent x = {0};
x.u.u.type = SelectionNotify;
x.u.selectionNotify.time = time;
x.u.selectionNotify.requestor = requestor;
x.u.selectionNotify.selection = selection;
x.u.selectionNotify.target = target;
x.u.selectionNotify.property = property;
return SendEventToClient(client, &x);
}
Bool nxagentValidServerTargets(Atom target) Bool nxagentValidServerTargets(Atom target)
{ {
if (target == XA_STRING) if (target == XA_STRING)
...@@ -726,26 +747,12 @@ void nxagentSendSelectionNotify(Atom property) ...@@ -726,26 +747,12 @@ void nxagentSendSelectionNotify(Atom property)
return; return;
} }
xEvent x; SendSelectionNotifyEventToClient(lastClientClientPtr,
lastClientTime,
#ifdef DEBUG lastClientRequestor,
fprintf (stderr, "%s: Sending event to client [%d].\n", __func__, lastClientSelection,
lastClientClientPtr -> index); lastClientTarget,
#endif property);
memset(&x, 0, sizeof(xEvent));
x.u.u.type = SelectionNotify;
x.u.selectionNotify.time = lastClientTime;
x.u.selectionNotify.requestor = lastClientRequestor;
x.u.selectionNotify.selection = lastClientSelection;
x.u.selectionNotify.target = lastClientTarget;
x.u.selectionNotify.property = property;
SendEventToClient(lastClientClientPtr, &x);
return;
} }
/* /*
...@@ -1392,8 +1399,6 @@ FIXME ...@@ -1392,8 +1399,6 @@ FIXME
void nxagentNotifyConvertFailure(ClientPtr client, Window requestor, void nxagentNotifyConvertFailure(ClientPtr client, Window requestor,
Atom selection, Atom target, Time time) Atom selection, Atom target, Time time)
{ {
xEvent x;
/* /*
FIXME: Why this pointer can be not a valid FIXME: Why this pointer can be not a valid
client pointer? client pointer?
...@@ -1407,15 +1412,7 @@ FIXME: Why this pointer can be not a valid ...@@ -1407,15 +1412,7 @@ FIXME: Why this pointer can be not a valid
return; return;
} }
memset(&x, 0, sizeof(xEvent)); SendSelectionNotifyEventToClient(client, time, requestor, selection, target, None);
x.u.u.type = SelectionNotify;
x.u.selectionNotify.time = time;
x.u.selectionNotify.requestor = requestor;
x.u.selectionNotify.selection = selection;
x.u.selectionNotify.target = target;
x.u.selectionNotify.property = None;
SendEventToClient(client, &x);
} }
int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
...@@ -1496,7 +1493,6 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1496,7 +1493,6 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
if (target == clientTARGETS) if (target == clientTARGETS)
{ {
Atom xa_STRING[4]; Atom xa_STRING[4];
xEvent x;
/* --- Order changed by dimbor (prevent sending COMPOUND_TEXT to client --- */ /* --- Order changed by dimbor (prevent sending COMPOUND_TEXT to client --- */
xa_STRING[0] = XA_STRING; xa_STRING[0] = XA_STRING;
...@@ -1512,15 +1508,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1512,15 +1508,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
4, 4,
&xa_STRING, 1); &xa_STRING, 1);
memset(&x, 0, sizeof(xEvent)); SendSelectionNotifyEventToClient(client, time, requestor, selection, target, property);
x.u.u.type = SelectionNotify;
x.u.selectionNotify.time = time;
x.u.selectionNotify.requestor = requestor;
x.u.selectionNotify.selection = selection;
x.u.selectionNotify.target = target;
x.u.selectionNotify.property = property;
SendEventToClient(client, &x);
return 1; return 1;
} }
...@@ -1534,7 +1522,6 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1534,7 +1522,6 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
if (i < NumCurrentSelections) if (i < NumCurrentSelections)
{ {
xEvent x;
ChangeWindowProperty(pWin, ChangeWindowProperty(pWin,
property, property,
target, target,
...@@ -1544,18 +1531,9 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1544,18 +1531,9 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
(unsigned char *) &lastSelectionOwner[i].lastTimeChanged, (unsigned char *) &lastSelectionOwner[i].lastTimeChanged,
1); 1);
memset(&x, 0, sizeof(xEvent)); SendSelectionNotifyEventToClient(client, time, requestor, selection, target, property);
x.u.u.type = SelectionNotify;
x.u.selectionNotify.time = time;
x.u.selectionNotify.requestor = requestor;
x.u.selectionNotify.selection = selection;
x.u.selectionNotify.target = target;
x.u.selectionNotify.property = property;
SendEventToClient(client, &x);
return 1; return 1;
} }
} }
...@@ -1625,21 +1603,13 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1625,21 +1603,13 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
} }
else else
{ {
xEvent x;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "%s: Xserver generates a SelectionNotify event " fprintf(stderr, "%s: Xserver generates a SelectionNotify event "
"to the requestor with property None.\n", __func__); "to the requestor with property None.\n", __func__);
#endif #endif
memset(&x, 0, sizeof(xEvent)); SendSelectionNotifyEventToClient(client, time, requestor, selection, target, None);
x.u.u.type = SelectionNotify;
x.u.selectionNotify.time = time;
x.u.selectionNotify.requestor = requestor;
x.u.selectionNotify.selection = selection;
x.u.selectionNotify.target = target;
x.u.selectionNotify.property = None;
SendEventToClient(client, &x);
return 1; return 1;
} }
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment