From 8fe65911163c37a9e292aca524377076a99589ee Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 17 Nov 2019 13:08:38 +0100 Subject: X11: Track visibility via system events This ensure that visibility is properly updated when a window is made visible or invisible by the user or window system. Unfortunately it does not seem to propagate automatically to child windows, but this is at least better than the previous situation, and good enough for most cases. --- pugl/detail/x11.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'pugl') diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index 847c092..8a24917 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -61,7 +61,8 @@ enum WmClientStateMessageAction { }; static const long eventMask = - (ExposureMask | StructureNotifyMask | FocusChangeMask | + (ExposureMask | StructureNotifyMask | + VisibilityChangeMask | FocusChangeMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask); @@ -259,7 +260,6 @@ puglShowWindow(PuglView* view) { XMapRaised(view->impl->display, view->impl->win); puglPostRedisplay(view); - view->visible = true; return PUGL_SUCCESS; } @@ -267,7 +267,6 @@ PuglStatus puglHideWindow(PuglView* view) { XUnmapWindow(view->impl->display, view->impl->win); - view->visible = false; return PUGL_SUCCESS; } @@ -421,6 +420,9 @@ translateEvent(PuglView* view, XEvent xevent) } } break; + case VisibilityNotify: + view->visible = xevent.xvisibility.state != VisibilityFullyObscured; + break; case MapNotify: { XWindowAttributes attrs = {0}; XGetWindowAttributes(view->impl->display, view->impl->win, &attrs); @@ -431,6 +433,9 @@ translateEvent(PuglView* view, XEvent xevent) event.configure.height = attrs.height; break; } + case UnmapNotify: + view->visible = false; + break; case ConfigureNotify: event.type = PUGL_CONFIGURE; event.configure.x = xevent.xconfigure.x; -- cgit v1.2.1