summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixSelect.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tkUnixSelect.c')
-rw-r--r--unix/tkUnixSelect.c117
1 files changed, 59 insertions, 58 deletions
diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c
index 060fdd1..172d5ca 100644
--- a/unix/tkUnixSelect.c
+++ b/unix/tkUnixSelect.c
@@ -183,7 +183,7 @@ TkSelGetSelection(
*/
retr.timeout = Tcl_CreateTimerHandler(1000, SelTimeoutProc,
- (ClientData) &retr);
+ &retr);
while (retr.result == -1) {
Tcl_DoOneEvent(0);
}
@@ -326,7 +326,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);
@@ -594,7 +594,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
@@ -617,10 +617,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
@@ -642,14 +642,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) {
@@ -661,14 +661,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;
@@ -690,10 +690,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);
@@ -791,7 +791,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. */
@@ -812,18 +815,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) {
@@ -846,8 +849,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 {
@@ -881,8 +884,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;
@@ -922,8 +924,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;
@@ -956,7 +958,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) {
@@ -965,7 +967,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)) {
@@ -984,7 +986,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) {
@@ -998,7 +1000,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);
@@ -1012,17 +1014,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);
@@ -1032,9 +1033,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);
/*
@@ -1052,7 +1053,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;
@@ -1071,7 +1072,7 @@ ConvertSelection(
* All done. Cleanup and return.
*/
- ckfree((char *) incr.converts);
+ ckfree(incr.converts);
if (multiple) {
XFree((char *) incr.multAtoms);
}
@@ -1082,8 +1083,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;
}
@@ -1159,7 +1160,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");
@@ -1190,7 +1191,7 @@ SelRcvIncrProc(
*/
retrPtr->result = TCL_OK;
- Tcl_Release((ClientData) interp);
+ Tcl_Release(interp);
goto done;
} else {
src = propInfo;
@@ -1231,9 +1232,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
@@ -1273,10 +1274,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;
@@ -1322,7 +1323,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;
@@ -1368,7 +1369,7 @@ IncrTimeoutProc(
incrPtr->numIncrs = 0;
} else {
incrPtr->timeout = Tcl_CreateTimerHandler(1000, IncrTimeoutProc,
- (ClientData) incrPtr);
+ incrPtr);
}
}
@@ -1422,7 +1423,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.
@@ -1447,7 +1448,7 @@ SelCvtToX(
* Release the parsed list.
*/
- ckfree((char *) field);
+ ckfree(field);
*numLongsPtr = i;
return propPtr;
}