Commit b82f44e3 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

nxagent: Add keystroke for dumping the current clipboard state

parent 89de77cd
......@@ -129,6 +129,10 @@ reread_keystrokes
autograb
Toggles autograb mode
dump_clipboard
print the current internal clipboard state (for debugging) to the
log.
force_synchronization
Forces immediate drawing of elements to be synchronized which can
fix some visual bugs.
......@@ -25,4 +25,5 @@
<keystroke action="viewport_scroll_down" Control="1" AltMeta="1" key="KP_Down" />
<keystroke action="reread_keystrokes" Control="1" AltMeta="1" key="k" />
<keystroke action="autograb" Control="1" AltMeta="1" key="g" />
<keystroke action="dump_clipboard" Control="1" Shift="1" AltMeta="1" key="c" />
</keystrokes>
......@@ -68,9 +68,7 @@ extern Selection *CurrentSelections;
int nxagentLastClipboardClient = -1;
static int agentClipboardInitialized = False;
#ifdef DEBUG
static int clientAccum;
#endif
XlibAtom serverTransToAgentProperty;
Atom clientCutProperty;
......@@ -156,19 +154,16 @@ static char szAgentCLIPBOARD[] = "CLIPBOARD";
/* number of milliseconds to wait for a conversion from the real X server. */
#define CONVERSION_TIMEOUT 5000
#ifdef DEBUG
/*
* Time window (milliseconds) within to detect multiple conversion
* calls of the same client.
*/
#define ACCUM_TIME 5000
#endif
/*
* some helpers for debugging output
*/
#ifdef DEBUG
static const char * getClientSelectionStageString(int stage)
{
switch(stage)
......@@ -181,15 +176,18 @@ static const char * getClientSelectionStageString(int stage)
default: return("UNKNOWN!"); break;;
}
}
#ifdef DEBUG
#define setClientSelectionStage(stage) do {fprintf(stderr, "%s: Changing selection stage from [%s] to [%s]\n", __func__, getClientSelectionStageString(lastClientStage), getClientSelectionStageString(SelectionStage##stage)); lastClientStage = SelectionStage##stage;} while (0)
#define printClientSelectionStage() do {fprintf(stderr, "%s: Current selection stage [%s]\n", __func__, getClientSelectionStageString(lastClientStage));} while (0)
#define WINDOWID(ptr) (ptr) ? (ptr->drawable.id) : 0
#define CLINDEX(clientptr) (clientptr) ? (clientptr->index) : -1
#else
#define setClientSelectionStage(stage) do {lastClientStage = SelectionStage##stage;} while (0)
#define printClientSelectionStage()
#endif
#define WINDOWID(ptr) (ptr) ? (ptr->drawable.id) : 0
#define CLINDEX(clientptr) (clientptr) ? (clientptr->index) : -1
#ifdef DEBUG
/*
* see also nx-X11/lib/src/ErrDes.c
......@@ -267,7 +265,6 @@ void nxagentPrintClipboardStat(char *);
extern unsigned long startTime;
#endif
#ifdef DEBUG
static void printSelectionStat(int sel)
{
SelectionOwner lOwner = lastSelectionOwner[sel];
......@@ -313,14 +310,12 @@ static void printSelectionStat(int sel)
fprintf(stderr, " CurrentSelections[].window [0x%x]\n", curSel.window);
return;
}
#endif
void nxagentPrintClipboardStat(char *header)
void nxagentDumpClipboardStat(void)
{
#ifdef DEBUG
char *s = NULL;
fprintf(stderr, "/----- Clipboard internal status - %s -----\n", header);
fprintf(stderr, "/----- Clipboard internal status -----\n");
fprintf(stderr, " current time (Time) [%u]\n", GetTimeInMillis());
fprintf(stderr, " agentClipboardInitialized (Bool) [%s]\n", agentClipboardInitialized ? "True" : "False");
......@@ -399,7 +394,6 @@ void nxagentPrintClipboardStat(char *header)
fprintf(stderr, "\\------------------------------------------------------------------------------\n");
SAFE_XFree(s);
#endif
}
/*
......@@ -581,8 +575,6 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow)
(void *) pClient, CLINDEX(pClient), (void *) pWindow, WINDOWID(pWindow));
#endif
nxagentPrintClipboardStat("before nxagentClearClipboard");
/*
* Only for PRIMARY and CLIPBOARD selections.
*/
......@@ -610,8 +602,6 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow)
lastClientWindowPtr = NULL;
setClientSelectionStage(None);
}
nxagentPrintClipboardStat("after nxagentClearClipboard");
}
/*
......@@ -655,8 +645,6 @@ void nxagentHandleSelectionClearFromXServer(XEvent *X)
fprintf(stderr, "%s: SelectionClear event for selection [%lu].\n", __func__, X->xselectionclear.selection);
#endif
nxagentPrintClipboardStat("before nxagentHandleSelectionClearFromXServer");
if (!agentClipboardInitialized)
{
#ifdef DEBUG
......@@ -701,7 +689,6 @@ void nxagentHandleSelectionClearFromXServer(XEvent *X)
lastClientWindowPtr = NULL;
setClientSelectionStage(None);
nxagentPrintClipboardStat("after nxagentHandleSelectionClearFromXServer");
}
/*
......@@ -760,8 +747,6 @@ void nxagentHandleSelectionRequestFromXServer(XEvent *X)
}
#endif
nxagentPrintClipboardStat("before nxagentHandleSelectionRequestFromXServer");
if (!agentClipboardInitialized)
{
#ifdef DEBUG
......@@ -984,7 +969,6 @@ void nxagentHandleSelectionRequestFromXServer(XEvent *X)
}
}
}
nxagentPrintClipboardStat("after nxagentHandleSelectionRequestFromXServer");
}
/*
......@@ -1887,7 +1871,6 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
}
}
#ifdef DEBUG
if (lastClientClientPtr == client && (GetTimeInMillis() - lastClientReqTime < ACCUM_TIME))
{
/*
......@@ -1897,9 +1880,11 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
* client requesting PRIMARY and CLIPBOARD would match here, too
*/
#ifdef DEBUG
fprintf(stderr, "%s: Consecutives request from client [%p] selection [%u] "
"elapsed time [%u] clientAccum [%d]\n", __func__, (void *) client, selection,
GetTimeInMillis() - lastClientReqTime, clientAccum);
#endif
clientAccum++;
}
......@@ -1911,7 +1896,6 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
clientAccum = 0;
}
}
#endif
if (target == clientTEXT ||
target == XA_STRING ||
......
......@@ -78,4 +78,6 @@ extern WindowPtr nxagentGetClipboardWindow(Atom property);
extern int nxagentSendNotify(xEvent *event);
extern void nxagentDumpClipboardStat(void);
#endif /* __Clipboard_H__ */
......@@ -1070,6 +1070,11 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
nxagentToggleAutoGrab();
break;
}
case doDumpClipboard:
{
nxagentDumpClipboardStat();
break;
}
default:
{
FatalError("nxagentDispatchEvent: handleKeyPress returned unknown value\n");
......
......@@ -52,6 +52,7 @@ enum HandleEventResult
doSwitchResizeMode,
doSwitchDeferMode,
doAutoGrab,
doDumpClipboard
};
extern CARD32 nxagentLastEventTime;
......
......@@ -102,6 +102,8 @@ char * nxagentSpecialKeystrokeNames[] = {
"autograb",
"dump_clipboard",
NULL,
};
......@@ -142,6 +144,7 @@ struct nxagentSpecialKeystrokeMap default_map[] = {
{KEYSTROKE_VIEWPORT_SCROLL_DOWN, ControlMask, True, XK_KP_Down},
{KEYSTROKE_REREAD_KEYSTROKES, ControlMask, True, XK_k},
{KEYSTROKE_AUTOGRAB, ControlMask, True, XK_g},
{KEYSTROKE_DUMP_CLIPBOARD, ControlMask | ShiftMask, True, XK_c},
{KEYSTROKE_END_MARKER, 0, False, NoSymbol},
};
struct nxagentSpecialKeystrokeMap *map = default_map;
......@@ -715,6 +718,9 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result)
case KEYSTROKE_AUTOGRAB:
*result = doAutoGrab;
break;
case KEYSTROKE_DUMP_CLIPBOARD:
*result = doDumpClipboard;
break;
case KEYSTROKE_NOTHING: /* do nothing. difference to KEYSTROKE_IGNORE is the return value */
case KEYSTROKE_END_MARKER: /* just to make gcc STFU */
case KEYSTROKE_MAX:
......
......@@ -78,10 +78,12 @@ enum nxagentSpecialKeystroke {
KEYSTROKE_AUTOGRAB,
KEYSTROKE_NOTHING,
KEYSTROKE_DUMP_CLIPBOARD,
/* insert more here and in the string translation */
KEYSTROKE_NOTHING,
KEYSTROKE_MAX,
};
......
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