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