(interp, tkwin, target, proc, clientData)
| 380 | * remainder of the selection retrieval will be aborted. |
| 381 | * |
| 382 | *-------------------------------------------------------------- |
| 383 | */ |
| 384 | |
| 385 | int |
| 386 | Tk_GetSelection(interp, tkwin, target, proc, clientData) |
| 387 | Tcl_Interp *interp; /* Interpreter to use for reporting |
| 388 | * errors. */ |
| 389 | Tk_Window tkwin; /* Window on whose behalf to retrieve |
| 390 | * the selection (determines display |
| 391 | * from which to retrieve). */ |
| 392 | Atom target; /* Desired form in which selection |
| 393 | * is to be returned. */ |
| 394 | Tk_GetSelProc *proc; /* Procedure to call to process the |
| 395 | * selection, once it has been retrieved. */ |
| 396 | ClientData clientData; /* Arbitrary value to pass to proc. */ |
| 397 | { |
| 398 | RetrievalInfo retr; |
| 399 | TkWindow *winPtr = (TkWindow *) tkwin; |
| 400 | TkDisplay *dispPtr = winPtr->dispPtr; |
| 401 | |
| 402 | if (dispPtr->multipleAtom == None) { |
| 403 | SelInit(tkwin); |
| 404 | } |
| 405 | |
| 406 | /* |
| 407 | * If the selection is owned by a window managed by this |
| 408 | * process, then call the retrieval procedure directly, |
| 409 | * rather than going through the X server (it's dangerous |
| 410 | * to go through the X server in this case because it could |
| 411 | * result in deadlock if an INCR-style selection results). |
| 412 | */ |
| 413 | |
| 414 | if (dispPtr->selectionOwner != NULL) { |
| 415 | register TkSelHandler *selPtr; |
| 416 | int offset, result, count; |
| 417 | char buffer[TK_SEL_BYTES_AT_ONCE+1]; |
| 418 | Time time; |
| 419 | |
| 420 | /* |
| 421 | * Make sure that the selection predates the request |
| 422 | * time. |
| 423 | */ |
| 424 | |
| 425 | time = TkCurrentTime(dispPtr); |
| 426 | if ((time < dispPtr->selectionTime) |
| 427 | && (time != CurrentTime) |
| 428 | && (dispPtr->selectionTime != CurrentTime)) { |
| 429 | interp->result = "selection changed before it could be retrieved"; |
| 430 | return TCL_ERROR; |
| 431 | } |
| 432 | |
| 433 | for (selPtr = ((TkWindow *) dispPtr->selectionOwner)->selHandlerList; |
| 434 | ; selPtr = selPtr->nextPtr) { |
| 435 | if (selPtr == NULL) { |
| 436 | Atom type; |
| 437 | |
| 438 | count = DefaultSelection((TkWindow *) dispPtr->selectionOwner, |
| 439 | target, buffer, TK_SEL_BYTES_AT_ONCE, &type); |
no test coverage detected