XWorkstation.st
changeset 8346 67c9eddbc4ba
parent 8342 61d70299d474
child 8347 33f968a33916
--- a/XWorkstation.st	Fri Apr 27 10:23:19 2018 +0200
+++ b/XWorkstation.st	Fri Apr 27 12:07:21 2018 +0200
@@ -10703,7 +10703,7 @@
     |val typeID|
 
 %{  /* UNLIMITEDSTACK */
-#define PROPERTY_DEBUG
+// #define PROPERTY_DEBUG
     Window window;
     Atom property;
     Atom actual_type;
@@ -10753,6 +10753,7 @@
 #endif
                 if (actual_type == None) {
                     // The property does not exist in the specified window
+                    ok = 0;
                     break;
                 }
                 typeID = __MKATOMOBJ(actual_type);
@@ -10806,6 +10807,7 @@
     ^ typeID->val
 
     "Created: / 25-04-2018 / 16:41:52 / stefan"
+    "Modified: / 27-04-2018 / 11:40:05 / stefan"
 !
 
 primSetProperty:propertyID type:typeID value:anObject for:aWindowID
@@ -11401,43 +11403,40 @@
     |selectionOwnerWindowId selection|
 
     selectionOwnerWindowId := self getSelectionOwnerOf:clipboardAtom.
-    selectionOwnerWindowId isNil ifTrue:[
-	"no selection. There is the possibilty that one of our (modal)
-	 views has been closed. Get the selection from the copyBuffer"
-	^ copyBuffer.
-    ].
-    selectionOwnerWindowId = selectionOwner ifTrue:[
-	"I still hold the selection, so return my locally buffered data"
-	^ copyBuffer
-    ].
-
-    drawableId notNil ifTrue:[
-	"sorry, cannot fetch a selection, if there is no drawableId.
-	 Should I borrow a drawableId from another window?"
-
-	selection := SelectionFetcher
-	    requestSelection:clipboardAtom
-	    type:(self atomIDOf:#'ST_OBJECT')
-	    onDevice:self for:drawableId.
-
-	"/ should not happen
-false ifTrue:[
-	"/ cg: disabled the code below: I don't want any string here (when asking for an object)
-	selection isEmptyOrNil ifTrue:[
-	    selection := SelectionFetcher
-		requestSelection:clipboardAtom
-		type:(self atomIDOf:#'UTF8_STRING')
-		onDevice:self for:drawableId.
-
-	    selection isNil ifTrue:[
-		selection := SelectionFetcher
-		    requestSelection:clipboardAtom
-		    type:(self atomIDOf:#STRING)
-		    onDevice:self for:drawableId.
-	    ].
-	].
-].
-    ].
+    (selectionOwnerWindowId isNil   "no selection. There is the possibilty that one of our (modal) views has been closed. 
+                                     Get the selection from our own buffer"
+     or:[(self viewFromId:selectionOwnerWindowId) notNil]) ifTrue:[
+        "one of our own views still holds the selection, so return my locally buffered data"
+        ^ copyBuffer
+    ].
+
+    drawableId isNil ifTrue:[
+        "sorry, cannot fetch a selection, if there is no drawableId.
+         Should I borrow a drawableId from another window?"
+        ^ nil.
+    ].
+
+    selection := SelectionFetcher
+        requestSelection:clipboardAtom
+        type:(self atomIDOf:#'ST_OBJECT')
+        onDevice:self for:drawableId.
+
+    "/ should not happen
+    "/ cg: disabled the code below: I don't want any string here (when asking for an object)
+"/    selection isEmptyOrNil ifTrue:[
+"/        selection := SelectionFetcher
+"/            requestSelection:clipboardAtom
+"/            type:(self atomIDOf:#'UTF8_STRING')
+"/            onDevice:self for:drawableId.
+"/
+"/        selection isNil ifTrue:[
+"/            selection := SelectionFetcher
+"/                requestSelection:clipboardAtom
+"/                type:(self atomIDOf:#STRING)
+"/                onDevice:self for:drawableId.
+"/        ].
+"/    ].
+
     selection isEmptyOrNil ifTrue:[ ^ copyBuffer ].
 
     ^ selection.
@@ -11445,6 +11444,8 @@
     "
        Display getClipboardObjectFor:Transcript id
     "
+
+    "Modified (format): / 27-04-2018 / 11:57:34 / stefan"
 !
 
 getClipboardText:selectionBufferSymbol for:drawableId
@@ -11454,43 +11455,41 @@
     |selectionId selectionOwnerWindowId selection|
 
     selectionBufferSymbol == #selection ifTrue:[
-	selectionId := primaryAtom.
+        selectionId := primaryAtom.
     ] ifFalse:[
-	selectionId := clipboardAtom.
+        selectionId := clipboardAtom.
     ].
 
     selectionOwnerWindowId := self getSelectionOwnerOf:selectionId.
-    selectionOwnerWindowId isNil ifTrue:[
-	"no selection. There is the possibilty that one of our (modal)
-	 views has been closed. Get the selection from the copyBuffer"
-	^ self copyBufferAsString.
-    ].
-
-    selectionOwnerWindowId = selectionOwner ifTrue:[
-	"I still hold the selection, so return my locally buffered data"
-	"JV@2012-04-02: Added support for PRIMARY/SELECTION buffers."
-	^ selectionId == primaryAtom ifTrue:[
-	    self primaryBufferAsString
-	] ifFalse:[
-	    self copyBufferAsString.
-	]
-    ].
-
-    drawableId notNil ifTrue:[
-	"sorry, cannot fetch a selection, if there is no drawableId.
-	 Should I borrow a drawableId from another window?"
-
-	selection := SelectionFetcher
-	    requestSelection:selectionId
-	    type:(self atomIDOf:#'UTF8_STRING')
-	    onDevice:self for:drawableId.
-
-	selection isNil ifTrue:[
-	    selection := SelectionFetcher
-		requestSelection:selectionId
-		type:(self atomIDOf:#STRING)
-		onDevice:self for:drawableId.
-	].
+
+    (selectionOwnerWindowId isNil   "no selection. There is the possibilty that one of our (modal) views has been closed. 
+                                     Get the selection from our own buffer"
+     or:[(self viewFromId:selectionOwnerWindowId) notNil]) ifTrue:[
+        "One of our own views still holds the selection, so return my locally buffered data"
+        "JV@2012-04-02: Added support for PRIMARY/SELECTION buffers."
+        ^ selectionId == primaryAtom ifTrue:[
+            self primaryBufferAsString
+        ] ifFalse:[
+            self copyBufferAsString.
+        ]
+    ].
+
+    drawableId isNil ifTrue:[
+        "sorry, cannot fetch a selection, if there is no drawableId.
+         Should I borrow a drawableId from another window?"
+         ^ nil.
+    ].
+
+    selection := SelectionFetcher
+        requestSelection:selectionId
+        type:(self atomIDOf:#'UTF8_STRING')
+        onDevice:self for:drawableId.
+
+    selection isNil ifTrue:[
+        selection := SelectionFetcher
+            requestSelection:selectionId
+            type:(self atomIDOf:#STRING)
+            onDevice:self for:drawableId.
     ].
 
     ^ selection
@@ -11501,6 +11500,7 @@
      "
 
     "Modified: / 02-04-2012 / 10:34:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 27-04-2018 / 11:57:03 / stefan"
 ! !
 
 !XWorkstation methodsFor:'selection sending'!
@@ -11808,16 +11808,10 @@
 
     |selectionAtomID|
 
-    "store the current owner of the selection.
-     If we still own the selection on paste,
-     we can avoid the X11 overhead"
-
-    selectionOwner := aWindowId.
-
     selectionAtomSymbolOrID isString ifTrue:[
-	selectionAtomID := self atomIDOf:selectionAtomSymbolOrID create:false.
+        selectionAtomID := self atomIDOf:selectionAtomSymbolOrID create:false.
     ] ifFalse:[
-	selectionAtomID := selectionAtomSymbolOrID.
+        selectionAtomID := selectionAtomSymbolOrID.
     ].
 
 %{
@@ -11826,31 +11820,33 @@
     if (__isExternalAddress(aWindowId)
      && __isAtomID(selectionAtomID)
      && ISCONNECTED) {
-	Display *dpy = myDpy;
-	Time time;
-
-	win = __WindowVal(aWindowId);
-
-	if (anIntegerTimestamp == nil) {
-	    /*
-	     * the ICCCM convention says: you should set the time to the time when
-	     * the selection was acquired and not to CurrentTime
-	     */
-	    time = CurrentTime;
-	} else if (__isInteger(anIntegerTimestamp)) {
-	    time = __unsignedLongIntVal(anIntegerTimestamp);
-	} else
-	    goto err;
-
-	DPRINTF(("setOwner prop=%"_lx_" win=%"_lx_"\n", (INT)__AtomVal(selectionAtomID), (INT)win));
-	ENTER_XLIB();
-	XSetSelectionOwner(dpy, __AtomVal(selectionAtomID), win, time);
-	RETURN (self);
-	LEAVE_XLIB();
+        Display *dpy = myDpy;
+        Time time;
+
+        win = __WindowVal(aWindowId);
+
+        if (anIntegerTimestamp == nil) {
+            /*
+             * the ICCCM convention says: you should set the time to the time when
+             * the selection was acquired and not to CurrentTime
+             */
+            time = CurrentTime;
+        } else if (__isInteger(anIntegerTimestamp)) {
+            time = __unsignedLongIntVal(anIntegerTimestamp);
+        } else
+            goto err;
+
+        DPRINTF(("setOwner prop=%"_lx_" win=%"_lx_"\n", (INT)__AtomVal(selectionAtomID), (INT)win));
+        ENTER_XLIB();
+        XSetSelectionOwner(dpy, __AtomVal(selectionAtomID), win, time);
+        RETURN (self);
+        LEAVE_XLIB();
     }
 err:;
 %}.
     self primitiveFailedOrClosedConnection.
+
+    "Modified: / 27-04-2018 / 11:56:21 / stefan"
 ! !
 
 !XWorkstation methodsFor:'window queries'!