aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-11-17 13:08:38 +0100
committerDavid Robillard <d@drobilla.net>2019-11-17 13:10:49 +0100
commit8fe65911163c37a9e292aca524377076a99589ee (patch)
treed18759ace6de4a0c93e40a992b573971da9fd038
parent78e402bea78f54a272e4cfb7152f7e8bf4ab0dfa (diff)
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.
-rw-r--r--pugl/detail/x11.c11
1 files changed, 8 insertions, 3 deletions
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;