I only get VisibilityNotify events at window mapping
Carsten Haitzler
raster at rasterman.com
Sat Sep 17 19:33:35 UTC 2022
On Sat, 17 Sep 2022 11:30:39 -0300 Lucas de Sena <lucas at seninha.org> said:
> 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 <stdio.h>
> #include <X11/Xlib.h>
>
> 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?
should i assume you're running in a composited environment? (i.e. a compositor
is running redirecting your window rendering to a pixmap)?
--
------------- Codito, ergo sum - "I code, therefore I am" --------------
Carsten Haitzler - raster at rasterman.com
More information about the xorg
mailing list