diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2009-07-15 20:56:48 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2009-07-15 20:56:48 (GMT) |
commit | 23c93fc468b9ccb7b9d9845ab87c1d4005043ab9 (patch) | |
tree | ca49c61cdc0f28a8da25c3368ccf8a4604512424 | |
parent | 0c4d260f03b28a644623131ea0a7b6e3ecc9fbb0 (diff) | |
download | tk-23c93fc468b9ccb7b9d9845ab87c1d4005043ab9.zip tk-23c93fc468b9ccb7b9d9845ab87c1d4005043ab9.tar.gz tk-23c93fc468b9ccb7b9d9845ab87c1d4005043ab9.tar.bz2 |
Apply patch from [Bug 2821962] to make binary byte selection transfers work.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | unix/tkUnixSelect.c | 74 |
2 files changed, 59 insertions, 20 deletions
@@ -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 df8c3af..9476e4e 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.22 2008/11/08 18:44:40 dkf Exp $ + * RCS: @(#) $Id: tkUnixSelect.c,v 1.23 2009/07/15 20:56:49 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(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(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: |