summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2009-07-15 21:08:43 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2009-07-15 21:08:43 (GMT)
commit19ea3b5ea84ea9eb57051fc996bb06ce0fecd1f6 (patch)
treede7c15752daa1bd80a5706158dfd448378c7da47 /unix
parentf3c805f63724d88a8dffc0b5c91573aa5b503c29 (diff)
downloadtk-19ea3b5ea84ea9eb57051fc996bb06ce0fecd1f6.zip
tk-19ea3b5ea84ea9eb57051fc996bb06ce0fecd1f6.tar.gz
tk-19ea3b5ea84ea9eb57051fc996bb06ce0fecd1f6.tar.bz2
Apply patch from [Bug 2821962] to make binary byte selection transfers work.
Diffstat (limited to 'unix')
-rw-r--r--unix/tkUnixSelect.c74
1 files changed, 54 insertions, 20 deletions
diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c
index b85b274..1de8bdc 100644
--- a/unix/tkUnixSelect.c
+++ b/unix/tkUnixSelect.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixSelect.c,v 1.21 2007/05/03 22:16:00 dkf Exp $
+ * RCS: @(#) $Id: tkUnixSelect.c,v 1.21.4.1 2009/07/15 21:08:43 dkf Exp $
*/
#include "tkInt.h"
@@ -93,7 +93,9 @@ static TkSelRetrievalInfo *pendingRetrievals = NULL;
static void ConvertSelection(TkWindow *winPtr,
XSelectionRequestEvent *eventPtr);
static void IncrTimeoutProc(ClientData clientData);
-static void SelCvtFromX(long *propPtr, int numValues, Atom type,
+static void SelCvtFromX32(long *propPtr, int numValues, Atom type,
+ Tk_Window tkwin, Tcl_DString *dsPtr);
+static void SelCvtFromX8(char *propPtr, int numValues, Atom type,
Tk_Window tkwin, Tcl_DString *dsPtr);
static long * SelCvtToX(char *string, Atom type, Tk_Window tkwin,
int *numLongsPtr);
@@ -672,19 +674,23 @@ TkSelEventProc(
} else {
Tcl_DString ds;
- if (format != 32) {
+ if (format != 32 && format != 8) {
char buf[64 + TCL_INTEGER_SPACE];
- sprintf(buf,
- "bad format for selection: wanted \"32\", got \"%d\"",
- format);
+ sprintf(buf, "bad format for selection: wanted \"32\" or "
+ "\"8\", got \"%d\"", format);
Tcl_SetResult(retrPtr->interp, buf, TCL_VOLATILE);
retrPtr->result = TCL_ERROR;
return;
}
Tcl_DStringInit(&ds);
- SelCvtFromX((long *) propInfo, (int) numItems, type,
- (Tk_Window) winPtr, &ds);
+ if (format == 32) {
+ SelCvtFromX32((long *) propInfo, (int) numItems, type,
+ (Tk_Window) winPtr, &ds);
+ } else {
+ SelCvtFromX8((char *) propInfo, (int) numItems, type,
+ (Tk_Window) winPtr, &ds);
+ }
interp = retrPtr->interp;
Tcl_Preserve((ClientData) interp);
retrPtr->result = (*retrPtr->proc)(retrPtr->clientData,
@@ -1251,19 +1257,23 @@ SelRcvIncrProc(
} else {
Tcl_DString ds;
- if (format != 32) {
+ if (format != 32 && format != 8) {
char buf[64 + TCL_INTEGER_SPACE];
- sprintf(buf,
- "bad format for selection: wanted \"32\", got \"%d\"",
- format);
+ sprintf(buf, "bad format for selection: wanted \"32\" or "
+ "\"8\", got \"%d\"", format);
Tcl_SetResult(retrPtr->interp, buf, TCL_VOLATILE);
retrPtr->result = TCL_ERROR;
goto done;
}
Tcl_DStringInit(&ds);
- SelCvtFromX((long *) propInfo, (int) numItems, type,
- (Tk_Window) retrPtr->winPtr, &ds);
+ if (format == 32) {
+ SelCvtFromX32((long *) propInfo, (int) numItems, type,
+ (Tk_Window) retrPtr->winPtr, &ds);
+ } else {
+ SelCvtFromX8((char *) propInfo, (int) numItems, type,
+ (Tk_Window) retrPtr->winPtr, &ds);
+ }
interp = retrPtr->interp;
Tcl_Preserve((ClientData) interp);
result = (*retrPtr->proc)(retrPtr->clientData, interp,
@@ -1447,12 +1457,12 @@ SelCvtToX(
/*
*----------------------------------------------------------------------
*
- * SelCvtFromX --
+ * SelCvtFromX32, SelCvtFromX8 --
*
- * Given an X property value, formatted as a collection of 32-bit values
- * according to "type" and the ICCCM conventions, convert the value to a
- * string suitable for manipulation by Tcl. This function is the inverse
- * of SelCvtToX.
+ * Given an X property value, formatted as a collection of 32-bit or
+ * 8-bit values according to "type" and the ICCCM conventions, convert
+ * the value to a string suitable for manipulation by Tcl. These
+ * functions are the inverse of SelCvtToX.
*
* Results:
* The return value (stored in a Tcl_DString) is the string equivalent of
@@ -1465,7 +1475,7 @@ SelCvtToX(
*/
static void
-SelCvtFromX(
+SelCvtFromX32(
register long *propPtr, /* Property value from X. */
int numValues, /* Number of 32-bit values in property. */
Atom type, /* Type of property Should not be XA_STRING
@@ -1495,6 +1505,30 @@ SelCvtFromX(
}
}
}
+
+static void
+SelCvtFromX8(
+ register char *propPtr, /* Property value from X. */
+ int numValues, /* Number of 8-bit values in property. */
+ Atom type, /* Type of property Should not be XA_STRING
+ * (if so, don't bother calling this function
+ * at all). */
+ Tk_Window tkwin, /* Window to use for atom conversion. */
+ Tcl_DString *dsPtr) /* Where to store the converted string. */
+{
+ /*
+ * Convert each long in the property to a string value, which is a
+ * hexadecimal string. We build the list in a Tcl_DString because this is
+ * easier than trying to get the quoting correct ourselves.
+ */
+
+ for ( ; numValues > 0; propPtr++, numValues--) {
+ char buf[12];
+
+ sprintf(buf, "0x%x", (unsigned char) *propPtr);
+ Tcl_DStringAppendElement(dsPtr, buf);
+ }
+}
/*
* Local Variables: