Merge jv
authorMerge Script
Fri, 25 Mar 2016 06:53:38 +0100
branchjv
changeset 7231 0550a616695c
parent 7226 78d9aa881c26 (current diff)
parent 7230 71910d55d08c (diff)
child 7244 9c77b73e65d8
Merge
Image.st
XWorkstation.st
--- a/DeviceWorkstation.st	Thu Mar 24 07:05:57 2016 +0100
+++ b/DeviceWorkstation.st	Fri Mar 25 06:53:38 2016 +0100
@@ -2302,6 +2302,13 @@
     ^ false
 !
 
+supportedClipboards
+    "answer a collection of symbols with the supported clipboards..
+     At least clipboard should be supported on any platform"
+
+    ^ #(clipboard)
+!
+
 supportedImageFormatForDepth:aDepth
     "given a depth, return the devices image format info,
      which provides padding info. If the given depth is not
@@ -2454,6 +2461,36 @@
     ^ false
 !
 
+supportsNativeDialogs
+    ^ false
+
+    "
+     Screen current supportsNativeDialogs
+    "
+!
+
+supportsNativeFileDialogs
+    ^ false
+
+    "Created: / 24-08-2010 / 17:23:51 / sr"
+!
+
+supportsNativeWidgetType:aWidgetTypeSymbol
+    ^ false
+
+    "
+     Screen current supportsNativeWidgetType:#Button
+    "
+!
+
+supportsNativeWidgets
+    ^ false
+
+    "
+     Screen current supportsNativeWidgets
+    "
+!
+
 supportsRoundShapedViews
     "return true, if this workstation supports round shaped
      (elliptical & circular) windows.
@@ -2466,6 +2503,19 @@
     "
 !
 
+supportsScreenReading
+    "can the screen be read?"
+
+    ^ true
+!
+
+supportsVariableHeightFonts
+    "are fonts with variable height supported?
+     Subclasses may redefine this"
+
+    ^ false
+!
+
 supportsViewBackgroundPixmap:aForm
     "return true, if the device allows the given pixmap as
      viewBackground. If false is returned,
@@ -7471,50 +7521,6 @@
 
 isX11Platform
     ^ self class isX11Platform
-!
-
-supportedClipboards
-    "answer a collection of symbols with the supported clipboards..
-     At least clipboard should be supported on any platform"
-
-    ^ #(clipboard)
-!
-
-supportsNativeDialogs
-    ^ false
-
-    "
-     Screen current supportsNativeDialogs
-    "
-!
-
-supportsNativeFileDialogs
-    ^ false
-
-    "Created: / 24-08-2010 / 17:23:51 / sr"
-!
-
-supportsNativeWidgetType:aWidgetTypeSymbol
-    ^ false
-
-    "
-     Screen current supportsNativeWidgetType:#Button
-    "
-!
-
-supportsNativeWidgets
-    ^ false
-
-    "
-     Screen current supportsNativeWidgets
-    "
-!
-
-supportsVariableHeightFonts
-    "are fonts with variable height supported?
-     Subclasses may redefine this"
-
-    ^ false
 ! !
 
 !DeviceWorkstation methodsFor:'retrieving pixels'!
--- a/Image.st	Thu Mar 24 07:05:57 2016 +0100
+++ b/Image.st	Fri Mar 25 06:53:38 2016 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1991 by Claus Gittinger
 	      All Rights Reserved
@@ -2273,10 +2271,32 @@
      is grabbed (i.e. blocked for others) and a camera cursor is
      shown while the readout is done.
      WARNING: with doGrab true, this temporarily grabs the display
-	      and it may not work from within a buttonMotion
-	      (use with a false grabArg then)."
-
-    |depth vis img|
+              and it may not work from within a buttonMotion
+              (use with a false grabArg then)."
+
+    |depth vis img tmpFile util|
+
+    aDisplay supportsScreenReading ifFalse:[
+        "/ workaround: look for a helper utility in support/<os>/screenshot
+        "/ currently there is one for osx.
+        tmpFile := Filename newTemporary withSuffix:'png'.
+        util := Smalltalk packageDirectory asFilename / ('../support/',OperatingSystem getSystemType,'/screenshot').
+        util exists ifTrue:[
+            OperatingSystem executeCommand:('%1 %2 png %3 %4 %5 %6'
+                                                bindWith:util pathName
+                                                with:tmpFile pathName
+                                                with:aRectangle left
+                                                with:aRectangle top
+                                                with:aRectangle width
+                                                with:aRectangle height).
+            [
+                img := Image fromFile:tmpFile.
+            ] ensure:[
+                tmpFile remove.
+            ].    
+            ^ img.
+        ].    
+    ].
 
     depth := aDisplay depth.
 
