aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2020-02-14 00:28:59 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2020-05-31 12:52:35 +0200
commitb82f44e3565b6670e816f4081076596d0ea0236b (patch)
tree86a3938217ae3e8d32aee6b1a1140d6aa9e7db9e
parent89de77cdc04f81d8080fa07507bb4bbf37e1b514 (diff)
downloadnx-libs-b82f44e3565b6670e816f4081076596d0ea0236b.tar.gz
nx-libs-b82f44e3565b6670e816f4081076596d0ea0236b.tar.bz2
nx-libs-b82f44e3565b6670e816f4081076596d0ea0236b.zip
nxagent: Add keystroke for dumping the current clipboard state
-rw-r--r--doc/nxagent/README.keystrokes4
-rw-r--r--etc/keystrokes.cfg1
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Clipboard.c34
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Clipboard.h2
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Events.c5
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Events.h1
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Keystroke.c6
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Keystroke.h4
8 files changed, 31 insertions, 26 deletions
diff --git a/doc/nxagent/README.keystrokes b/doc/nxagent/README.keystrokes
index b76e9fd62..e916bddc0 100644
--- a/doc/nxagent/README.keystrokes
+++ b/doc/nxagent/README.keystrokes
@@ -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.
diff --git a/etc/keystrokes.cfg b/etc/keystrokes.cfg
index 27acf8e84..ea9feeea6 100644
--- a/etc/keystrokes.cfg
+++ b/etc/keystrokes.cfg
@@ -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>
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
index d51f066a9..990c175a0 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
@@ -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 ||
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h
index b741ef286..4817a03e2 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h
+++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h
@@ -78,4 +78,6 @@ extern WindowPtr nxagentGetClipboardWindow(Atom property);
extern int nxagentSendNotify(xEvent *event);
+extern void nxagentDumpClipboardStat(void);
+
#endif /* __Clipboard_H__ */
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c
index 83091eff4..346ee48d8 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Events.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c
@@ -1070,6 +1070,11 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
nxagentToggleAutoGrab();
break;
}
+ case doDumpClipboard:
+ {
+ nxagentDumpClipboardStat();
+ break;
+ }
default:
{
FatalError("nxagentDispatchEvent: handleKeyPress returned unknown value\n");
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.h b/nx-X11/programs/Xserver/hw/nxagent/Events.h
index a33a1abb1..fc00ba1d0 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Events.h
+++ b/nx-X11/programs/Xserver/hw/nxagent/Events.h
@@ -52,6 +52,7 @@ enum HandleEventResult
doSwitchResizeMode,
doSwitchDeferMode,
doAutoGrab,
+ doDumpClipboard
};
extern CARD32 nxagentLastEventTime;
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c
index 73a5901f8..d6c659fec 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c
@@ -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:
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h
index 463bda9b3..a5a6fbcf1 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h
@@ -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,
};