mirror of
https://github.com/glfw/glfw.git
synced 2026-11-18 12:54:54 +00:00
@@ -75,6 +75,8 @@ typedef struct _GLFWwindowNS
|
||||
id delegate;
|
||||
id view;
|
||||
|
||||
GLFWbool maximized;
|
||||
|
||||
// The total sum of the distances the cursor has been warped
|
||||
// since the last cursor motion event was processed
|
||||
// This is kept to counteract Cocoa doing the same internally
|
||||
|
||||
@@ -238,6 +238,13 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
if (_glfw.ns.disabledCursorWindow == window)
|
||||
centerCursor(window);
|
||||
|
||||
const int maximized = [window->ns.object isZoomed];
|
||||
if (window->ns.maximized != maximized)
|
||||
{
|
||||
window->ns.maximized = maximized;
|
||||
_glfwInputWindowMaximize(window, maximized);
|
||||
}
|
||||
|
||||
const NSRect contentRect = [window->ns.view frame];
|
||||
const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
|
||||
|
||||
|
||||
@@ -378,6 +378,7 @@ struct _GLFWwindow
|
||||
GLFWwindowrefreshfun refresh;
|
||||
GLFWwindowfocusfun focus;
|
||||
GLFWwindowiconifyfun iconify;
|
||||
GLFWwindowmaximizefun maximize;
|
||||
GLFWframebuffersizefun fbsize;
|
||||
GLFWmousebuttonfun mouseButton;
|
||||
GLFWcursorposfun cursorPos;
|
||||
@@ -856,6 +857,14 @@ void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height);
|
||||
*/
|
||||
void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified);
|
||||
|
||||
/*! @brief Notifies shared code of a window maximization event.
|
||||
* @param[in] window The window that received the event.
|
||||
* @param[in] maximized `GLFW_TRUE` if the window was maximized, or
|
||||
* `GLFW_FALSE` if it was restored.
|
||||
* @ingroup event
|
||||
*/
|
||||
void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized);
|
||||
|
||||
/*! @brief Notifies shared code of a window damage event.
|
||||
* @param[in] window The window that received the event.
|
||||
*/
|
||||
|
||||
@@ -235,6 +235,7 @@ typedef struct _GLFWwindowWin32
|
||||
|
||||
GLFWbool cursorTracked;
|
||||
GLFWbool iconified;
|
||||
GLFWbool maximized;
|
||||
|
||||
// The last received cursor position, regardless of source
|
||||
int lastCursorPosX, lastCursorPosY;
|
||||
|
||||
+14
-17
@@ -693,36 +693,33 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
const GLFWbool iconified =
|
||||
!window->win32.iconified && wParam == SIZE_MINIMIZED;
|
||||
const GLFWbool restored =
|
||||
window->win32.iconified &&
|
||||
(wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED);
|
||||
const GLFWbool iconified = wParam == SIZE_MINIMIZED;
|
||||
const GLFWbool maximized = wParam == SIZE_MAXIMIZED ||
|
||||
(window->win32.maximized &&
|
||||
wParam != SIZE_RESTORED);
|
||||
|
||||
if (_glfw.win32.disabledCursorWindow == window)
|
||||
updateClipRect(window);
|
||||
|
||||
if (iconified)
|
||||
_glfwInputWindowIconify(window, GLFW_TRUE);
|
||||
else if (restored)
|
||||
_glfwInputWindowIconify(window, GLFW_FALSE);
|
||||
if (window->win32.iconified != iconified)
|
||||
_glfwInputWindowIconify(window, iconified);
|
||||
|
||||
if (window->win32.maximized != maximized)
|
||||
_glfwInputWindowMaximize(window, maximized);
|
||||
|
||||
_glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam));
|
||||
_glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
|
||||
|
||||
if (iconified)
|
||||
if (window->monitor && window->win32.iconified != iconified)
|
||||
{
|
||||
window->win32.iconified = GLFW_TRUE;
|
||||
if (window->monitor)
|
||||
if (iconified)
|
||||
releaseMonitor(window);
|
||||
}
|
||||
else if (restored)
|
||||
{
|
||||
window->win32.iconified = GLFW_FALSE;
|
||||
if (window->monitor)
|
||||
else
|
||||
acquireMonitor(window);
|
||||
}
|
||||
|
||||
window->win32.iconified = iconified;
|
||||
window->win32.maximized = maximized;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,12 @@ void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified)
|
||||
window->callbacks.iconify((GLFWwindow*) window, iconified);
|
||||
}
|
||||
|
||||
void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized)
|
||||
{
|
||||
if (window->callbacks.maximize)
|
||||
window->callbacks.maximize((GLFWwindow*) window, maximized);
|
||||
}
|
||||
|
||||
void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
|
||||
{
|
||||
if (window->callbacks.fbsize)
|
||||
@@ -856,6 +862,17 @@ GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* handle,
|
||||
GLFWwindowmaximizefun cbfun)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.maximize, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle,
|
||||
GLFWframebuffersizefun cbfun)
|
||||
{
|
||||
|
||||
@@ -112,6 +112,8 @@ typedef struct _GLFWwindowX11
|
||||
XIC ic;
|
||||
|
||||
GLFWbool overrideRedirect;
|
||||
GLFWbool iconified;
|
||||
GLFWbool maximized;
|
||||
|
||||
// Cached position and size used to filter out duplicate events
|
||||
int width, height;
|
||||
|
||||
+25
-10
@@ -559,6 +559,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
||||
{
|
||||
states[count++] = _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT;
|
||||
states[count++] = _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ;
|
||||
window->x11.maximized = GLFW_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1415,23 +1416,37 @@ static void processEvent(XEvent *event)
|
||||
|
||||
case PropertyNotify:
|
||||
{
|
||||
if (event->xproperty.atom == _glfw.x11.WM_STATE &&
|
||||
event->xproperty.state == PropertyNewValue)
|
||||
if (event->xproperty.state != PropertyNewValue)
|
||||
return;
|
||||
|
||||
if (event->xproperty.atom == _glfw.x11.WM_STATE)
|
||||
{
|
||||
const int state = getWindowState(window);
|
||||
if (state == IconicState)
|
||||
if (state != IconicState && state != NormalState)
|
||||
return;
|
||||
|
||||
const GLFWbool iconified = (state == IconicState);
|
||||
if (window->x11.iconified != iconified)
|
||||
{
|
||||
if (window->monitor)
|
||||
releaseMonitor(window);
|
||||
{
|
||||
if (iconified)
|
||||
releaseMonitor(window);
|
||||
else
|
||||
acquireMonitor(window);
|
||||
}
|
||||
|
||||
_glfwInputWindowIconify(window, GLFW_TRUE);
|
||||
window->x11.iconified = iconified;
|
||||
_glfwInputWindowIconify(window, iconified);
|
||||
}
|
||||
else if (state == NormalState)
|
||||
}
|
||||
else if (event->xproperty.atom == _glfw.x11.NET_WM_STATE)
|
||||
{
|
||||
const GLFWbool maximized = _glfwPlatformWindowMaximized(window);
|
||||
if (window->x11.maximized != maximized)
|
||||
{
|
||||
if (window->monitor)
|
||||
acquireMonitor(window);
|
||||
|
||||
_glfwInputWindowIconify(window, GLFW_FALSE);
|
||||
window->x11.maximized = maximized;
|
||||
_glfwInputWindowMaximize(window, maximized);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user