window manager rudely overwrites part of my window - Xwindows

This is a discussion on window manager rudely overwrites part of my window - Xwindows ; Hello, I just started learning X programming this week in my spare time. I'm currently working through basic examples and tutorials from the web. When I create a window, my window manager (quite rudely, I must say) overwrites the top ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: window manager rudely overwrites part of my window

  1. window manager rudely overwrites part of my window

    Hello,

    I just started learning X programming this week in my spare time.
    I'm currently working through basic examples and tutorials from the
    web.

    When I create a window, my window manager (quite rudely, I must say)
    overwrites the top part of my window with the title bar. I always
    assumed that the window manager would "grow" the title bar from the
    top of my window.

    As I don't think an application should know anything about the
    window manager, how do I get around this? Right now, I've basically
    got a kludge factor that adds extra height to my window. Certainly
    there's a better way though!

    Thanks!
    Matt

    --
    Matt Garman
    email at: http://raw-sewage.net/index.php?file=email

  2. Re: window manager rudely overwrites part of my window

    What is your window manager?

    --- Casantos


  3. Re: window manager rudely overwrites part of my window

    On 18 Sep 2005 16:13:58 -0700, nojunk@gate.cpmet.ufpel.tche.br
    wrote:
    > What is your window manager?


    Enlightenment DR 0.16.7.2.

    I also tried it with Fluxbox 0.9.14, same result.

    There's another thread about this over on comp.unix.programmer,
    where I actually posted the code. One poster said that it worked
    just fine for him, so I'm pretty confused as to what the problem is.

    I guess I can try some more window managers.

    Thanks!
    Matt

    --
    Matt Garman
    email at: http://raw-sewage.net/index.php?file=email

  4. Re: window manager rudely overwrites part of my window

    Matt Garman writes:

    > On 18 Sep 2005 16:13:58 -0700, nojunk@gate.cpmet.ufpel.tche.br
    > wrote:
    >> What is your window manager?

    >
    > Enlightenment DR 0.16.7.2.
    >
    > I also tried it with Fluxbox 0.9.14, same result.
    >
    > There's another thread about this over on comp.unix.programmer,
    > where I actually posted the code. One poster said that it worked
    > just fine for him, so I'm pretty confused as to what the problem is.


    That was me.

    Now try the program below. It should display a 50x50 window with a
    white background divided into a 5x5 grid by black lines 10 pixels
    apart. Run the program, and if it doesn't display what it should,
    make a screenshot available somewhere.

    #include
    #include
    #include
    #include
    #include

    int
    main(int argc, char **argv)
    {
    Display *dpy;
    Window w;
    GC gc;
    XGCValues gcv;
    int run = 1;

    if(!(dpy = XOpenDisplay(NULL)))
    return 1;

    w = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, 50, 50, 0,
    CopyFromParent, InputOutput, CopyFromParent, 0, NULL);

    gcv.foreground = BlackPixel(dpy, DefaultScreen(dpy));
    gcv.line_width = 1;
    gcv.line_style = LineSolid;

    gc = XCreateGC(dpy, w, GCForeground | GCLineWidth | GCLineStyle, &gcv);
    XSetWindowBackground(dpy, w, WhitePixel(dpy, DefaultScreen(dpy)));
    XSelectInput(dpy, w, ExposureMask | KeyPressMask);
    XMapWindow(dpy, w);
    XSync(dpy, False);

    while(run){
    XEvent xe;
    int i;

    XNextEvent(dpy, &xe);
    switch(xe.type){
    case Expose:
    for(i = 10; i < 50; i += 10)
    XDrawLine(dpy, w, gc, i, 0, i, 50);
    for(i = 10; i < 50; i += 10)
    XDrawLine(dpy, w, gc, 0, i, 50, i);
    break;
    case KeyPress:
    run = 0;
    break;
    }
    }

    XDestroyWindow(dpy, w);
    XCloseDisplay(dpy);

    return 0;
    }


    --
    Måns Rullgård
    mru@inprovide.com

  5. Re: window manager rudely overwrites part of my window

    On Mon, 19 Sep 2005 19:42:23 +0100, Måns Rullgård wrote:
    > Matt Garman writes:
    > > There's another thread about this over on comp.unix.programmer,
    > > where I actually posted the code. One poster said that it worked
    > > just fine for him, so I'm pretty confused as to what the problem is.

    >
    > That was me.


    Hehe, I see we're talking on two different newsgroups now!

    At any rate, I was seeing this behavior in both Fluxbox and
    Enlightenment. When I tried FVWM, my application didn't show
    anything in the window (it was "transparent").

    So I asked about that on the FVWM mailing list, and someone there
    suggested that you shouldn't draw to the window until receiving an
    expose event.

    This looks like what your program below is doing---not drawing until
    an expose event has been received.

    Perhaps this is also what is causing my titlebar-overwrites-window
    problem?

    > Now try the program below. It should display a 50x50 window with
    > a white background divided into a 5x5 grid by black lines 10
    > pixels apart. Run the program, and if it doesn't display what it
    > should, make a screenshot available somewhere.


    Will do, thank you very much!

    I have a feeling that waiting for the expose event before drawing
    might fix my problem, but won't be able to test that until tonight.

    At any rate, why don't the tutorials teach that?!

    Thanks again,
    Much appreciated,
    Matt

    --
    Matt Garman
    email at: http://raw-sewage.net/index.php?file=email

  6. Re: window manager rudely overwrites part of my window

    Matt Garman writes:

    > On Mon, 19 Sep 2005 19:42:23 +0100, Måns Rullgård wrote:
    >> Matt Garman writes:
    >> > There's another thread about this over on comp.unix.programmer,
    >> > where I actually posted the code. One poster said that it worked
    >> > just fine for him, so I'm pretty confused as to what the problem is.

    >>
    >> That was me.

    >
    > Hehe, I see we're talking on two different newsgroups now!
    >
    > At any rate, I was seeing this behavior in both Fluxbox and
    > Enlightenment. When I tried FVWM, my application didn't show
    > anything in the window (it was "transparent").
    >
    > So I asked about that on the FVWM mailing list, and someone there
    > suggested that you shouldn't draw to the window until receiving an
    > expose event.


    Before you get the expose event your window might not be visible.
    Drawing to it will still work, but whatever is drawn will be lost.
    The reason it does not generate an error is that it simplifies
    programming, since you don't need to care about which areas of a
    window are visible. In performance critical situations, you might
    still want to draw only to the visible parts, but there is no
    requirement to do so.

    You will also have to redraw your window after every expose event (or
    the part that the expose event tells you just got visible).

    > This looks like what your program below is doing---not drawing until
    > an expose event has been received.
    >
    > Perhaps this is also what is causing my titlebar-overwrites-window
    > problem?


    It could very well be related.

    >> Now try the program below. It should display a 50x50 window with
    >> a white background divided into a 5x5 grid by black lines 10
    >> pixels apart. Run the program, and if it doesn't display what it
    >> should, make a screenshot available somewhere.

    >
    > Will do, thank you very much!
    >
    > I have a feeling that waiting for the expose event before drawing
    > might fix my problem, but won't be able to test that until tonight.
    >
    > At any rate, why don't the tutorials teach that?!


    Don't know, didn't read them. It can all be inferred from the
    information in the Xlib manual, if you read it carefully.

    --
    Måns Rullgård
    mru@inprovide.com

+ Reply to Thread