[comp.windows.x] twm - What is size of title bar?

mustard@sdrc.UUCP (Sandy Mustard) (10/12/90)

We are building some X applications that require exacting locations
of the windows that we create (both with and without title bars).
We are using the twm window manager.

What determines the size of the title bar that is placed on the
window and can we obtain the title size to addjust out x and y
coordinates?

Thanks

Sandy Mustard
SDRC
mustard@sdrc.UU.NET

carroll@sunc5.cs.uiuc.edu (Alan M. Carroll) (10/14/90)

What we've done for this is to trace back the X window tree until you get a window
whose parent is the root window, and then retrieve the screen information for that
window. This can be compared to the information for the actual client window to
determine the size of the various WM borders. I don't have any C code for this,
but here's some Epoch code that does it -

(defun backing-screen-info (&optional win)
  (setq win (or win (current-screen)))
  (let ((parent nil)
        (root   nil)
        (wlist  nil))
    (while (and (setq wlist (query-tree win))
                (setq parent (cadr wlist))
                (setq root   (car wlist))
                (not (equal root parent)))
      (setq win parent))
    (and parent (screen-information win))))

This code is used for a modified version of Dan Pierson's minibuffer mover, so
that the title bar of the minibuffer doesn't obscure the bottom of the edit
screen, i.e. the code matches up the edges of the WM borders, not the client
window borders, which is what I understood the original question to be.

phil@ux1.cso.uiuc.edu (10/15/90)

Depending on your needs, it might work out to specify your geometry in terms
of the position of the lower right of the window from the lower right of the
root screen.  Then you'd only have to worry about border sizes.

--Phil Howard, KA9WGN-- | Individual CHOICE is fundamental to a free society
<phil@ux1.cso.uiuc.edu> | no matter what the particular issue is all about.

toml@ninja.Solbourne.COM (Tom LaStrange) (10/15/90)

In article <1990Oct13.184110.13150@ux1.cso.uiuc.edu>,
carroll@sunc5.cs.uiuc.edu (Alan M. Carroll) writes:
|> What we've done for this is to trace back the X window tree until you
get a window
|> whose parent is the root window, and then retrieve the screen
information for that
|> window. This can be compared to the information for the actual client
window to
|> determine the size of the various WM borders. I don't have any C code
for this,
|> but here's some Epoch code that does it -

This will not work with tvtwm or any other window manager that places an
extra window on top of the root window.  There really is no "standard" way
to find out how big the decoration is around your window.

--
Tom LaStrange

Solbourne Computer Inc.    ARPA: toml@Solbourne.COM
1900 Pike Rd.              UUCP: ...!{boulder,sun}!stan!toml
Longmont, CO  80501

pierson@encore.com (Dan L. Pierson) (10/16/90)

Regarding Re: twm - What is size of title bar?; toml@ninja.Solbourne.COM (Tom LaStrange) adds:
In article <1990Oct15.140039.24990@Solbourne.COM> toml@ninja.Solbourne.COM (Tom LaStrange) writes:
> In article <1990Oct13.184110.13150@ux1.cso.uiuc.edu>,
> carroll@sunc5.cs.uiuc.edu (Alan M. Carroll) writes: |> What we've
> done for this is to trace back the X window tree until you get a
> window |> whose parent is the root window, and then retrieve the
> screen information for that |> window. This can be compared to the
> information for the actual client window to |> determine the size of
> the various WM borders. I don't have any C code for this, |> but
> here's some Epoch code that does it -

> This will not work with tvtwm or any other window manager that
> places an extra window on top of the root window.  There really is
> no "standard" way to find out how big the decoration is around your
> window.

However this should:

;;; Utilities to find screen information for the tvtwm virtual root
;;; (or the real root if not running tvtwm).

(defun find-root (&optional start)
  (setq start (or start (current-screen)))
  (let ((tree (epoch::query-tree start)))
    (while (car (cdr tree))
      (setq tree (epoch::query-tree (car (cdr tree)))))
    tree))

;;; Standard Elisp control structures are very impoverished.  If
;;; you're willing to load cl.elc use this one, if not see below.
(defun find-virtual-root (&optional start)
  (do* ((vr-atom (epoch::intern-atom "__SWM_VROOT"))
	(tree (find-root start) (cdr tree))
	(win (car tree) (car tree))
	(root win)
	(ans nil))
       ((or ans (null tree))
	(or ans root))
    (when win
      (setq ans (epoch::get-property vr-atom win)))))

;;; Use this version to avoid using cl.ecl.
(defun find-virtual-root (&optional start)
  (let* ((vr-atom (epoch::intern-atom "__SWM_VROOT"))
	 (tree (find-root start))
	 (root (car tree)))
    (catch 'found-it 
      (while tree
	(let ((win (car tree)))
	  (setq tree (cdr tree))
	  (if win
	      (let ((ans (epoch::get-property vr-atom win)))
		(if ans
		    (progn
		      (setq root ans)
		      (throw 'found-it ans))))))))))

(defun backing-screen-info (&optional win)
  (let ((root (find-virtual-root (or win (current-screen)))))
    (and root (screen-information root))))
--

                                            dan

In real life: Dan Pierson, Encore Computer Corporation, Research
UUCP: {talcott,linus,necis,decvax}!encore!pierson
Internet: pierson@encore.com