From ae57d1386866ecc9e9a86f622dce976db01359c2 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sat, 11 Sep 2010 15:14:57 +0200 Subject: [PATCH] Made active window state global. --- src/internal.h | 2 +- src/window.c | 5 ++++- src/x11/x11_window.c | 9 +++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/internal.h b/src/internal.h index 61b2b763..e49277c3 100644 --- a/src/internal.h +++ b/src/internal.h @@ -153,7 +153,6 @@ typedef struct _GLFWwindow GLFWcharfun charCallback; // Window settings and state - GLboolean active; // GL_TRUE if this window is active GLboolean iconified; // GL_TRUE if this window is iconified GLboolean closed; // GL_TRUE if this window should be closed int width, height; @@ -208,6 +207,7 @@ typedef struct _GLFWlibrary _GLFWwindow* windowListHead; _GLFWwindow* currentWindow; + _GLFWwindow* activeWindow; _GLFWwindow* cursorLockWindow; _GLFW_PLATFORM_LIBRARY_STATE; diff --git a/src/window.c b/src/window.c index bc30ab2b..cbd6dce7 100644 --- a/src/window.c +++ b/src/window.c @@ -695,6 +695,9 @@ GLFWAPI void glfwCloseWindow(GLFWwindow window) if (window == _glfwLibrary.currentWindow) glfwMakeWindowCurrent(NULL); + if (window == _glfwLibrary.activeWindow) + _glfwLibrary.activeWindow = NULL; + _glfwPlatformCloseWindow(window); prev = &_glfwLibrary.windowListHead; @@ -900,7 +903,7 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow window, int param) switch (param) { case GLFW_ACTIVE: - return window->active; + return window == _glfwLibrary.activeWindow; case GLFW_ICONIFIED: return window->iconified; case GLFW_ACCELERATED: diff --git a/src/x11/x11_window.c b/src/x11/x11_window.c index 4b0ead93..2fac1527 100644 --- a/src/x11/x11_window.c +++ b/src/x11/x11_window.c @@ -1321,7 +1321,7 @@ static void processSingleEvent(void) return; } - window->active = GL_TRUE; + _glfwLibrary.activeWindow = window; if (_glfwLibrary.cursorLockWindow == window) _glfwPlatformHideMouseCursor(window); @@ -1339,7 +1339,9 @@ static void processSingleEvent(void) return; } - window->active = GL_FALSE; + if (_glfwLibrary.activeWindow == window) + _glfwLibrary.activeWindow = NULL; + _glfwInputDeactivation(window); if (_glfwLibrary.cursorLockWindow == window) @@ -1506,6 +1508,9 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window) if (window->mode == GLFW_FULLSCREEN) leaveFullscreenMode(window); + if (_glfwLibrary.activeWindow == window) + _glfwLibrary.activeWindow = NULL; + if (window->GLX.context) { // Release and destroy the context