I only get VisibilityNotify events at window mapping

Chris Sorenson csoren at cpinternet.com
Sun Sep 18 23:00:41 UTC 2022


>

> 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)


More information about the xorg mailing list