diff options
Diffstat (limited to 'unix/tkUnixSelect.c')
-rw-r--r-- | unix/tkUnixSelect.c | 119 |
1 files changed, 60 insertions, 59 deletions
diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c index fda261c..6dd5008 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.4.2 2009/07/18 19:32:20 dkf Exp $ + * RCS: @(#) $Id: tkUnixSelect.c,v 1.27 2010/06/15 11:16:03 nijtmans Exp $ */ #include "tkInt.h" @@ -185,7 +185,7 @@ TkSelGetSelection( */ retr.timeout = Tcl_CreateTimerHandler(1000, SelTimeoutProc, - (ClientData) &retr); + &retr); while (retr.result == -1) { Tcl_DoOneEvent(0); } @@ -328,7 +328,7 @@ TkSelPropProc( length = strlen(incrPtr->converts[i].buffer); strcpy((char *)buffer, incrPtr->converts[i].buffer); - numItems = (*selPtr->proc)(selPtr->clientData, + numItems = selPtr->proc(selPtr->clientData, incrPtr->converts[i].offset, ((char *) buffer) + length, TK_SEL_BYTES_AT_ONCE - length); @@ -596,7 +596,7 @@ TkSelEventProc( return; } interp = retrPtr->interp; - Tcl_Preserve((ClientData) interp); + Tcl_Preserve(interp); /* * Convert the X selection data into UTF before passing it to the @@ -619,10 +619,10 @@ TkSelEventProc( Tcl_FreeEncoding(encoding); } - retrPtr->result = (*retrPtr->proc)(retrPtr->clientData, - interp, Tcl_DStringValue(&ds)); + retrPtr->result = retrPtr->proc(retrPtr->clientData, interp, + Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); - Tcl_Release((ClientData) interp); + Tcl_Release(interp); } else if (type == dispPtr->utf8Atom) { /* * The X selection data is in UTF-8 format already. We can't @@ -644,14 +644,14 @@ TkSelEventProc( } if (propInfo[numItems] != '\0') { - propData = ckalloc((size_t) numItems + 1); + propData = ckalloc(numItems + 1); strcpy(propData, propInfo); propData[numItems] = '\0'; } - retrPtr->result = (*retrPtr->proc)(retrPtr->clientData, + retrPtr->result = retrPtr->proc(retrPtr->clientData, retrPtr->interp, propData); if (propData != propInfo) { - ckfree((char *) propData); + ckfree(propData); } } else if (type == dispPtr->incrAtom) { @@ -663,14 +663,14 @@ TkSelEventProc( retrPtr->idleTime = 0; Tk_CreateEventHandler(tkwin, PropertyChangeMask, SelRcvIncrProc, - (ClientData) retrPtr); + retrPtr); XDeleteProperty(Tk_Display(tkwin), Tk_WindowId(tkwin), retrPtr->property); while (retrPtr->result == -1) { Tcl_DoOneEvent(0); } Tk_DeleteEventHandler(tkwin, PropertyChangeMask, SelRcvIncrProc, - (ClientData) retrPtr); + retrPtr); } else { Tcl_DString ds; @@ -692,10 +692,10 @@ TkSelEventProc( (Tk_Window) winPtr, &ds); } interp = retrPtr->interp; - Tcl_Preserve((ClientData) interp); - retrPtr->result = (*retrPtr->proc)(retrPtr->clientData, + Tcl_Preserve(interp); + retrPtr->result = retrPtr->proc(retrPtr->clientData, interp, Tcl_DStringValue(&ds)); - Tcl_Release((ClientData) interp); + Tcl_Release(interp); Tcl_DStringFree(&ds); } XFree(propInfo); @@ -793,7 +793,10 @@ ConvertSelection( register XSelectionRequestEvent *eventPtr) /* Event describing request. */ { - XSelectionEvent reply; /* Used to notify requestor that selection + union { + XSelectionEvent xsel; + XEvent ev; + } reply; /* Used to notify requestor that selection * info is ready. */ int multiple; /* Non-zero means a MULTIPLE request is being * handled. */ @@ -814,18 +817,18 @@ ConvertSelection( * Initialize the reply event. */ - reply.type = SelectionNotify; - reply.serial = 0; - reply.send_event = True; - reply.display = eventPtr->display; - reply.requestor = eventPtr->requestor; - reply.selection = eventPtr->selection; - reply.target = eventPtr->target; - reply.property = eventPtr->property; - if (reply.property == None) { - reply.property = reply.target; + reply.xsel.type = SelectionNotify; + reply.xsel.serial = 0; + reply.xsel.send_event = True; + reply.xsel.display = eventPtr->display; + reply.xsel.requestor = eventPtr->requestor; + reply.xsel.selection = eventPtr->selection; + reply.xsel.target = eventPtr->target; + reply.xsel.property = eventPtr->property; + if (reply.xsel.property == None) { + reply.xsel.property = reply.xsel.target; } - reply.time = eventPtr->time; + reply.xsel.time = eventPtr->time; for (infoPtr = winPtr->dispPtr->selectionInfoPtr; infoPtr != NULL; infoPtr = infoPtr->nextPtr) { @@ -848,8 +851,8 @@ ConvertSelection( incr.selection = eventPtr->selection; if (eventPtr->target != winPtr->dispPtr->multipleAtom) { multiple = 0; - singleInfo[0] = reply.target; - singleInfo[1] = reply.property; + singleInfo[0] = reply.xsel.target; + singleInfo[1] = reply.xsel.property; incr.multAtoms = singleInfo; incr.numConversions = 1; } else { @@ -883,8 +886,7 @@ ConvertSelection( * below). */ - incr.converts = (ConvertInfo *) - ckalloc((unsigned) incr.numConversions * sizeof(ConvertInfo)); + incr.converts = ckalloc(incr.numConversions * sizeof(ConvertInfo)); incr.numIncrs = 0; for (i = 0; i < incr.numConversions; i++) { Atom target, property, type; @@ -924,8 +926,8 @@ ConvertSelection( ip.nextPtr = TkSelGetInProgress(); TkSelSetInProgress(&ip); type = selPtr->format; - numItems = (*selPtr->proc)(selPtr->clientData, 0, - (char *) buffer, TK_SEL_BYTES_AT_ONCE); + numItems = selPtr->proc(selPtr->clientData, 0, (char *) buffer, + TK_SEL_BYTES_AT_ONCE); TkSelSetInProgress(ip.nextPtr); if ((ip.selPtr == NULL) || (numItems < 0)) { incr.multAtoms[2*i + 1] = None; @@ -958,7 +960,7 @@ ConvertSelection( propPtr = (char *) buffer; format = 32; incr.converts[i].offset = 0; - XChangeProperty(reply.display, reply.requestor, + XChangeProperty(reply.xsel.display, reply.xsel.requestor, property, type, format, PropModeReplace, (unsigned char *) propPtr, numItems); } else if (type == winPtr->dispPtr->utf8Atom) { @@ -967,7 +969,7 @@ ConvertSelection( * allows us to pass our utf-8 information untouched. */ - XChangeProperty(reply.display, reply.requestor, property, type, 8, + XChangeProperty(reply.xsel.display, reply.xsel.requestor, property, type, 8, PropModeReplace, (unsigned char *) buffer, numItems); } else if ((type == XA_STRING) || (type == winPtr->dispPtr->compoundTextAtom)) { @@ -986,7 +988,7 @@ ConvertSelection( encoding = Tcl_GetEncoding(NULL, "iso2022"); } Tcl_UtfToExternalDString(encoding, (char *) buffer, -1, &ds); - XChangeProperty(reply.display, reply.requestor, property, type, 8, + XChangeProperty(reply.xsel.display, reply.xsel.requestor, property, type, 8, PropModeReplace, (unsigned char *) Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); if (encoding) { @@ -1000,7 +1002,7 @@ ConvertSelection( goto refuse; } format = 32; - XChangeProperty(reply.display, reply.requestor, property, type, + XChangeProperty(reply.xsel.display, reply.xsel.requestor, property, type, format, PropModeReplace, (unsigned char *) propPtr, numItems); ckfree(propPtr); @@ -1014,17 +1016,16 @@ ConvertSelection( */ if (incr.numIncrs > 0) { - XSelectInput(reply.display, reply.requestor, PropertyChangeMask); - incr.timeout = Tcl_CreateTimerHandler(1000, IncrTimeoutProc, - (ClientData) &incr); + XSelectInput(reply.xsel.display, reply.xsel.requestor, PropertyChangeMask); + incr.timeout = Tcl_CreateTimerHandler(1000, IncrTimeoutProc, &incr); incr.idleTime = 0; - incr.reqWindow = reply.requestor; + incr.reqWindow = reply.xsel.requestor; incr.time = infoPtr->time; incr.nextPtr = tsdPtr->pendingIncrs; tsdPtr->pendingIncrs = &incr; } if (multiple) { - XChangeProperty(reply.display, reply.requestor, reply.property, + XChangeProperty(reply.xsel.display, reply.xsel.requestor, reply.xsel.property, XA_ATOM, 32, PropModeReplace, (unsigned char *) incr.multAtoms, (int) incr.numConversions*2); @@ -1034,9 +1035,9 @@ ConvertSelection( * to None if there was an error in conversion. */ - reply.property = incr.multAtoms[1]; + reply.xsel.property = incr.multAtoms[1]; } - XSendEvent(reply.display, reply.requestor, False, 0, (XEvent *) &reply); + XSendEvent(reply.xsel.display, reply.xsel.requestor, False, 0, &reply.ev); Tk_DeleteErrorHandler(errorHandler); /* @@ -1054,7 +1055,7 @@ ConvertSelection( Tcl_DeleteTimerHandler(incr.timeout); errorHandler = Tk_CreateErrorHandler(winPtr->display, -1, -1,-1, (int (*)()) NULL, NULL); - XSelectInput(reply.display, reply.requestor, 0L); + XSelectInput(reply.xsel.display, reply.xsel.requestor, 0L); Tk_DeleteErrorHandler(errorHandler); if (tsdPtr->pendingIncrs == &incr) { tsdPtr->pendingIncrs = incr.nextPtr; @@ -1073,7 +1074,7 @@ ConvertSelection( * All done. Cleanup and return. */ - ckfree((char *) incr.converts); + ckfree(incr.converts); if (multiple) { XFree((char *) incr.multAtoms); } @@ -1084,8 +1085,8 @@ ConvertSelection( */ refuse: - reply.property = None; - XSendEvent(reply.display, reply.requestor, False, 0, (XEvent *) &reply); + reply.xsel.property = None; + XSendEvent(reply.xsel.display, reply.xsel.requestor, False, 0, &reply.ev); Tk_DeleteErrorHandler(errorHandler); return; } @@ -1161,7 +1162,7 @@ SelRcvIncrProc( goto done; } interp = retrPtr->interp; - Tcl_Preserve((ClientData) interp); + Tcl_Preserve(interp); if (type == retrPtr->winPtr->dispPtr->compoundTextAtom) { encoding = Tcl_GetEncoding(NULL, "iso2022"); @@ -1192,7 +1193,7 @@ SelRcvIncrProc( */ retrPtr->result = TCL_OK; - Tcl_Release((ClientData) interp); + Tcl_Release(interp); goto done; } else { src = propInfo; @@ -1233,9 +1234,9 @@ SelRcvIncrProc( } Tcl_DStringSetLength(dstPtr, soFar); - result = (*retrPtr->proc)(retrPtr->clientData, interp, + result = retrPtr->proc(retrPtr->clientData, interp, Tcl_DStringValue(dstPtr)); - Tcl_Release((ClientData) interp); + Tcl_Release(interp); /* * Copy any unused data into the destination buffer so we can pick it @@ -1275,10 +1276,10 @@ SelRcvIncrProc( (Tk_Window) retrPtr->winPtr, &ds); } interp = retrPtr->interp; - Tcl_Preserve((ClientData) interp); - result = (*retrPtr->proc)(retrPtr->clientData, interp, + Tcl_Preserve(interp); + result = retrPtr->proc(retrPtr->clientData, interp, Tcl_DStringValue(&ds)); - Tcl_Release((ClientData) interp); + Tcl_Release(interp); Tcl_DStringFree(&ds); if (result != TCL_OK) { retrPtr->result = result; @@ -1324,7 +1325,7 @@ SelectionSize( TkSelSetInProgress(&ip); do { - chunkSize = (*selPtr->proc)(selPtr->clientData, size, (char *) buffer, + chunkSize = selPtr->proc(selPtr->clientData, size, (char *) buffer, TK_SEL_BYTES_AT_ONCE); if (ip.selPtr == NULL) { size = 0; @@ -1370,7 +1371,7 @@ IncrTimeoutProc( incrPtr->numIncrs = 0; } else { incrPtr->timeout = Tcl_CreateTimerHandler(1000, IncrTimeoutProc, - (ClientData) incrPtr); + incrPtr); } } @@ -1424,7 +1425,7 @@ SelCvtToX( if (Tcl_SplitList(NULL, string, &numFields, &field) != TCL_OK) { return NULL; } - propPtr = (long *) ckalloc((unsigned) numFields*sizeof(long)); + propPtr = ckalloc(numFields * sizeof(long)); /* * Convert the fields one-by-one. @@ -1449,7 +1450,7 @@ SelCvtToX( * Release the parsed list. */ - ckfree((char *) field); + ckfree(field); *numLongsPtr = i; return propPtr; } |