How to query a window for the height of its title bar? - Xwindows

This is a discussion on How to query a window for the height of its title bar? - Xwindows ; Hi, The subject says it all. I'm a complete X11-idiot, so if anyone could show me a code snippet before I plow through zillions of documents, that would be greatly appreciated. Thanks in advance Pia Kraft...

+ Reply to Thread
Results 1 to 2 of 2

Thread: How to query a window for the height of its title bar?

  1. How to query a window for the height of its title bar?

    Hi,

    The subject says it all. I'm a complete X11-idiot, so if anyone could show
    me a code snippet before I plow through zillions of documents, that would
    be greatly appreciated.

    Thanks in advance
    Pia Kraft

  2. Re: How to query a window for the height of its title bar?


    "Pia Kraft" wrote in message
    news:du93an$kg8$00$1@news.t-online.com...
    > Hi,
    >
    > The subject says it all. I'm a complete X11-idiot, so if anyone could show
    > me a code snippet before I plow through zillions of documents, that would
    > be greatly appreciated.
    >
    > Thanks in advance
    > Pia Kraft


    It's not particularly easy to do in general, since many window managers do
    not provide an API for this. here's something I wrote a long time ago to do
    this. Note that the shell must be visible at the time this is called.
    Usually I register a StructureNotify event handler on the widget, then call
    this from the event handler (and then remove the event handler).

    /* Needs appropriate include */

    static void
    GetMWMOffsets(
    Widget w, /* IN: Any widget in the shell */
    Position *x, /* OUT: X Offset within the decorations */
    Position *y, /* OUT: Top Y offset within the decorations */
    Position *yb) /* OUT: Bottom Y offset */
    #endif
    /************************************************** ****************************/
    {
    Display *dpy = XtDisplay(w);
    unsigned int width;
    unsigned int height=0, ht=0;
    int xp, yp;

    Window win, parent, root;
    Window *children;
    unsigned int bw, depth, nchildren;
    /************************************************** ****************************/

    while ( !XtIsShell(w) ){
    w = XtParent(w);
    }
    win = XtWindow(w);
    *x = 0;
    *y = 0;
    while (win != None && win != PointerRoot) {
    if (!XGetGeometry(dpy, win, &root, &xp, &yp, &width, &height, &bw,
    &depth)) {
    break;
    };
    children = NULL;
    if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren)) {
    break;
    }
    XFree (children);
    if (parent == root) {
    break;
    }
    *x += xp;
    *y += yp;
    ht = height;
    win = parent;
    }
    *yb = height - ht - *y;
    }

    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Software Reuse Project



+ Reply to Thread