@@ -2287,9 +2307,9 @@
     "/
     vis := aDisplay visualType.
     (vis == #TrueColor or:[vis == #DirectColor]) ifTrue:[
-	depth > 8 ifTrue:[
-	    depth := 24.
-	]
+        depth > 8 ifTrue:[
+            depth := 24.
+        ]
     ].
 
     img := self newForDepth:depth.
@@ -14351,7 +14371,7 @@
 from:aDrawable in:aRectangle
     "read an image from aDrawable.
      This may be a device Form, a view or the rootView.
-     If its a view or rootView, it must be completely visible (or have
+     If it's a view or rootView, it must be completely visible (or have
      the backingStore option turned on). Otherwise, only the clipped contents
      is returned. This is a common helper for form-to-image conversion,
      and to read hardcopy images from the screen."
@@ -14405,8 +14425,8 @@
             visType := device visualType.
             ddepth := device depth.
         ] ifTrue:[
+            visType := aDrawable photometric.
             ddepth := aDrawable depth.
-            visType := aDrawable photometric
         ].
     ].
 
@@ -14454,7 +14474,7 @@
     ].
 
     "
-     dont know yet, how the display pads; assume worst case,
+     don't know yet, how the display pads; assume worst case,
      offering enough space for 32 bit padding
     "
     w := width := aRectangle width.
@@ -14644,7 +14664,7 @@
     "/
     photometric == #palette ifTrue:[
         "/
-        "/ what we have now are the color numbers - still need the r/g/b values.
+        "/ what we now have are the color numbers - still need the r/g/b values.
         "/ find out, which colors are in the picture
         "/
         usedPixels := inData usedValues.
@@ -14656,9 +14676,11 @@
             |i|
 
             i := colorIndex + 1.
-            device getRGBFrom:colorIndex into:[:r :g :b |
-                map at:i put:(Color red:r green:g blue:b)
-            ]
+            device 
+                getRGBFrom:colorIndex 
+                into:[:r :g :b |
+                    map at:i put:(Color red:r green:g blue:b)
+                ]
         ].
         self setColorMap:map.
     ].
@@ -14705,7 +14727,7 @@
 !
 
 fromScreen:aRectangle on:aDevice grab:doGrab
-    "read an image from aDevices display screen.
+    "read an image from aDevice's display screen.
      If the doGrab argument is true, the display
      is grabbed (i.e. blocked for others) and a camera cursor is
      shown while the readout is done.
@@ -14730,7 +14752,7 @@
 "/    ].
 
     "
-     actually have to grabServer ... but thats not yet available
+     actually have to grabServer ... but that's not yet available
     "
     rootView := aDevice rootView.
     doGrab ifTrue:[
--- a/XWorkstation.st	Thu Mar 24 07:05:57 2016 +0100
+++ b/XWorkstation.st	Fri Mar 25 06:53:38 2016 +0100
@@ -1669,6 +1669,14 @@
     "
 !
 
+supportedClipboards
+    "answer a collection of symbols with the supported clipboards.
+     X11 additionaly supports a buffer containing the currently selected text
+     (in xterm) - the PRIMARY selection"
+
+    ^ #(clipboard selection)
+!
+
 supportedImageFormats
     "return an array with supported image formats;
      each array entry is an attribute dictionary, consisting of
@@ -1782,6 +1790,36 @@
     "Created: / 4.5.1999 / 12:16:43 / cg"
 !
 
+supportsScreenReading
+    "return true, if the device allows reading the screen pixels
+     True returned here - X can do it"
+
+    "XQuartz seems to have a bug here...
+     ...but only on XQuartz servers.
+     Blame: cannot ask via server vendor, if its a Quartz display"
+    OperatingSystem isOSXlike ifTrue:[
+        ^ false
+    ].
+    ^ true
+
+    "
+     Display serverVendor
+     Display supportsScreenReading
+    "
+!
+
+supportsUTF8WindowLabels
+    "answer true, if window labels are to be utf-8 encoded"
+
+    ^ false
+!
+
+supportsVariableHeightFonts
+    "are fonts with variable height supported?"
+
+    ^ false
+!
+
 supportsViewBackgroundPixmap:aForm
     "return true, if the device allows the given pixmap as
      viewBackground.
@@ -11060,26 +11098,6 @@
     "
      Display isXineramaActive
     "
-!
-
-supportedClipboards
-    "answer a collection of symbols with the supported clipboards.
-     X11 additionaly supports a buffer containing the currently selected text
-     (in xterm) - the PRIMARY selection"
-
-    ^ #(clipboard selection)
-!
-
-supportsUTF8WindowLabels
-    "answer true, if window labels are to be utf-8 encoded"
-
-    ^ false
-!
-
-supportsVariableHeightFonts
-    "are fonts with variable height supported?"
-
-    ^ false
 ! !
 
 !XWorkstation methodsFor:'resources'!