mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Added window iconification callback.
This commit is contained in:
parent
871f3d172e
commit
0d7e1794a5
@ -386,6 +386,7 @@ typedef void (* GLFWwindowsizefun)(GLFWwindow,int,int);
|
||||
typedef int (* GLFWwindowclosefun)(GLFWwindow);
|
||||
typedef void (* GLFWwindowrefreshfun)(GLFWwindow);
|
||||
typedef void (* GLFWwindowfocusfun)(GLFWwindow,int);
|
||||
typedef void (* GLFWwindowiconifyfun)(GLFWwindow,int);
|
||||
typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int);
|
||||
typedef void (* GLFWmouseposfun)(GLFWwindow,int,int);
|
||||
typedef void (* GLFWmousewheelfun)(GLFWwindow,int);
|
||||
@ -431,6 +432,7 @@ GLFWAPI void glfwSetWindowSizeCallback(GLFWwindow window, GLFWwindowsizefun cbfu
|
||||
GLFWAPI void glfwSetWindowCloseCallback(GLFWwindow window, GLFWwindowclosefun cbfun);
|
||||
GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfun cbfun);
|
||||
GLFWAPI void glfwSetWindowFocusCallback(GLFWwindow window, GLFWwindowfocusfun cbfun);
|
||||
GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindow window, GLFWwindowiconifyfun cbfun);
|
||||
|
||||
/* Event handling */
|
||||
GLFWAPI void glfwPollEvents(void);
|
||||
|
@ -269,6 +269,7 @@ version of GLFW.</p>
|
||||
<li>Added <code>glfwGetVersionString</code> function for determining which code paths were enabled at compile time</li>
|
||||
<li>Added <code>glfwGetWindowPos</code> function for querying the position of the specified window</li>
|
||||
<li>Added <code>glfwSetWindowFocusCallback</code> function and GLFWwindowfocusfun type for receiving window focus events</li>
|
||||
<li>Added <code>glfwSetWindowIconifyCallback</code> function and GLFWwindowiconifyfun type for receiving window iconification events</li>
|
||||
<li>Added <code>windows</code> simple multi-window test program</li>
|
||||
<li>Added initial window title parameter to <code>glfwOpenWindow</code></li>
|
||||
<li>Changed buffer bit depth parameters of <code>glfwOpenWindow</code> to window hints</li>
|
||||
|
@ -94,11 +94,17 @@
|
||||
- (void)windowDidMiniaturize:(NSNotification *)notification
|
||||
{
|
||||
window->iconified = GL_TRUE;
|
||||
|
||||
if (window->windowIconifyCallback)
|
||||
window->windowIconifyCallback(window, window->iconified);
|
||||
}
|
||||
|
||||
- (void)windowDidDeminiaturize:(NSNotification *)notification
|
||||
{
|
||||
window->iconified = GL_FALSE;
|
||||
|
||||
if (window->windowIconifyCallback)
|
||||
window->windowIconifyCallback(window, window->iconified);
|
||||
}
|
||||
|
||||
- (void)windowDidBecomeKey:(NSNotification *)notification
|
||||
|
@ -149,6 +149,7 @@ typedef struct _GLFWwindow
|
||||
GLFWwindowclosefun windowCloseCallback;
|
||||
GLFWwindowrefreshfun windowRefreshCallback;
|
||||
GLFWwindowfocusfun windowFocusCallback;
|
||||
GLFWwindowiconifyfun windowIconifyCallback;
|
||||
GLFWmousebuttonfun mouseButtonCallback;
|
||||
GLFWmouseposfun mousePosCallback;
|
||||
GLFWmousewheelfun mouseWheelCallback;
|
||||
|
@ -697,7 +697,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
|
||||
_glfwInputWindowFocus(window, active);
|
||||
|
||||
window->iconified = iconified;
|
||||
if (iconified != window->iconified)
|
||||
{
|
||||
window->iconified = iconified;
|
||||
|
||||
if (window->windowIconifyCallback)
|
||||
window->windowIconifyCallback(window, window->iconified);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
16
src/window.c
16
src/window.c
@ -1122,6 +1122,22 @@ GLFWAPI void glfwSetWindowFocusCallback(GLFWwindow window, GLFWwindowfocusfun cb
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Set callback function for window iconification events
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindow window, GLFWwindowiconifyfun cbfun)
|
||||
{
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED);
|
||||
return;
|
||||
}
|
||||
|
||||
window->windowIconifyCallback = cbfun;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Poll for new window and input events and close any flagged windows
|
||||
//========================================================================
|
||||
|
@ -1272,6 +1272,10 @@ static void processSingleEvent(void)
|
||||
}
|
||||
|
||||
window->iconified = GL_FALSE;
|
||||
|
||||
if (window->windowIconifyCallback)
|
||||
window->windowIconifyCallback(window, window->iconified);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1286,6 +1290,10 @@ static void processSingleEvent(void)
|
||||
}
|
||||
|
||||
window->iconified = GL_TRUE;
|
||||
|
||||
if (window->windowIconifyCallback)
|
||||
window->windowIconifyCallback(window, window->iconified);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -193,6 +193,14 @@ static void window_focus_callback(GLFWwindow window, int activated)
|
||||
activated ? "activated" : "deactivated");
|
||||
}
|
||||
|
||||
static void window_iconify_callback(GLFWwindow window, int iconified)
|
||||
{
|
||||
printf("%08x at %0.3f: Window was %s\n",
|
||||
counter++,
|
||||
glfwGetTime(),
|
||||
iconified ? "iconified" : "restored");
|
||||
}
|
||||
|
||||
static void mouse_button_callback(GLFWwindow window, int button, int action)
|
||||
{
|
||||
const char* name = get_button_name(button);
|
||||
@ -299,6 +307,7 @@ int main(void)
|
||||
glfwSetWindowCloseCallback(window, window_close_callback);
|
||||
glfwSetWindowRefreshCallback(window, window_refresh_callback);
|
||||
glfwSetWindowFocusCallback(window, window_focus_callback);
|
||||
glfwSetWindowIconifyCallback(window, window_iconify_callback);
|
||||
glfwSetMouseButtonCallback(window, mouse_button_callback);
|
||||
glfwSetMousePosCallback(window, mouse_position_callback);
|
||||
glfwSetMouseWheelCallback(window, mouse_wheel_callback);
|
||||
|
Loading…
Reference in New Issue
Block a user