From 58de77fc496cc978312dfdd1adfdc097f2c49850 Mon Sep 17 00:00:00 2001 From: MALET Jean-Luc Date: Sun, 28 Feb 2021 18:52:09 +0100 Subject: [PATCH] handle VisibilityNotify on x11 so that a window that is mapped but covered by another window is considered as not visible --- src/internal.h | 1 + src/x11_window.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/internal.h b/src/internal.h index f87c2f93..bfc25f44 100644 --- a/src/internal.h +++ b/src/internal.h @@ -383,6 +383,7 @@ struct _GLFWwindow GLFWbool focusOnShow; GLFWbool mousePassthrough; GLFWbool shouldClose; + GLFWbool visible; void* userPointer; GLFWvidmode videoMode; _GLFWmonitor* monitor; diff --git a/src/x11_window.c b/src/x11_window.c index a85688e1..e04f1213 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -119,7 +119,7 @@ static GLFWbool waitForVisibilityNotify(_GLFWwindow* window) if (!waitForEvent(&timeout)) return GLFW_FALSE; } - + window->visible = GLFW_TRUE; return GLFW_TRUE; } @@ -1838,6 +1838,12 @@ static void processEvent(XEvent *event) return; } + case VisibilityNotify : + { + if (event->xvisibility.state == VisibilityFullyObscured) window->visible = GLFW_FALSE; + else window->visible = GLFW_TRUE; + } + case DestroyNotify: return; } @@ -2529,7 +2535,7 @@ int _glfwPlatformWindowVisible(_GLFWwindow* window) { XWindowAttributes wa; XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &wa); - return wa.map_state == IsViewable; + return wa.map_state == IsViewable && window->visible == GLFW_TRUE; } int _glfwPlatformWindowMaximized(_GLFWwindow* window)