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

Clipboard: align reported targets

Always report the same list of available targets to internal and external requests.
parent 509ae051
...@@ -91,6 +91,7 @@ static char *nxagentAtomNames[NXAGENT_NUMBER_OF_ATOMS + 1] = ...@@ -91,6 +91,7 @@ static char *nxagentAtomNames[NXAGENT_NUMBER_OF_ATOMS + 1] =
"_NET_WM_STATE", /* 13 */ "_NET_WM_STATE", /* 13 */
"_NET_WM_STATE_FULLSCREEN", /* 14 */ "_NET_WM_STATE_FULLSCREEN", /* 14 */
"NX_CUT_BUFFER_CLIENT", /* 15 */ "NX_CUT_BUFFER_CLIENT", /* 15 */
"COMPOUND_TEXT", /* 16 */
NULL, NULL,
NULL NULL
}; };
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "../../include/window.h" #include "../../include/window.h"
#include "screenint.h" #include "screenint.h"
#define NXAGENT_NUMBER_OF_ATOMS 17 #define NXAGENT_NUMBER_OF_ATOMS 18
extern Atom nxagentAtoms[NXAGENT_NUMBER_OF_ATOMS]; extern Atom nxagentAtoms[NXAGENT_NUMBER_OF_ATOMS];
......
...@@ -133,15 +133,18 @@ static Time lastServerTime; ...@@ -133,15 +133,18 @@ static Time lastServerTime;
static XlibAtom serverTARGETS; static XlibAtom serverTARGETS;
static XlibAtom serverTIMESTAMP; static XlibAtom serverTIMESTAMP;
static XlibAtom serverTEXT; static XlibAtom serverTEXT;
static XlibAtom serverCOMPOUND_TEXT;
static XlibAtom serverUTF8_STRING; static XlibAtom serverUTF8_STRING;
static XlibAtom serverClientCutProperty; static XlibAtom serverClientCutProperty;
static Atom clientTARGETS; static Atom clientTARGETS;
static Atom clientTIMESTAMP;
static Atom clientTEXT; static Atom clientTEXT;
static Atom clientCOMPOUND_TEXT; static Atom clientCOMPOUND_TEXT;
static Atom clientUTF8_STRING; static Atom clientUTF8_STRING;
static char szAgentTARGETS[] = "TARGETS"; static char szAgentTARGETS[] = "TARGETS";
static char szAgentTEXT[] = "TEXT"; static char szAgentTEXT[] = "TEXT";
static char szAgentTIMESTAMP[] = "TIMESTAMP";
static char szAgentCOMPOUND_TEXT[] = "COMPOUND_TEXT"; static char szAgentCOMPOUND_TEXT[] = "COMPOUND_TEXT";
static char szAgentUTF8_STRING[] = "UTF8_STRING"; static char szAgentUTF8_STRING[] = "UTF8_STRING";
static char szAgentNX_CUT_BUFFER_CLIENT[] = "NX_CUT_BUFFER_CLIENT"; static char szAgentNX_CUT_BUFFER_CLIENT[] = "NX_CUT_BUFFER_CLIENT";
...@@ -354,6 +357,8 @@ void nxagentPrintClipboardStat(char *header) ...@@ -354,6 +357,8 @@ void nxagentPrintClipboardStat(char *header)
fprintf(stderr, " serverTARGETS [% 4d][%s]\n", serverTARGETS, validateString(s)); fprintf(stderr, " serverTARGETS [% 4d][%s]\n", serverTARGETS, validateString(s));
SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverTEXT); SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverTEXT);
fprintf(stderr, " serverTEXT [% d][%s]\n", serverTEXT, s); fprintf(stderr, " serverTEXT [% d][%s]\n", serverTEXT, s);
SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverCOMPOUND_TEXT);
fprintf(stderr, " serverCOMPOUND_TEXT [% d][%s]\n", serverCOMPOUND_TEXT, s);
SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverUTF8_STRING); SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverUTF8_STRING);
fprintf(stderr, " serverUTF8_STRING [% 4d][%s]\n", serverUTF8_STRING, s); fprintf(stderr, " serverUTF8_STRING [% 4d][%s]\n", serverUTF8_STRING, s);
SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverCutProperty); SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverCutProperty);
...@@ -366,6 +371,7 @@ void nxagentPrintClipboardStat(char *header) ...@@ -366,6 +371,7 @@ void nxagentPrintClipboardStat(char *header)
fprintf(stderr, "Atoms (inside nxagent)\n"); fprintf(stderr, "Atoms (inside nxagent)\n");
fprintf(stderr, " clientTARGETS [% 4d][%s]\n", clientTARGETS, NameForAtom(clientTARGETS)); fprintf(stderr, " clientTARGETS [% 4d][%s]\n", clientTARGETS, NameForAtom(clientTARGETS));
fprintf(stderr, " clientTIMESTAMP [% 4d][%s]\n", clientTIMESTAMP, NameForAtom(clientTIMESTAMP));
fprintf(stderr, " clientTEXT [% 4d][%s]\n", clientTEXT, NameForAtom(clientTEXT)); fprintf(stderr, " clientTEXT [% 4d][%s]\n", clientTEXT, NameForAtom(clientTEXT));
fprintf(stderr, " clientCOMPOUND_TEXT [% 4d][%s]\n", clientCOMPOUND_TEXT, NameForAtom(clientCOMPOUND_TEXT)); fprintf(stderr, " clientCOMPOUND_TEXT [% 4d][%s]\n", clientCOMPOUND_TEXT, NameForAtom(clientCOMPOUND_TEXT));
fprintf(stderr, " clientUTF8_STRING [% 4d][%s]\n", clientUTF8_STRING, NameForAtom(clientUTF8_STRING)); fprintf(stderr, " clientUTF8_STRING [% 4d][%s]\n", clientUTF8_STRING, NameForAtom(clientUTF8_STRING));
...@@ -490,6 +496,13 @@ Bool nxagentValidServerTargets(XlibAtom target) ...@@ -490,6 +496,13 @@ Bool nxagentValidServerTargets(XlibAtom target)
#endif #endif
return True; return True;
} }
else if (target == serverCOMPOUND_TEXT)
{
#ifdef DEBUG
fprintf(stderr, "%s: valid target [COMPOUND_TEXT].\n", __func__);
#endif
return True;
}
else if (target == serverTARGETS) else if (target == serverTARGETS)
{ {
#ifdef DEBUG #ifdef DEBUG
...@@ -771,15 +784,14 @@ void nxagentRequestSelection(XEvent *X) ...@@ -771,15 +784,14 @@ void nxagentRequestSelection(XEvent *X)
* The selection does not matter here, we will return this for * The selection does not matter here, we will return this for
* PRIMARY and CLIPBOARD. * PRIMARY and CLIPBOARD.
* *
* FIXME: I am wondering if we should align this with * The list is aligned with the one in nxagentConvertSelection.
* nxagentConvertSelection, where we report more formats. *
* FIXME: the perfect solution should not just answer with * FIXME: the perfect solution should not just answer with
* XA_STRING but ask the real owner what format it supports. The * XA_STRING but ask the real owner what format it supports. The
* should then be sent to the original requestor. * should then be sent to the original requestor.
* FIXME: add serverCOMPOUND_TEXT?
*/ */
long targets[] = {XA_STRING, serverUTF8_STRING, serverTEXT, serverTARGETS, serverTIMESTAMP}; long targets[] = {XA_STRING, serverUTF8_STRING, serverTEXT, serverCOMPOUND_TEXT, serverTARGETS, serverTIMESTAMP};
int numTargets = sizeof(targets) / sizeof(targets[0]); int numTargets = sizeof(targets) / sizeof(targets[0]);
#ifdef DEBUG #ifdef DEBUG
...@@ -1785,15 +1797,13 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1785,15 +1797,13 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
/* /*
* The selection request target is TARGETS. The requestor is asking * The selection request target is TARGETS. The requestor is asking
* for a list of supported data formats. Currently there's 4 of them. * for a list of supported data formats.
* *
* FIXME: I am wondering if we should align this with * The list is aligned with the one in nxagentRequestSelection.
* nxagentRequestSelection, where we use another target list.
*/ */
if (target == clientTARGETS) if (target == clientTARGETS)
{ {
/* --- Order changed by dimbor (prevent sending COMPOUND_TEXT to client --- */ Atom targets[] = {XA_STRING, clientUTF8_STRING, clientTEXT, clientCOMPOUND_TEXT, clientTARGETS, clientTIMESTAMP};
Atom targets[] = {XA_STRING, clientUTF8_STRING, clientTEXT, clientCOMPOUND_TEXT};
int numTargets = sizeof(targets) / sizeof(targets[0]); int numTargets = sizeof(targets) / sizeof(targets[0]);
#ifdef DEBUG #ifdef DEBUG
...@@ -1827,7 +1837,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1827,7 +1837,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
* support conversion to TIMESTAMP, returning the timestamp they * support conversion to TIMESTAMP, returning the timestamp they
* used to obtain the selection." * used to obtain the selection."
*/ */
if (target == MakeAtom("TIMESTAMP", 9, 1)) if (target == clientTIMESTAMP)
{ {
int i = nxagentFindCurrentSelectionIndex(selection); int i = nxagentFindCurrentSelectionIndex(selection);
if (i < NumCurrentSelections) if (i < NumCurrentSelections)
...@@ -2051,10 +2061,10 @@ int nxagentSendNotify(xEvent *event) ...@@ -2051,10 +2061,10 @@ int nxagentSendNotify(xEvent *event)
{ {
eventSelection.target = serverTEXT; eventSelection.target = serverTEXT;
} }
/*else if (event->u.selectionNotify.target == clientCOMPOUND_TEXT) else if (event->u.selectionNotify.target == clientCOMPOUND_TEXT)
{ {
eventSelection.target = serverCOMPOUND_TEXT; eventSelection.target = serverCOMPOUND_TEXT;
}*/ }
else else
{ {
eventSelection.target = XA_STRING; eventSelection.target = XA_STRING;
...@@ -2149,6 +2159,7 @@ Bool nxagentInitClipboard(WindowPtr pWin) ...@@ -2149,6 +2159,7 @@ Bool nxagentInitClipboard(WindowPtr pWin)
serverTARGETS = nxagentAtoms[6]; /* TARGETS */ serverTARGETS = nxagentAtoms[6]; /* TARGETS */
serverTEXT = nxagentAtoms[7]; /* TEXT */ serverTEXT = nxagentAtoms[7]; /* TEXT */
serverUTF8_STRING = nxagentAtoms[12]; /* UTF8_STRING */ serverUTF8_STRING = nxagentAtoms[12]; /* UTF8_STRING */
serverCOMPOUND_TEXT = nxagentAtoms[16]; /* COMPOUND_TEXT */
/* see nxagentSendNotify for an explanation */ /* see nxagentSendNotify for an explanation */
serverClientCutProperty = nxagentAtoms[15]; /* NX_CUT_BUFFER_CLIENT */ serverClientCutProperty = nxagentAtoms[15]; /* NX_CUT_BUFFER_CLIENT */
...@@ -2252,6 +2263,7 @@ Bool nxagentInitClipboard(WindowPtr pWin) ...@@ -2252,6 +2263,7 @@ Bool nxagentInitClipboard(WindowPtr pWin)
clientTEXT = MakeAtom(szAgentTEXT, strlen(szAgentTEXT), True); clientTEXT = MakeAtom(szAgentTEXT, strlen(szAgentTEXT), True);
clientCOMPOUND_TEXT = MakeAtom(szAgentCOMPOUND_TEXT, strlen(szAgentCOMPOUND_TEXT), True); clientCOMPOUND_TEXT = MakeAtom(szAgentCOMPOUND_TEXT, strlen(szAgentCOMPOUND_TEXT), True);
clientUTF8_STRING = MakeAtom(szAgentUTF8_STRING, strlen(szAgentUTF8_STRING), True); clientUTF8_STRING = MakeAtom(szAgentUTF8_STRING, strlen(szAgentUTF8_STRING), True);
clientTIMESTAMP = MakeAtom(szAgentTIMESTAMP, strlen(szAgentTIMESTAMP), True);
if (clientCutProperty == None) if (clientCutProperty == None)
{ {
......
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