summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--unix/tkUnixSelect.c74
2 files changed, 59 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 6ce5afc..d9de4ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-15 Donal K. Fellows <dkf@users.sf.net>
+
+ * unix/tkUnixSelect.c (TkSelEventProc, SelRcvIncrProc, SelCvtFromX8):
+ [Bug 2821962]: Make byte sequence selection transfers possible.
+
2009-07-14 Donal K. Fellows <dkf@users.sf.net>
* doc/canvas.n (WINDOW ITEMS): [Bug 2326602]: Corrected definition of
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: