(tkwin, target, proc, clientData, format)
| 224 | *-------------------------------------------------------------- |
| 225 | */ |
| 226 | |
| 227 | void |
| 228 | Tk_CreateSelHandler(tkwin, target, proc, clientData, format) |
| 229 | Tk_Window tkwin; /* Token for window. */ |
| 230 | Atom target; /* The kind of selection conversions |
| 231 | * that can be handled by proc, |
| 232 | * e.g. TARGETS or XA_STRING. */ |
| 233 | Tk_SelectionProc *proc; /* Procedure to invoke to convert |
| 234 | * selection to type "target". */ |
| 235 | ClientData clientData; /* Value to pass to proc. */ |
| 236 | Atom format; /* Format in which the selection |
| 237 | * information should be returned to |
| 238 | * the requestor. XA_STRING is best by |
| 239 | * far, but anything listed in the ICCCM |
| 240 | * will be tolerated (blech). */ |
| 241 | { |
| 242 | register TkSelHandler *selPtr; |
| 243 | TkWindow *winPtr = (TkWindow *) tkwin; |
| 244 | |
| 245 | if (winPtr->dispPtr->multipleAtom == None) { |
| 246 | SelInit(tkwin); |
| 247 | } |
| 248 | |
| 249 | /* |
| 250 | * See if there's already a handler for this target on |
| 251 | * this window. If so, re-use it. If not, create a new one. |
| 252 | */ |
| 253 | |
| 254 | for (selPtr = winPtr->selHandlerList; ; selPtr = selPtr->nextPtr) { |
| 255 | if (selPtr == NULL) { |
| 256 | selPtr = (TkSelHandler *) ckalloc(sizeof(TkSelHandler)); |
| 257 | selPtr->nextPtr = winPtr->selHandlerList; |
| 258 | winPtr->selHandlerList = selPtr; |
| 259 | break; |
| 260 | } |
| 261 | if (selPtr->target == target) { |
| 262 | |
| 263 | /* |
| 264 | * Special case: when replacing handler created by |
| 265 | * "selection handle" free up memory. Should there be a |
| 266 | * callback to allow other clients to do this too? |
| 267 | */ |
| 268 | |
| 269 | if (selPtr->proc == HandleTclCommand) { |
| 270 | ckfree((char *) selPtr->clientData); |
| 271 | } |
| 272 | break; |
| 273 | } |
| 274 | } |
| 275 | selPtr->target = target; |
| 276 | selPtr->format = format; |
| 277 | selPtr->proc = proc; |
| 278 | selPtr->clientData = clientData; |
| 279 | if (format == XA_STRING) { |
| 280 | selPtr->size = 8; |
| 281 | } else { |
| 282 | selPtr->size = 32; |
| 283 | } |
no test coverage detected