From 14355d692fc4c8ac4446cda6ddeda650a0c36ef4 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 22 Nov 2012 17:04:44 +0100 Subject: [PATCH] Fixed active/focused nomenclature mixing. --- include/GL/glfw3.h | 10 +++++----- readme.html | 1 + src/init.c | 4 ++-- src/input.c | 4 ++-- src/internal.h | 4 ++-- src/win32_window.c | 36 ++++++++++++++++++------------------ src/window.c | 26 +++++++++++++------------- src/x11_window.c | 6 +++--- tests/events.c | 4 ++-- tests/fsfocus.c | 6 +++--- tests/iconify.c | 6 +++--- 11 files changed, 54 insertions(+), 53 deletions(-) diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 957adbd0..73a84d07 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -462,9 +462,9 @@ extern "C" { * @ingroup window * @{ */ -/*! @brief @c GL_TRUE if the window is active, or @c GL_FALSE otherwise. +/*! @brief @c GL_TRUE if the window has focus, or @c GL_FALSE otherwise. */ -#define GLFW_ACTIVE 0x00020001 +#define GLFW_FOCUSED 0x00020001 /*! @brief @c GL_TRUE if the window is iconified, or @c GL_FALSE otherwise. */ #define GLFW_ICONIFIED 0x00020002 @@ -679,9 +679,9 @@ extern "C" { * more specific categories. */ #define GLFW_PLATFORM_ERROR 0x00070008 -/*! @brief The specified window needed to be active for the call to succeed. +/*! @brief The specified window needed to be focused for the call to succeed. */ -#define GLFW_WINDOW_NOT_ACTIVE 0x00070009 +#define GLFW_WINDOW_NOT_FOCUSED 0x00070009 /*! @brief The clipboard did not contain data in the requested format. */ #define GLFW_FORMAT_UNAVAILABLE 0x0007000A @@ -1332,7 +1332,7 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow window, int* xpos, int* ypos); * client area, or @c NULL. * @ingroup input * - * @note The specified window must be active. + * @note The specified window must be focused. * * @sa glfwGetCursorPos */ diff --git a/readme.html b/readme.html index cf5eb5b8..d73fa539 100644 --- a/readme.html +++ b/readme.html @@ -298,6 +298,7 @@ version of GLFW.

  • Changed glfwGetVideoModes to return a dynamic, unlimited number of video modes
  • Renamed glfw.h to glfw3.h to avoid conflicts with 2.x series
  • Renamed glfwOpenWindowHint to glfwWindowHint
  • +
  • Renamed GLFW_ACTIVE to GLFW_FOCUSED
  • Renamed GLFW_WINDOW token to GLFW_WINDOWED
  • Renamed GLFW_WINDOW_NO_RESIZE to GLFW_RESIZABLE
  • Renamed GLFW_BUILD_DLL to _GLFW_BUILD_DLL
  • diff --git a/src/init.c b/src/init.c index efcea20c..fd7d5833 100644 --- a/src/init.c +++ b/src/init.c @@ -228,8 +228,8 @@ GLFWAPI const char* glfwErrorString(int error) return "The requested OpenGL version is unavailable"; case GLFW_PLATFORM_ERROR: return "A platform-specific error occurred"; - case GLFW_WINDOW_NOT_ACTIVE: - return "The specified window is not active"; + case GLFW_WINDOW_NOT_FOCUSED: + return "The specified window is not focused"; case GLFW_FORMAT_UNAVAILABLE: return "The requested format is unavailable"; } diff --git a/src/input.c b/src/input.c index 46c9da6e..66e82b68 100644 --- a/src/input.c +++ b/src/input.c @@ -422,9 +422,9 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow handle, int xpos, int ypos) return; } - if (_glfwLibrary.activeWindow != window) + if (_glfwLibrary.focusedWindow != window) { - _glfwSetError(GLFW_WINDOW_NOT_ACTIVE, NULL); + _glfwSetError(GLFW_WINDOW_NOT_FOCUSED, NULL); return; } diff --git a/src/internal.h b/src/internal.h index 50bfa4c6..c4ac9d2d 100644 --- a/src/internal.h +++ b/src/internal.h @@ -226,7 +226,7 @@ struct _GLFWlibrary _GLFWhints hints; _GLFWwindow* windowListHead; - _GLFWwindow* activeWindow; + _GLFWwindow* focusedWindow; GLFWgammaramp currentRamp; GLFWgammaramp originalRamp; @@ -321,7 +321,7 @@ void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long //======================================================================== // Window event notification (window.c) -void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated); +void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean focused); void _glfwInputWindowPos(_GLFWwindow* window, int x, int y); void _glfwInputWindowSize(_GLFWwindow* window, int width, int height); void _glfwInputWindowIconify(_GLFWwindow* window, int iconified); diff --git a/src/win32_window.c b/src/win32_window.c index fd342da6..a99f08dd 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -328,22 +328,22 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_ACTIVATE: { - // Window was (de)activated and/or (de)iconified + // Window was (de)focused and/or (de)iconified - BOOL active = LOWORD(wParam) != WA_INACTIVE; + BOOL focused = LOWORD(wParam) != WA_INACTIVE; BOOL iconified = HIWORD(wParam) ? TRUE : FALSE; - if (active && iconified) + if (focused && iconified) { // This is a workaround for window iconification using the - // taskbar leading to windows being told they're active and - // iconified and then never told they're deactivated - active = FALSE; + // taskbar leading to windows being told they're focused and + // iconified and then never told they're defocused + focused = FALSE; } - if (!active && _glfwLibrary.activeWindow == window) + if (!focused && _glfwLibrary.focusedWindow == window) { - // The window was deactivated (or iconified, see above) + // The window was defocused (or iconified, see above) if (window->cursorMode == GLFW_CURSOR_CAPTURED) showCursor(window); @@ -364,9 +364,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, } } } - else if (active && _glfwLibrary.activeWindow != window) + else if (focused && _glfwLibrary.focusedWindow != window) { - // The window was activated + // The window was focused if (window->cursorMode == GLFW_CURSOR_CAPTURED) captureCursor(window); @@ -386,7 +386,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, } } - _glfwInputWindowFocus(window, active); + _glfwInputWindowFocus(window, focused); _glfwInputWindowIconify(window, iconified); return 0; } @@ -544,7 +544,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (window->cursorMode == GLFW_CURSOR_CAPTURED) { - if (_glfwLibrary.activeWindow != window) + if (_glfwLibrary.focusedWindow != window) return 0; x = newCursorX - window->Win32.oldCursorX; @@ -829,8 +829,8 @@ static void destroyWindow(_GLFWwindow* window) // This is duplicated from glfwDestroyWindow // TODO: Stop duplicating code - if (window == _glfwLibrary.activeWindow) - _glfwLibrary.activeWindow = NULL; + if (window == _glfwLibrary.focusedWindow) + _glfwLibrary.focusedWindow = NULL; if (window->Win32.handle) { @@ -1132,7 +1132,7 @@ void _glfwPlatformPollEvents(void) MSG msg; _GLFWwindow* window; - window = _glfwLibrary.activeWindow; + window = _glfwLibrary.focusedWindow; if (window) { window->Win32.cursorCentered = GL_FALSE; @@ -1168,7 +1168,7 @@ void _glfwPlatformPollEvents(void) // LSHIFT/RSHIFT fixup (keys tend to "stick" without this fix) // This is the only async event handling in GLFW, but it solves some // nasty problems. - window = _glfwLibrary.activeWindow; + window = _glfwLibrary.focusedWindow; if (window) { int lshift_down, rshift_down; @@ -1186,8 +1186,8 @@ void _glfwPlatformPollEvents(void) _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, GLFW_RELEASE); } - // Did the cursor move in an active window that has captured the cursor - window = _glfwLibrary.activeWindow; + // Did the cursor move in an focused window that has captured the cursor + window = _glfwLibrary.focusedWindow; if (window) { if (window->cursorMode == GLFW_CURSOR_CAPTURED && diff --git a/src/window.c b/src/window.c index 73bc1698..ed6d2435 100644 --- a/src/window.c +++ b/src/window.c @@ -72,21 +72,21 @@ static void clearScrollOffsets(void) // Register window focus events //======================================================================== -void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated) +void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean focused) { - if (activated) + if (focused) { - if (_glfwLibrary.activeWindow != window) + if (_glfwLibrary.focusedWindow != window) { - _glfwLibrary.activeWindow = window; + _glfwLibrary.focusedWindow = window; if (window->windowFocusCallback) - window->windowFocusCallback(window, activated); + window->windowFocusCallback(window, focused); } } else { - if (_glfwLibrary.activeWindow == window) + if (_glfwLibrary.focusedWindow == window) { int i; @@ -104,10 +104,10 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated) _glfwInputMouseClick(window, i, GLFW_RELEASE); } - _glfwLibrary.activeWindow = NULL; + _glfwLibrary.focusedWindow = NULL; if (window->windowFocusCallback) - window->windowFocusCallback(window, activated); + window->windowFocusCallback(window, focused); } } } @@ -502,9 +502,9 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow handle) if (window == _glfwPlatformGetCurrentContext()) _glfwPlatformMakeContextCurrent(NULL); - // Clear the active window pointer if this is the active window - if (window == _glfwLibrary.activeWindow) - _glfwLibrary.activeWindow = NULL; + // Clear the focused window pointer if this is the focused window + if (window == _glfwLibrary.focusedWindow) + _glfwLibrary.focusedWindow = NULL; _glfwPlatformDestroyWindow(window); @@ -700,8 +700,8 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param) switch (param) { - case GLFW_ACTIVE: - return window == _glfwLibrary.activeWindow; + case GLFW_FOCUSED: + return window == _glfwLibrary.focusedWindow; case GLFW_ICONIFIED: return window->iconified; case GLFW_CLOSE_REQUESTED: diff --git a/src/x11_window.c b/src/x11_window.c index 28724750..01ba91ec 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -632,7 +632,7 @@ static void processEvent(XEvent *event) if (window->cursorMode == GLFW_CURSOR_CAPTURED) { - if (_glfwLibrary.activeWindow != window) + if (_glfwLibrary.focusedWindow != window) break; x = event->xmotion.x - window->X11.cursorPosX; @@ -1134,11 +1134,11 @@ void _glfwPlatformPollEvents(void) processEvent(&event); } - // Check whether the cursor has moved inside an active window that has + // Check whether the cursor has moved inside an focused window that has // captured the cursor (because then it needs to be re-centered) _GLFWwindow* window; - window = _glfwLibrary.activeWindow; + window = _glfwLibrary.focusedWindow; if (window) { if (window->cursorMode == GLFW_CURSOR_CAPTURED && diff --git a/tests/events.c b/tests/events.c index 4e3002cf..3bd0d82e 100644 --- a/tests/events.c +++ b/tests/events.c @@ -248,12 +248,12 @@ static void window_refresh_callback(GLFWwindow window) } } -static void window_focus_callback(GLFWwindow window, int activated) +static void window_focus_callback(GLFWwindow window, int focused) { printf("%08x at %0.3f: Window %s\n", counter++, glfwGetTime(), - activated ? "activated" : "deactivated"); + focused ? "focused" : "defocused"); } static void window_iconify_callback(GLFWwindow window, int iconified) diff --git a/tests/fsfocus.c b/tests/fsfocus.c index 17ffc35f..a87d136a 100644 --- a/tests/fsfocus.c +++ b/tests/fsfocus.c @@ -23,7 +23,7 @@ // //======================================================================== // -// This test is used to test window activation and iconfication for +// This test is used to test window focusing and iconfication for // fullscreen windows with a video mode differing from the desktop mode // //======================================================================== @@ -35,11 +35,11 @@ static GLboolean running = GL_TRUE; -static void window_focus_callback(GLFWwindow window, int activated) +static void window_focus_callback(GLFWwindow window, int focused) { printf("%0.3f: Window %s\n", glfwGetTime(), - activated ? "activated" : "deactivated"); + focused ? "focused" : "defocused"); } static void window_key_callback(GLFWwindow window, int key, int action) diff --git a/tests/iconify.c b/tests/iconify.c index f7a87cba..e10571c8 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -75,11 +75,11 @@ static void window_size_callback(GLFWwindow window, int width, int height) glViewport(0, 0, width, height); } -static void window_focus_callback(GLFWwindow window, int activated) +static void window_focus_callback(GLFWwindow window, int focused) { printf("%0.2f Window %s\n", glfwGetTime(), - activated ? "activated" : "deactivated"); + focused ? "focused" : "defocused"); } static void window_iconify_callback(GLFWwindow window, int iconified) @@ -152,7 +152,7 @@ int main(int argc, char** argv) printf("Window is %s and %s\n", glfwGetWindowParam(window, GLFW_ICONIFIED) ? "iconified" : "restored", - glfwGetWindowParam(window, GLFW_ACTIVE) ? "active" : "inactive"); + glfwGetWindowParam(window, GLFW_FOCUSED) ? "focused" : "defocused"); glEnable(GL_SCISSOR_TEST);