I am writing a X application, but when I execute the following code:
#include <X11/Xlib.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
Display* dpy = XOpenDisplay(getenv("DISPLAY"));
Drawable d = XCreateWindow(dpy, DefaultRootWindow(dpy), 10, 10,
640, 480, 0, CopyFromParent, InputOutput, CopyFromParent, 0, NULL);
XMapRaised(dpy, d);
XFlush(dpy);
XSelectInput(dpy, d, ExposureMask);
XEvent e;
while(e.type != Expose)
{
XNextEvent(dpy, &e);
}
sleep(10);
}
The window doesn't map correctly. It appears in the window list in my
taskbar, but it doesn't appear on the screen. When I set the border width
to something else than 0, like:
Drawable d = XCreateWindow(dpy, DefaultRootWindow(dpy), 10, 10,
640, 480, 1, CopyFromParent, InputOutput, CopyFromParent, 0, NULL);
The window does appear, but I don't want a border. What is my error?
Grtz,
Leon
I'm no X expert, but I tried this on my machine. With border width 1 I
only see a one-pixel border; the inside contains whatever was already
displayed in that area. This is easier to notice if you move the window
around; it keeps those contents (until something else gets drawn over
them).
With border width 0 I can still see a border. But if you can't (maybe
depending on your window manager) I suspect that your window is there,
but you can't see it because its contents are exactly the same as what's
underneath it. (It's perfectly camouflaged, if you like.) Again, if
you move it around you will probably see it move.
Once you get around to actually drawing something in the window, or
giving it a background, this shouldn't be an issue, I'd guess.
> #include <X11/Xlib.h>
> #include <stdlib.h>
Are you using Gnome? With that I get set same effect. But with
other window managers (KDE, fvwm2, twm, icewm etc.) the window
does appear with the decorations put around it. Even more inter-
estingly, when just running the window manager of Gnome, sawfish,
via Xnest, then the window also appears. So it looks like a pro-
blem that only concerns Gnome. And I guess that when you actually
try to draw something into that window it finally will become
visible.
Regards, Jens
--
\ Jens Thoms Toerring ___ j...@toerring.de
\__________________________ http://toerring.de
I am not sure if it is a problem with Gnome (i use Gnome), because the
window does appear when using XCreateSimpleWindow(...) with a border of
0. Also trying to draw stuff in the window didn't make any difference.
And as a reply to Nate:
The moving didn't make any difference too, and no window decorations
appeared too, so I don't think the whole window is actually drawn.
Grtz,
Leon
> I am not sure if it is a problem with Gnome (i use Gnome), because the
> window does appear when using XCreateSimpleWindow(...) with a border of
> 0. Also trying to draw stuff in the window didn't make any difference.
Just another data point: if I change the "Visual Effects" under
Gnome (use System->Preferences->Appearance) to None then the
window appears (at least the decorations are drawn, but then
there isn't much more to draw;-) Moreover, even if the window
isn't visible in any way it still gets found by xwininfo. So
to me it seems that the window is actually there, only for
some strange reasons Gnome (or metacity, I think that's now
the default Gnome window manager) doesn't draw its decora-
tions around it...
Having windows with a border width of 0 is quite normal and
I haven't seen this effect before with Gnome, but then I never
tried to just create a window without immediately drawing lots
of stuff into it...
Correction, painting did show the window.
Thanks!
> On Sun, 15 Feb 2009 09:44:07 +0000, Jens Thoms Toerring wrote:
>
>> The Doctor <TheD...@imnotemailable.org> wrote:
>>> I am writing a X application, but when I execute the following code:
[snip]
>>> The window doesn't map correctly. It appears in the window list in my
>>> taskbar, but it doesn't appear on the screen. When I set the border
>>> width to something else than 0, like:
>>
>>> Drawable d = XCreateWindow(dpy, DefaultRootWindow(dpy), 10, 10,
>>> 640, 480, 1, CopyFromParent, InputOutput, CopyFromParent, 0, NULL);
>>
>>> The window does appear, but I don't want a border. What is my error?
>>
>> Are you using Gnome? With that I get set same effect. But with other
>> window managers (KDE, fvwm2, twm, icewm etc.) the window does appear
>> with the decorations put around it. Even more inter- estingly, when just
>> running the window manager of Gnome, sawfish, via Xnest, then the window
>> also appears. So it looks like a pro- blem that only concerns Gnome. And
>> I guess that when you actually try to draw something into that window it
>> finally will become visible.
>> Regards, Jens
>
> I am not sure if it is a problem with Gnome (i use Gnome), because the
> window does appear when using XCreateSimpleWindow(...) with a border of
> 0. Also trying to draw stuff in the window didn't make any difference.
Note that XCreateSimpleWindow sets a background for the window!
> And as a reply to Nate:
> The moving didn't make any difference too, and no window decorations
> appeared too, so I don't think the whole window is actually drawn.
Suppressing the decorations might be a feature of your window manager.
By "moving the window", I meant move it around with the mouse. This
might be hard to do if your window manager doesn't give it decorations.
(I use awesome, a tiling window manager which never creates decorations
anyway, so this is not an issue.) Maybe you thought I meant just
creating it at a different position?
No, i understood what you meant. I moved the window by right-clicking on
its name in the task bar, and clicking 'move'. But it didn't appear. But
when i started painting the window, it suddenly appeared. I have no idea
what causes this problem, but it is 'solved'.
> Nate Eldredge <na...@vulcan.lan> wrote:
> > Suppressing the decorations might be a feature of your window manager.
As Nate wrote, it could be considered a feature since it avoids
having empty decorations on the screen. That might be visually
more pleasing with programs that first open a window and then
do a lot of time-consuming initialization before they start to
draw into that window.
|> No, i understood what you meant. I moved the window by right-clicking on
|> its name in the task bar, and clicking 'move'. But it didn't appear. But
|> when i started painting the window, it suddenly appeared. I have no idea
|> what causes this problem, but it is 'solved'.
Try XSync(dpy,0) instead of XFlush.
--
Georg Acher, ac...@in.tum.de
http://www.lrr.in.tum.de/~acher
"Oh no, not again !" The bowl of petunias