I only get VisibilityNotify events at window mapping
Vito Caputo
xorg at pengaru.com
Sun Sep 18 23:37:40 UTC 2022
On Sun, Sep 18, 2022 at 07:00:41PM -0400, Chris Sorenson wrote:
> >
>
> > Date: Sat, 17 Sep 2022 11:30:39 -0300
> > From: Lucas de Sena
> > To: xorg at lists.x.org
> > Subject: I only get VisibilityNotify events at window mapping
> > Message-ID:
> > Content-Type: text/plain; charset=us-ascii
> >
> > Hi,
> >
> > I'm trying to get VisibilityNotify events to check whether a given
> > window is obscured.
> >
> > However, I only get VisibilityNotify events after mapping the window.
> > Obscuring it with any other window (be it a sibling or not) does not
> > trigger a VisibilityNotify event, nor when I unobscure it.
> >
> > And when I get such event, the value of `ev.xvisibility.state` is always
> > `VisibilityUnobscured`, even when mapping the window below others.
> >
> > Here's a sample program:
> >
> > #include
> > #include
> >
> > int
> > main(void)
> > {
> > Display *dpy;
> > Window win;
> > XEvent ev;
> >
> > if ((dpy = XOpenDisplay(NULL)) == NULL)
> > return 1;
> > win = XCreateWindow(
> > dpy,
> > XDefaultRootWindow(dpy),
> > 0, 0,
> > 100, 100,
> > 0,
> > CopyFromParent, InputOutput, CopyFromParent,
> > CWEventMask | CWBackPixel,
> > &(XSetWindowAttributes){
> > .event_mask = VisibilityChangeMask,
> > .background_pixel = BlackPixel(dpy, DefaultScreen(dpy)),
> > }
> > );
> > XMapWindow(dpy, win);
> > while (!XNextEvent(dpy, &ev))
> > if (ev.type == VisibilityNotify)
> > printf("visibility: %d\n", ev.xvisibility.state);
> > return 0;
> > }
> >
> > Is that how VisibilityNotify is supposed to work?
> >
>
> It works perfectly for me using MWM (Motif Window Manager)
It's a compositing-specific limitation:
https://gitlab.freedesktop.org/xorg/xserver/-/blob/master/mi/mivaltree.c#L171
When the windows are all RedirectManual, e.g.
XCompositeRedirectSubwindows(disp, root, CompositeRedirectManual);
Xorg-xserver just assumes they're transparent.
Cheers,
Vito Caputo
More information about the xorg
mailing list