mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 10:05:10 +00:00
Fixed active/focused nomenclature mixing.
This commit is contained in:
parent
bce2cd65e1
commit
14355d692f
@ -462,9 +462,9 @@ extern "C" {
|
|||||||
* @ingroup window
|
* @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.
|
/*! @brief @c GL_TRUE if the window is iconified, or @c GL_FALSE otherwise.
|
||||||
*/
|
*/
|
||||||
#define GLFW_ICONIFIED 0x00020002
|
#define GLFW_ICONIFIED 0x00020002
|
||||||
@ -679,9 +679,9 @@ extern "C" {
|
|||||||
* more specific categories.
|
* more specific categories.
|
||||||
*/
|
*/
|
||||||
#define GLFW_PLATFORM_ERROR 0x00070008
|
#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.
|
/*! @brief The clipboard did not contain data in the requested format.
|
||||||
*/
|
*/
|
||||||
#define GLFW_FORMAT_UNAVAILABLE 0x0007000A
|
#define GLFW_FORMAT_UNAVAILABLE 0x0007000A
|
||||||
@ -1332,7 +1332,7 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow window, int* xpos, int* ypos);
|
|||||||
* client area, or @c NULL.
|
* client area, or @c NULL.
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*
|
*
|
||||||
* @note The specified window must be active.
|
* @note The specified window must be focused.
|
||||||
*
|
*
|
||||||
* @sa glfwGetCursorPos
|
* @sa glfwGetCursorPos
|
||||||
*/
|
*/
|
||||||
|
@ -298,6 +298,7 @@ version of GLFW.</p>
|
|||||||
<li>Changed <code>glfwGetVideoModes</code> to return a dynamic, unlimited number of video modes</li>
|
<li>Changed <code>glfwGetVideoModes</code> to return a dynamic, unlimited number of video modes</li>
|
||||||
<li>Renamed <code>glfw.h</code> to <code>glfw3.h</code> to avoid conflicts with 2.x series</li>
|
<li>Renamed <code>glfw.h</code> to <code>glfw3.h</code> to avoid conflicts with 2.x series</li>
|
||||||
<li>Renamed <code>glfwOpenWindowHint</code> to <code>glfwWindowHint</code></li>
|
<li>Renamed <code>glfwOpenWindowHint</code> to <code>glfwWindowHint</code></li>
|
||||||
|
<li>Renamed <code>GLFW_ACTIVE</code> to <code>GLFW_FOCUSED</code></li>
|
||||||
<li>Renamed <code>GLFW_WINDOW</code> token to <code>GLFW_WINDOWED</code></li>
|
<li>Renamed <code>GLFW_WINDOW</code> token to <code>GLFW_WINDOWED</code></li>
|
||||||
<li>Renamed <code>GLFW_WINDOW_NO_RESIZE</code> to <code>GLFW_RESIZABLE</code></li>
|
<li>Renamed <code>GLFW_WINDOW_NO_RESIZE</code> to <code>GLFW_RESIZABLE</code></li>
|
||||||
<li>Renamed <code>GLFW_BUILD_DLL</code> to <code>_GLFW_BUILD_DLL</code></li>
|
<li>Renamed <code>GLFW_BUILD_DLL</code> to <code>_GLFW_BUILD_DLL</code></li>
|
||||||
|
@ -228,8 +228,8 @@ GLFWAPI const char* glfwErrorString(int error)
|
|||||||
return "The requested OpenGL version is unavailable";
|
return "The requested OpenGL version is unavailable";
|
||||||
case GLFW_PLATFORM_ERROR:
|
case GLFW_PLATFORM_ERROR:
|
||||||
return "A platform-specific error occurred";
|
return "A platform-specific error occurred";
|
||||||
case GLFW_WINDOW_NOT_ACTIVE:
|
case GLFW_WINDOW_NOT_FOCUSED:
|
||||||
return "The specified window is not active";
|
return "The specified window is not focused";
|
||||||
case GLFW_FORMAT_UNAVAILABLE:
|
case GLFW_FORMAT_UNAVAILABLE:
|
||||||
return "The requested format is unavailable";
|
return "The requested format is unavailable";
|
||||||
}
|
}
|
||||||
|
@ -422,9 +422,9 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow handle, int xpos, int ypos)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfwLibrary.activeWindow != window)
|
if (_glfwLibrary.focusedWindow != window)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_WINDOW_NOT_ACTIVE, NULL);
|
_glfwSetError(GLFW_WINDOW_NOT_FOCUSED, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ struct _GLFWlibrary
|
|||||||
_GLFWhints hints;
|
_GLFWhints hints;
|
||||||
|
|
||||||
_GLFWwindow* windowListHead;
|
_GLFWwindow* windowListHead;
|
||||||
_GLFWwindow* activeWindow;
|
_GLFWwindow* focusedWindow;
|
||||||
|
|
||||||
GLFWgammaramp currentRamp;
|
GLFWgammaramp currentRamp;
|
||||||
GLFWgammaramp originalRamp;
|
GLFWgammaramp originalRamp;
|
||||||
@ -321,7 +321,7 @@ void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
// Window event notification (window.c)
|
// 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 _glfwInputWindowPos(_GLFWwindow* window, int x, int y);
|
||||||
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
|
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
|
||||||
void _glfwInputWindowIconify(_GLFWwindow* window, int iconified);
|
void _glfwInputWindowIconify(_GLFWwindow* window, int iconified);
|
||||||
|
@ -328,22 +328,22 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
|
|
||||||
case WM_ACTIVATE:
|
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;
|
BOOL iconified = HIWORD(wParam) ? TRUE : FALSE;
|
||||||
|
|
||||||
if (active && iconified)
|
if (focused && iconified)
|
||||||
{
|
{
|
||||||
// This is a workaround for window iconification using the
|
// This is a workaround for window iconification using the
|
||||||
// taskbar leading to windows being told they're active and
|
// taskbar leading to windows being told they're focused and
|
||||||
// iconified and then never told they're deactivated
|
// iconified and then never told they're defocused
|
||||||
active = FALSE;
|
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)
|
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
showCursor(window);
|
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)
|
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
captureCursor(window);
|
captureCursor(window);
|
||||||
@ -386,7 +386,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputWindowFocus(window, active);
|
_glfwInputWindowFocus(window, focused);
|
||||||
_glfwInputWindowIconify(window, iconified);
|
_glfwInputWindowIconify(window, iconified);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -544,7 +544,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
{
|
{
|
||||||
if (_glfwLibrary.activeWindow != window)
|
if (_glfwLibrary.focusedWindow != window)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
x = newCursorX - window->Win32.oldCursorX;
|
x = newCursorX - window->Win32.oldCursorX;
|
||||||
@ -829,8 +829,8 @@ static void destroyWindow(_GLFWwindow* window)
|
|||||||
|
|
||||||
// This is duplicated from glfwDestroyWindow
|
// This is duplicated from glfwDestroyWindow
|
||||||
// TODO: Stop duplicating code
|
// TODO: Stop duplicating code
|
||||||
if (window == _glfwLibrary.activeWindow)
|
if (window == _glfwLibrary.focusedWindow)
|
||||||
_glfwLibrary.activeWindow = NULL;
|
_glfwLibrary.focusedWindow = NULL;
|
||||||
|
|
||||||
if (window->Win32.handle)
|
if (window->Win32.handle)
|
||||||
{
|
{
|
||||||
@ -1132,7 +1132,7 @@ void _glfwPlatformPollEvents(void)
|
|||||||
MSG msg;
|
MSG msg;
|
||||||
_GLFWwindow* window;
|
_GLFWwindow* window;
|
||||||
|
|
||||||
window = _glfwLibrary.activeWindow;
|
window = _glfwLibrary.focusedWindow;
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
window->Win32.cursorCentered = GL_FALSE;
|
window->Win32.cursorCentered = GL_FALSE;
|
||||||
@ -1168,7 +1168,7 @@ void _glfwPlatformPollEvents(void)
|
|||||||
// LSHIFT/RSHIFT fixup (keys tend to "stick" without this fix)
|
// LSHIFT/RSHIFT fixup (keys tend to "stick" without this fix)
|
||||||
// This is the only async event handling in GLFW, but it solves some
|
// This is the only async event handling in GLFW, but it solves some
|
||||||
// nasty problems.
|
// nasty problems.
|
||||||
window = _glfwLibrary.activeWindow;
|
window = _glfwLibrary.focusedWindow;
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
int lshift_down, rshift_down;
|
int lshift_down, rshift_down;
|
||||||
@ -1186,8 +1186,8 @@ void _glfwPlatformPollEvents(void)
|
|||||||
_glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, GLFW_RELEASE);
|
_glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, GLFW_RELEASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Did the cursor move in an active window that has captured the cursor
|
// Did the cursor move in an focused window that has captured the cursor
|
||||||
window = _glfwLibrary.activeWindow;
|
window = _glfwLibrary.focusedWindow;
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED &&
|
if (window->cursorMode == GLFW_CURSOR_CAPTURED &&
|
||||||
|
26
src/window.c
26
src/window.c
@ -72,21 +72,21 @@ static void clearScrollOffsets(void)
|
|||||||
// Register window focus events
|
// 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)
|
if (window->windowFocusCallback)
|
||||||
window->windowFocusCallback(window, activated);
|
window->windowFocusCallback(window, focused);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_glfwLibrary.activeWindow == window)
|
if (_glfwLibrary.focusedWindow == window)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -104,10 +104,10 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated)
|
|||||||
_glfwInputMouseClick(window, i, GLFW_RELEASE);
|
_glfwInputMouseClick(window, i, GLFW_RELEASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwLibrary.activeWindow = NULL;
|
_glfwLibrary.focusedWindow = NULL;
|
||||||
|
|
||||||
if (window->windowFocusCallback)
|
if (window->windowFocusCallback)
|
||||||
window->windowFocusCallback(window, activated);
|
window->windowFocusCallback(window, focused);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -502,9 +502,9 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow handle)
|
|||||||
if (window == _glfwPlatformGetCurrentContext())
|
if (window == _glfwPlatformGetCurrentContext())
|
||||||
_glfwPlatformMakeContextCurrent(NULL);
|
_glfwPlatformMakeContextCurrent(NULL);
|
||||||
|
|
||||||
// Clear the active window pointer if this is the active window
|
// Clear the focused window pointer if this is the focused window
|
||||||
if (window == _glfwLibrary.activeWindow)
|
if (window == _glfwLibrary.focusedWindow)
|
||||||
_glfwLibrary.activeWindow = NULL;
|
_glfwLibrary.focusedWindow = NULL;
|
||||||
|
|
||||||
_glfwPlatformDestroyWindow(window);
|
_glfwPlatformDestroyWindow(window);
|
||||||
|
|
||||||
@ -700,8 +700,8 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
|
|||||||
|
|
||||||
switch (param)
|
switch (param)
|
||||||
{
|
{
|
||||||
case GLFW_ACTIVE:
|
case GLFW_FOCUSED:
|
||||||
return window == _glfwLibrary.activeWindow;
|
return window == _glfwLibrary.focusedWindow;
|
||||||
case GLFW_ICONIFIED:
|
case GLFW_ICONIFIED:
|
||||||
return window->iconified;
|
return window->iconified;
|
||||||
case GLFW_CLOSE_REQUESTED:
|
case GLFW_CLOSE_REQUESTED:
|
||||||
|
@ -632,7 +632,7 @@ static void processEvent(XEvent *event)
|
|||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||||
{
|
{
|
||||||
if (_glfwLibrary.activeWindow != window)
|
if (_glfwLibrary.focusedWindow != window)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
x = event->xmotion.x - window->X11.cursorPosX;
|
x = event->xmotion.x - window->X11.cursorPosX;
|
||||||
@ -1134,11 +1134,11 @@ void _glfwPlatformPollEvents(void)
|
|||||||
processEvent(&event);
|
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)
|
// captured the cursor (because then it needs to be re-centered)
|
||||||
|
|
||||||
_GLFWwindow* window;
|
_GLFWwindow* window;
|
||||||
window = _glfwLibrary.activeWindow;
|
window = _glfwLibrary.focusedWindow;
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED &&
|
if (window->cursorMode == GLFW_CURSOR_CAPTURED &&
|
||||||
|
@ -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",
|
printf("%08x at %0.3f: Window %s\n",
|
||||||
counter++,
|
counter++,
|
||||||
glfwGetTime(),
|
glfwGetTime(),
|
||||||
activated ? "activated" : "deactivated");
|
focused ? "focused" : "defocused");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_iconify_callback(GLFWwindow window, int iconified)
|
static void window_iconify_callback(GLFWwindow window, int iconified)
|
||||||
|
@ -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
|
// fullscreen windows with a video mode differing from the desktop mode
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -35,11 +35,11 @@
|
|||||||
|
|
||||||
static GLboolean running = GL_TRUE;
|
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",
|
printf("%0.3f: Window %s\n",
|
||||||
glfwGetTime(),
|
glfwGetTime(),
|
||||||
activated ? "activated" : "deactivated");
|
focused ? "focused" : "defocused");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_key_callback(GLFWwindow window, int key, int action)
|
static void window_key_callback(GLFWwindow window, int key, int action)
|
||||||
|
@ -75,11 +75,11 @@ static void window_size_callback(GLFWwindow window, int width, int height)
|
|||||||
glViewport(0, 0, width, 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",
|
printf("%0.2f Window %s\n",
|
||||||
glfwGetTime(),
|
glfwGetTime(),
|
||||||
activated ? "activated" : "deactivated");
|
focused ? "focused" : "defocused");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_iconify_callback(GLFWwindow window, int iconified)
|
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",
|
printf("Window is %s and %s\n",
|
||||||
glfwGetWindowParam(window, GLFW_ICONIFIED) ? "iconified" : "restored",
|
glfwGetWindowParam(window, GLFW_ICONIFIED) ? "iconified" : "restored",
|
||||||
glfwGetWindowParam(window, GLFW_ACTIVE) ? "active" : "inactive");
|
glfwGetWindowParam(window, GLFW_FOCUSED) ? "focused" : "defocused");
|
||||||
|
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user