XWorkstation.st
changeset 3789 712d129efee8
parent 3788 765f9c81f481
child 3790 43261db5b846
--- a/XWorkstation.st	Sat Feb 08 21:33:28 2003 +0100
+++ b/XWorkstation.st	Mon Feb 10 17:47:22 2003 +0100
@@ -10859,6 +10859,70 @@
     self primitiveFailedOrClosedConnection
 !
 
+getGeometryOf:aWindowId
+    "get a windows geometry. 
+     NOTICE: X-WindowManagers usually do wrap client topViews into their own 
+     decoration views (top label, resize boundaries etc.).
+     Thus, the numbers returned here for topViews are the physical (real) dimensions
+     relative to such a wrapper.
+     In contrast, the values found in the views instance variables are virtual dimensions
+     (i.e. ST/X makes this decoration view transparent to the program."
+
+    <context: #return>
+
+    |x y width height depth borderWidth info|
+
+%{  
+    int x_return, y_return;
+    unsigned int width_return, height_return, 
+                 border_width_return, depth_return;
+    Window root_return;
+
+    if (ISCONNECTED
+     && __isExternalAddress(aWindowId)) {
+        ENTER_XLIB();
+        XGetGeometry(myDpy, __WindowVal(aWindowId), 
+                     &root_return, 
+                     &x_return, &y_return, 
+                     &width_return, &height_return, &border_width_return,
+                     &depth_return);
+        LEAVE_XLIB();
+
+        x = __MKSMALLINT(x_return);
+        y = __MKSMALLINT(y_return);
+        width = __MKSMALLINT(width_return);
+        height = __MKSMALLINT(height_return);
+        depth = __MKSMALLINT(depth_return);
+        borderWidth = __MKSMALLINT(border_width_return);
+    }
+%}.
+    borderWidth isNil ifTrue:[
+        self primitiveFailedOrClosedConnection.
+        ^ nil
+    ].
+    info := Dictionary new.
+    info at:#origin put:(x @ y).
+    info at:#extent put:(width @ height).
+    info at:#depth  put:depth.
+    info at:#borderWidth put:borderWidth.
+    ^ info
+
+    "
+     Transcript topView device
+        getGeometryOf:(Transcript id)
+    "
+    "
+     Transcript topView device
+        getGeometryOf:(Transcript topView id)
+    "
+    "
+     |d|
+
+     d := Transcript topView device.
+     d getGeometryOf:(d parentWindowIdOf:Transcript topView id)
+    "
+!
+
 isValidWindowId:aWindowId
     "return true, if the given window ID is (still) valid.
      Especially useful, if the passed windowID is 
@@ -11111,6 +11175,42 @@
     self primitiveFailedOrClosedConnection
 !
 
+parentWindowIdOf:aWindowId
+    "return a windows parent-window id.
+     Useful with getGeometryOf:, to compute information about the decoration."
+
+%{ 
+
+    if (ISCONNECTED
+     && __isExternalAddress(aWindowId)) {
+        Status ok;
+        Window root, parent, *children = NULL;
+        int nChildren;
+
+/*        ENTER_XLIB(); */
+        ok = XQueryTree(myDpy, __WindowVal(aWindowId), 
+                        &root, &parent, &children, &nChildren);
+        if (children) {
+            XFree(children);
+        }
+/*        LEAVE_XLIB();   */
+        if (! ok) {
+            RETURN ( nil );
+        }
+        RETURN ( __MKEXTERNALADDRESS(parent) );
+    }
+%}.
+    self primitiveFailedOrClosedConnection.
+    ^ false
+
+    "
+     |id|
+
+     id := Transcript device parentWindowIdOf:(Transcript id).
+     self assert: ( Transcript container id = id ).
+    "
+!
+
 raiseWindow:aWindowId
     "bring a window to front"
 
@@ -11792,7 +11892,7 @@
 !XWorkstation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.418 2003-02-08 20:33:28 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.419 2003-02-10 16:47:22 cg Exp $'
 ! !
 
 XWorkstation initialize!