diff -r 294a80096da6 -r f1726c185220 XWorkstation.st --- a/XWorkstation.st Fri Sep 17 15:18:48 2004 +0200 +++ b/XWorkstation.st Fri Sep 17 15:21:32 2004 +0200 @@ -9415,7 +9415,7 @@ nitems *= (actual_format / 8); typeID = __MKATOMOBJ(actual_type); if (! cp) { - cp = cp2 = (char *)malloc(nitems+bytes_after+1); + cp = cp2 = (char *)malloc(nitems+bytes_after); } else { cp2 = cp + nread; } @@ -9433,11 +9433,21 @@ } while (bytes_after > 0); if (ok) { - if (actual_type == XA_STRING) { - cp[nread] = '\0'; - val = __MKSTRING_L(cp, nread); - } else { - val = __MKBYTEARRAY(cp, nread); + switch (actual_format) { + case 32: + val = __stArrayFromCUIntArray(cp, nread/4); + break; + case 16: + val = __stArrayFromCUShortArray(cp, nread/2); + break; + case 8: + default: + if (actual_type == XA_STRING) { + val = __MKSTRING_L(cp, nread); + } else { + val = __MKBYTEARRAY(cp, nread); + } + break; } } if (cp) @@ -9988,7 +9998,7 @@ selectionOwnerWindowId isNil ifTrue:[ ^ nil "no selection" ]. - selectionOwnerWindowId == selectionOwner ifTrue:[ + selectionOwnerWindowId = selectionOwner ifTrue:[ "I still hold the selection, so return my locally buffered data" ^ copyBuffer ]. @@ -10029,7 +10039,7 @@ ^ nil "no selection" ]. - selectionOwnerWindowId == selectionOwner ifTrue:[ + selectionOwnerWindowId = selectionOwner ifTrue:[ "I still hold the selection, so return my locally buffered data" ^ self selectionAsString. ]. @@ -10103,7 +10113,7 @@ We set only the CLIPBOARD selection" selectionTime := lastEventTime. - ^ self setSelectionOwner:aWindowId of:clipboardAtom time:selectionTime + self setSelectionOwner:aWindowId of:clipboardAtom time:selectionTime ! setTextSelection:aString owner:aWindowId @@ -10115,11 +10125,8 @@ selectionTime := lastEventTime. - (self setSelectionOwner:aWindowId of:clipboardAtom time:selectionTime) ifFalse:[ - 'XWorkstation [warning]: selection ownerchange failed: ' errorPrint. self errorPrintCR. - ]. + self setSelectionOwner:aWindowId of:clipboardAtom time:selectionTime. self setSelectionOwner:aWindowId of:primaryAtom time:selectionTime. - ^ true "Modified: / 17.6.1998 / 19:48:54 / cg" ! @@ -10130,7 +10137,7 @@ |supportedTargets numericTargetArray| - supportedTargets := #(ST_OBJECT STRING UTF8_STRING TARGETS TIMESTAMP LENGTH). + supportedTargets := #(ST_OBJECT STRING UTF8_STRING TIMESTAMP TARGETS LENGTH). numericTargetArray := IntegerArray new:supportedTargets size. supportedTargets keysAndValuesDo:[:index :targetSymbol| @@ -10349,7 +10356,6 @@ && __isAtomID(selectionAtomID) && ISCONNECTED) { Display *dpy = myDpy; - Window owner; Time time; win = __WindowVal(aWindowId); @@ -10368,17 +10374,12 @@ DPRINTF(("setOwner prop=%x win=%x\n", __AtomVal(selectionAtomID), win)); ENTER_XLIB(); XSetSelectionOwner(dpy, __AtomVal(selectionAtomID), win, time); - owner = XGetSelectionOwner(dpy, __AtomVal(selectionAtomID)); + RETURN (self); LEAVE_XLIB(); - if (owner != win) { - RETURN (false); - } - RETURN (true); } err:; %}. self primitiveFailedOrClosedConnection. - ^ false ! ! !XWorkstation methodsFor:'window stuff'! @@ -11583,6 +11584,9 @@ ^ selection. ]. + targetID == (display atomIDOf:#'TARGETS') ifTrue:[ + ^ buffer + ]. targetID == (display atomIDOf:#'ST_OBJECT') ifTrue:[ ^ (Object readBinaryFrom:(ReadStream on:buffer) onError:[nil]) ]. @@ -11739,7 +11743,7 @@ !XWorkstation class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.462 2004-09-15 20:48:27 stefan Exp $' + ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.463 2004-09-17 13:21:32 stefan Exp $' ! ! XWorkstation initialize!