From: Pierre Ossman Date: Wed, 13 Jan 2016 10:25:40 +0000 (+0100) Subject: Create all Atoms in a central place X-Git-Tag: v1.7.90~102^2~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e4be5cc09850b3e606f9315334b0253467e66655;p=tigervnc.git Create all Atoms in a central place --- diff --git a/unix/xserver/hw/vnc/vncSelection.c b/unix/xserver/hw/vnc/vncSelection.c index 263dbeca..b4a58e38 100644 --- a/unix/xserver/hw/vnc/vncSelection.c +++ b/unix/xserver/hw/vnc/vncSelection.c @@ -41,6 +41,9 @@ #define LOG_INFO(...) vncLogInfo(LOG_NAME, __VA_ARGS__) #define LOG_DEBUG(...) vncLogDebug(LOG_NAME, __VA_ARGS__) +static Atom xaPRIMARY, xaCLIPBOARD; +static Atom xaTARGETS, xaTIMESTAMP, xaSTRING, xaTEXT; + static WindowPtr pWindow; static Window wid; @@ -59,6 +62,14 @@ static int (*origProcSendEvent)(ClientPtr); void vncSelectionInit(void) { + xaPRIMARY = MakeAtom("PRIMARY", 7, TRUE); + xaCLIPBOARD = MakeAtom("CLIPBOARD", 9, TRUE); + + xaTARGETS = MakeAtom("TARGETS", 7, TRUE); + xaTIMESTAMP = MakeAtom("TIMESTAMP", 9, TRUE); + xaSTRING = MakeAtom("STRING", 6, TRUE); + xaTEXT = MakeAtom("TEXT", 4, TRUE); + /* There are no hooks for when these are internal windows, so * override the relevant handlers. */ origProcConvertSelection = ProcVector[X_ConvertSelection]; @@ -87,10 +98,10 @@ void vncClientCutText(const char* str, int len) memcpy(clientCutText, str, len); clientCutTextLen = len; - rc = vncOwnSelection(MakeAtom("PRIMARY", 7, TRUE)); + rc = vncOwnSelection(xaPRIMARY); if (rc != Success) LOG_ERROR("Could not set PRIMARY selection"); - vncOwnSelection(MakeAtom("CLIPBOARD", 9, TRUE)); + vncOwnSelection(xaCLIPBOARD); if (rc != Success) LOG_ERROR("Could not set CLIPBOARD selection"); } @@ -186,7 +197,6 @@ static int vncConvertSelection(ClientPtr client, Atom selection, WindowPtr pWin; int rc; - Atom xaTARGETS, xaTIMESTAMP, xaSTRING, xaTEXT; Atom realProperty; xEvent event; @@ -212,11 +222,6 @@ static int vncConvertSelection(ClientPtr client, Atom selection, /* FIXME: MULTIPLE target */ - xaTARGETS = MakeAtom("TARGETS", 7, TRUE); - xaTIMESTAMP = MakeAtom("TIMESTAMP", 9, TRUE); - xaSTRING = MakeAtom("STRING", 6, TRUE); - xaTEXT = MakeAtom("TEXT", 4, TRUE); - if (target == xaTARGETS) { Atom targets[] = { xaTARGETS, xaTIMESTAMP, xaSTRING, xaTEXT }; @@ -305,7 +310,6 @@ static void vncHandleSelection(Atom selection, Atom target, Atom property, Atom requestor, TimeStamp time) { - Atom xaSTRING; PropertyPtr prop; int rc; @@ -313,8 +317,6 @@ static void vncHandleSelection(Atom selection, Atom target, NameForAtom(selection), NameForAtom(target), NameForAtom(property)); - xaSTRING = MakeAtom("STRING", 6, TRUE); - if (target != xaSTRING) return; if (property != xaSTRING) @@ -361,7 +363,6 @@ static void vncSelectionCallback(CallbackListPtr *callbacks, { SelectionInfoRec *info = (SelectionInfoRec *) args; - Atom xaPRIMARY, xaCLIPBOARD, xaSTRING; xEvent event; int rc; @@ -370,9 +371,6 @@ static void vncSelectionCallback(CallbackListPtr *callbacks, if (info->client == serverClient) return; - xaPRIMARY = MakeAtom("PRIMARY", 7, TRUE); - xaCLIPBOARD = MakeAtom("CLIPBOARD", 9, TRUE); - if ((info->selection->selection != xaPRIMARY) && (info->selection->selection != xaCLIPBOARD)) return; @@ -388,8 +386,6 @@ static void vncSelectionCallback(CallbackListPtr *callbacks, LOG_DEBUG("Requesting %s selection", NameForAtom(info->selection->selection)); - xaSTRING = MakeAtom("STRING", 6, TRUE); - event.u.u.type = SelectionRequest; event.u.selectionRequest.owner = info->selection->window; event.u.selectionRequest.time = currentTime.milliseconds;