Explicitly unmap iconified windows before restoring them.

Closes: #2077
This commit is contained in:
Rémi Bernon 2025-02-17 10:51:43 +01:00
parent e7ea71be03
commit 54ecc8a9f5
No known key found for this signature in database
GPG Key ID: 38D0E5827B54E5C9
2 changed files with 10 additions and 1 deletions

View File

@ -2339,6 +2339,9 @@ void _glfwRestoreWindowX11(_GLFWwindow* window)
if (_glfwWindowIconifiedX11(window)) if (_glfwWindowIconifiedX11(window))
{ {
// Some window managers do not unmap iconified windows, and XMapWindow is
// then no-op. Explicitly unmap the window to make sure it gets restored.
XUnmapWindow(_glfw.x11.display, window->x11.handle);
XMapWindow(_glfw.x11.display, window->x11.handle); XMapWindow(_glfw.x11.display, window->x11.handle);
waitForVisibilityNotify(window); waitForVisibilityNotify(window);
} }

View File

@ -56,6 +56,8 @@ static void error_callback(int error, const char* description)
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{ {
static GLFWwindow *iconified;
printf("%0.2f Key %s\n", printf("%0.2f Key %s\n",
glfwGetTime(), glfwGetTime(),
action == GLFW_PRESS ? "pressed" : "released"); action == GLFW_PRESS ? "pressed" : "released");
@ -67,12 +69,15 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
{ {
case GLFW_KEY_I: case GLFW_KEY_I:
glfwIconifyWindow(window); glfwIconifyWindow(window);
iconified = window;
break; break;
case GLFW_KEY_M: case GLFW_KEY_M:
glfwMaximizeWindow(window); glfwMaximizeWindow(window);
break; break;
case GLFW_KEY_R: case GLFW_KEY_R:
if (iconified) window = iconified;
glfwRestoreWindow(window); glfwRestoreWindow(window);
iconified = NULL;
break; break;
case GLFW_KEY_ESCAPE: case GLFW_KEY_ESCAPE:
glfwSetWindowShouldClose(window, GLFW_TRUE); glfwSetWindowShouldClose(window, GLFW_TRUE);
@ -253,9 +258,10 @@ int main(int argc, char** argv)
if (fullscreen) if (fullscreen)
monitor = glfwGetPrimaryMonitor(); monitor = glfwGetPrimaryMonitor();
window_count = 1; window_count = 2;
windows = calloc(window_count, sizeof(GLFWwindow*)); windows = calloc(window_count, sizeof(GLFWwindow*));
windows[0] = create_window(monitor); windows[0] = create_window(monitor);
windows[1] = create_window(monitor);
} }
for (i = 0; i < window_count; i++) for (i = 0; i < window_count; i++)