response to the shutdown

This commit is contained in:
Torkel 2020-10-28 12:37:39 +09:00
parent 067598814d
commit 30c5f3a924
5 changed files with 15 additions and 13 deletions

View File

@ -1422,10 +1422,11 @@ typedef void (* GLFWwindowclosefun)(GLFWwindow*);
* *
* @sa @ref machine_shutdown * @sa @ref machine_shutdown
* @sa @ref glfwSetMachineShutdownCallback * @sa @ref glfwSetMachineShutdownCallback
* @return GLFW_TRUE to accept the shutdown or GLFW_FALSE to interrupt it
* *
* @ingroup window * @ingroup window
*/ */
typedef void (* GLFWmachineShutdownfun)(GLFWwindow*); typedef int (* GLFWmachineShutdownfun)(GLFWwindow*);
/*! @brief The function pointer type for window content refresh callbacks. /*! @brief The function pointer type for window content refresh callbacks.
* *

View File

@ -730,7 +730,7 @@ void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified);
void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized); void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized);
void _glfwInputWindowDamage(_GLFWwindow* window); void _glfwInputWindowDamage(_GLFWwindow* window);
void _glfwInputWindowCloseRequest(_GLFWwindow* window); void _glfwInputWindowCloseRequest(_GLFWwindow* window);
void _glfwInputMachineShutdown(_GLFWwindow* window); GLFWbool _glfwInputMachineShutdown(_GLFWwindow* window);
void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor); void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor);
void _glfwInputKey(_GLFWwindow* window, void _glfwInputKey(_GLFWwindow* window,

View File

@ -627,6 +627,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
return 0; return 0;
} }
case WM_QUERYENDSESSION:
{
return _glfwInputMachineShutdown(window);
}
case WM_INPUTLANGCHANGE: case WM_INPUTLANGCHANGE:
{ {
_glfwUpdateKeyNamesWin32(); _glfwUpdateKeyNamesWin32();
@ -1199,13 +1204,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
DragFinish(drop); DragFinish(drop);
return 0; return 0;
} }
case WM_QUERYENDSESSION:
case WM_ENDSESSION:
{
_glfwInputMachineShutdown(window);
return 0;
}
} }
return DefWindowProcW(hWnd, uMsg, wParam, lParam); return DefWindowProcW(hWnd, uMsg, wParam, lParam);

View File

@ -140,10 +140,12 @@ void _glfwInputWindowCloseRequest(_GLFWwindow* window)
// Notifies shared code that the machine is shuting down // Notifies shared code that the machine is shuting down
// //
void _glfwInputMachineShutdown(_GLFWwindow *window) GLFWbool _glfwInputMachineShutdown(_GLFWwindow *window)
{ {
if (window->callbacks.shutdown) if (window->callbacks.shutdown) {
window->callbacks.shutdown((GLFWwindow*) window); return window->callbacks.shutdown((GLFWwindow*) window);
}
return GLFW_TRUE;
} }
// Notifies shared code that a window has changed its desired monitor // Notifies shared code that a window has changed its desired monitor

View File

@ -329,11 +329,12 @@ static void window_close_callback(GLFWwindow* window)
glfwSetWindowShouldClose(window, slot->closeable); glfwSetWindowShouldClose(window, slot->closeable);
} }
static void window_machine_shutdown_callback(GLFWwindow* window) static int window_machine_shutdown_callback(GLFWwindow* window)
{ {
printf("%08x at %0.3f: Machine shutdown detected\n", printf("%08x at %0.3f: Machine shutdown detected\n",
counter++, counter++,
glfwGetTime()); glfwGetTime());
return GLFW_TRUE;
} }
static void window_refresh_callback(GLFWwindow* window) static void window_refresh_callback(GLFWwindow* window)