Creation of toolbar-like frames - Xwindows

This is a discussion on Creation of toolbar-like frames - Xwindows ; Hi, I'm trying to create a C++ widget: I would like to create a sort of miniframe like those containing detached toolbars. They are top level windows with no borders. My window is able to draw all itselfs: its caption ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Creation of toolbar-like frames

  1. Creation of toolbar-like frames

    Hi,
    I'm trying to create a C++ widget: I would like to create a sort of
    miniframe like those containing detached toolbars.
    They are top level windows with no borders. My window is able to draw all
    itselfs: its caption bar, its title; the problem is
    that I don't manage to create a toplevel window, _not_ clipped against its
    parent (it must be able to float out of parent's
    client area), with no borders: that is, without WM decorations.
    I tried this pseudo-code:

    XSetWindowAttributes xattributes;
    long xattributes_mask =
    CWBorderPixel | CWBackPixel;

    xattributes_mask |= CWOverrideRedirect;
    xattributes.override_redirect = True;

    xattributes_mask |= CWEventMask;
    xattributes.event_mask = [....];

    xattributes.background_pixel = m_backgroundColour.GetPixel();
    xattributes.border_pixel = BlackPixel( xdisplay, xscreen );

    myxwindow = XCreateWindow( xdisplay, xparent, m_x, m_y, m_width,
    m_height,
    0, DefaultDepth(xdisplay,xscreen),
    InputOutput, DefaultVisual(xdisplay, xscreen), xattributes_mask,
    &xattributes );

    XSetTransientForHint( xdisplay, myxwindow, RootWindow(xdisplay,
    xscreen) );

    In this way I get exactly what I want except for one thing: the frame which
    is created is *always* over *all* other windows: if I
    open another application/window (KWrite, Kate, .....) my frame is not
    hidden: it stays above all the windows.
    I also tried the following code to avoid this unwanted behaviour:

    XWindowChanges xwc;
    xwc.stack_mode = Above;
    xwc.sibling = (Window)xparentwnd;
    xwc.x = xwc.y = 0;
    xwc.width = xwc.height = 0;
    xwc.border_width = 0;

    XConfigureWindow(xd, w, CWStackMode, &xwc);

    But it doesn't work: I cannot manage to create a toplevel window without WM
    decorations.... any idea ?

    Thank you very much,
    Francesco Montorsi






  2. Re: Creation of toolbar-like frames

    Francesco wrote:

    > I'm trying to create a C++ widget: I would like to create a sort of
    > miniframe like those containing detached toolbars.
    > They are top level windows with no borders. My window is able to draw all
    > itselfs: its caption bar, its title; the problem is
    > that I don't manage to create a toplevel window, _not_ clipped against its
    > parent (it must be able to float out of parent's
    > client area), with no borders: that is, without WM decorations.
    > I tried this pseudo-code:

    [...]
    > xattributes_mask |= CWOverrideRedirect;
    > xattributes.override_redirect = True;

    [...]
    > myxwindow = XCreateWindow( xdisplay, xparent, m_x, m_y, m_width,
    > m_height,
    > 0, DefaultDepth(xdisplay,xscreen),
    > InputOutput, DefaultVisual(xdisplay, xscreen), xattributes_mask,
    > &xattributes );
    >
    > XSetTransientForHint( xdisplay, myxwindow, RootWindow(xdisplay,
    > xscreen) );


    This is a hint for the WM, who is bypassed by setting override_redirect.
    So it will have no effect.

    > In this way I get exactly what I want except for one thing: the frame which
    > is created is *always* over *all* other windows: if I
    > open another application/window (KWrite, Kate, .....) my frame is not
    > hidden: it stays above all the windows.
    > I also tried the following code to avoid this unwanted behaviour:
    >
    > XWindowChanges xwc;
    > xwc.stack_mode = Above;
    > xwc.sibling = (Window)xparentwnd;
    > xwc.x = xwc.y = 0;
    > xwc.width = xwc.height = 0;
    > xwc.border_width = 0;
    >
    > XConfigureWindow(xd, w, CWStackMode, &xwc);


    You gave no hint, that you specified the sibling information, so it is
    ignored. Instead the window is placed at the top of the stack. Try:

    XConfigureWindow(xd, w, CWStackMode|CWSibling, &xwc);

    > But it doesn't work: I cannot manage to create a toplevel window without WM
    > decorations.... any idea ?


    Above you wrote, you could create a window w/o WM decoration!?

    Regards,
    Daniel

  3. Re: Creation of toolbar-like frames

    Francesco wrote:
    [snip]
    >
    >In this way I get exactly what I want except for one thing: the frame which
    >is created is *always* over *all* other windows: if I
    >open another application/window (KWrite, Kate, .....) my frame is not
    >hidden: it stays above all the windows.
    >I also tried the following code to avoid this unwanted behaviour:
    >
    > XWindowChanges xwc;
    > xwc.stack_mode = Above;
    > xwc.sibling = (Window)xparentwnd;
    > xwc.x = xwc.y = 0;
    > xwc.width = xwc.height = 0;
    > xwc.border_width = 0;
    >
    > XConfigureWindow(xd, w, CWStackMode, &xwc);
    >
    >But it doesn't work: I cannot manage to create a toplevel window without WM
    >decorations.... any idea ?


    First, you need the CWSibling flag in XConfigureWindow. Without it,
    you are requesting that your window be put on top, and that is exactly
    what is happening.

    Second, you should be accepting StructureNotify events on the window,
    and re-issuing XConfigureWindow whenever the "above" field of an
    XConfigureEvent is not the parent window.


+ Reply to Thread