mirror of
https://github.com/glfw/glfw.git
synced 2026-09-20 08:23:13 +00:00
+18
-1
@@ -851,6 +851,9 @@ static GLFWbool createWindow(_GLFWwindow* window,
|
||||
|
||||
if (wndconfig->floating)
|
||||
[window->ns.object setLevel:NSFloatingWindowLevel];
|
||||
|
||||
if (wndconfig->maximized)
|
||||
[window->ns.object zoom:nil];
|
||||
}
|
||||
|
||||
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
|
||||
@@ -1023,7 +1026,16 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||
|
||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
{
|
||||
[window->ns.object deminiaturize:nil];
|
||||
if ([window->ns.object isMiniaturized])
|
||||
[window->ns.object deminiaturize:nil];
|
||||
else if ([window->ns.object isZoomed])
|
||||
[window->ns.object zoom:nil];
|
||||
}
|
||||
|
||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||
{
|
||||
if (![window->ns.object isZoomed])
|
||||
[window->ns.object zoom:nil];
|
||||
}
|
||||
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||
@@ -1062,6 +1074,11 @@ int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
||||
return [window->ns.object isVisible];
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
||||
{
|
||||
return [window->ns.object isZoomed];
|
||||
}
|
||||
|
||||
void _glfwPlatformPollEvents(void)
|
||||
{
|
||||
for (;;)
|
||||
|
||||
@@ -255,6 +255,7 @@ struct _GLFWwndconfig
|
||||
GLFWbool focused;
|
||||
GLFWbool autoIconify;
|
||||
GLFWbool floating;
|
||||
GLFWbool maximized;
|
||||
_GLFWmonitor* monitor;
|
||||
};
|
||||
|
||||
@@ -673,6 +674,11 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window);
|
||||
*/
|
||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window);
|
||||
|
||||
/*! @copydoc glfwMaximizeWindow
|
||||
* @ingroup platform
|
||||
*/
|
||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window);
|
||||
|
||||
/*! @copydoc glfwShowWindow
|
||||
* @ingroup platform
|
||||
*/
|
||||
@@ -702,6 +708,11 @@ int _glfwPlatformWindowIconified(_GLFWwindow* window);
|
||||
*/
|
||||
int _glfwPlatformWindowVisible(_GLFWwindow* window);
|
||||
|
||||
/*! @brief Returns whether the window is maximized.
|
||||
* @ingroup platform
|
||||
*/
|
||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window);
|
||||
|
||||
/*! @copydoc glfwPollEvents
|
||||
* @ingroup platform
|
||||
*/
|
||||
|
||||
@@ -467,6 +467,12 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
mir_surface_set_state(window->mir.surface, mir_surface_state_restored);
|
||||
}
|
||||
|
||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||
{
|
||||
MirSurfaceSpec* spec;
|
||||
@@ -514,6 +520,13 @@ int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
||||
return mir_surface_get_visibility(window->mir.surface) == mir_surface_visibility_exposed;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s", __PRETTY_FUNCTION__);
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
void _glfwPlatformPollEvents(void)
|
||||
{
|
||||
EventNode* node = NULL;
|
||||
|
||||
+18
-3
@@ -653,6 +653,8 @@ static int createWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig)
|
||||
{
|
||||
int xpos, ypos, fullWidth, fullHeight;
|
||||
WCHAR* wideTitle;
|
||||
DWORD style = getWindowStyle(window);
|
||||
DWORD exStyle = getWindowExStyle(window);
|
||||
|
||||
if (wndconfig->monitor)
|
||||
{
|
||||
@@ -671,7 +673,10 @@ static int createWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig)
|
||||
xpos = CW_USEDEFAULT;
|
||||
ypos = CW_USEDEFAULT;
|
||||
|
||||
getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
|
||||
if (wndconfig->maximized)
|
||||
style |= WS_MAXIMIZE;
|
||||
|
||||
getFullWindowSize(style, exStyle,
|
||||
wndconfig->width, wndconfig->height,
|
||||
&fullWidth, &fullHeight);
|
||||
}
|
||||
@@ -684,10 +689,10 @@ static int createWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig)
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
window->win32.handle = CreateWindowExW(getWindowExStyle(window),
|
||||
window->win32.handle = CreateWindowExW(exStyle,
|
||||
_GLFW_WNDCLASSNAME,
|
||||
wideTitle,
|
||||
getWindowStyle(window),
|
||||
style,
|
||||
xpos, ypos,
|
||||
fullWidth, fullHeight,
|
||||
NULL, // No parent window
|
||||
@@ -1026,6 +1031,11 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
ShowWindow(window->win32.handle, SW_RESTORE);
|
||||
}
|
||||
|
||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||
{
|
||||
ShowWindow(window->win32.handle, SW_MAXIMIZE);
|
||||
}
|
||||
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||
{
|
||||
ShowWindow(window->win32.handle, SW_SHOW);
|
||||
@@ -1059,6 +1069,11 @@ int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
||||
return IsWindowVisible(window->win32.handle);
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
||||
{
|
||||
return IsZoomed(window->win32.handle);
|
||||
}
|
||||
|
||||
void _glfwPlatformPollEvents(void)
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
@@ -339,6 +339,9 @@ GLFWAPI void glfwWindowHint(int hint, int value)
|
||||
case GLFW_FLOATING:
|
||||
_glfw.hints.window.floating = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
break;
|
||||
case GLFW_MAXIMIZED:
|
||||
_glfw.hints.window.maximized = hint ? GLFW_TRUE : GLFW_FALSE;
|
||||
break;
|
||||
case GLFW_VISIBLE:
|
||||
_glfw.hints.window.visible = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
break;
|
||||
@@ -593,6 +596,13 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
|
||||
_glfwPlatformRestoreWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformMaximizeWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwShowWindow(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
@@ -634,6 +644,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
||||
return _glfwPlatformWindowIconified(window);
|
||||
case GLFW_VISIBLE:
|
||||
return _glfwPlatformWindowVisible(window);
|
||||
case GLFW_MAXIMIZED:
|
||||
return _glfwPlatformWindowMaximized(window);
|
||||
case GLFW_RESIZABLE:
|
||||
return window->resizable;
|
||||
case GLFW_DECORATED:
|
||||
|
||||
@@ -459,6 +459,12 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
fprintf(stderr, "_glfwPlatformRestoreWindow not implemented yet\n");
|
||||
}
|
||||
|
||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||
{
|
||||
// TODO
|
||||
fprintf(stderr, "_glfwPlatformMaximizeWindow not implemented yet\n");
|
||||
}
|
||||
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||
{
|
||||
wl_shell_surface_set_toplevel(window->wl.shell_surface);
|
||||
@@ -494,6 +500,12 @@ int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
||||
{
|
||||
// TODO
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
void _glfwPlatformPollEvents(void)
|
||||
{
|
||||
handleEvents(0);
|
||||
|
||||
@@ -444,6 +444,10 @@ static void detectEWMH(void)
|
||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE");
|
||||
_glfw.x11.NET_WM_STATE_FULLSCREEN =
|
||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN");
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT =
|
||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT");
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ =
|
||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ");
|
||||
_glfw.x11.NET_WM_FULLSCREEN_MONITORS =
|
||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS");
|
||||
_glfw.x11.NET_WM_NAME =
|
||||
|
||||
@@ -175,6 +175,8 @@ typedef struct _GLFWlibraryX11
|
||||
Atom NET_WM_STATE;
|
||||
Atom NET_WM_STATE_ABOVE;
|
||||
Atom NET_WM_STATE_FULLSCREEN;
|
||||
Atom NET_WM_STATE_MAXIMIZED_VERT;
|
||||
Atom NET_WM_STATE_MAXIMIZED_HORZ;
|
||||
Atom NET_WM_BYPASS_COMPOSITOR;
|
||||
Atom NET_WM_FULLSCREEN_MONITORS;
|
||||
Atom NET_ACTIVE_WINDOW;
|
||||
|
||||
+76
-1
@@ -355,6 +355,24 @@ static GLFWbool createWindow(_GLFWwindow* window,
|
||||
0, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (wndconfig->maximized)
|
||||
{
|
||||
if (_glfw.x11.NET_WM_STATE &&
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
|
||||
{
|
||||
const Atom states[2] =
|
||||
{
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ
|
||||
};
|
||||
|
||||
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char*) &states, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1820,10 +1838,42 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
return;
|
||||
}
|
||||
|
||||
XMapWindow(_glfw.x11.display, window->x11.handle);
|
||||
if (_glfwPlatformWindowIconified(window))
|
||||
XMapWindow(_glfw.x11.display, window->x11.handle);
|
||||
else
|
||||
{
|
||||
if (_glfw.x11.NET_WM_STATE &&
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
|
||||
{
|
||||
sendEventToWM(window,
|
||||
_glfw.x11.NET_WM_STATE,
|
||||
_NET_WM_STATE_REMOVE,
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ,
|
||||
1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
XFlush(_glfw.x11.display);
|
||||
}
|
||||
|
||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||
{
|
||||
if (_glfw.x11.NET_WM_STATE &&
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
|
||||
{
|
||||
sendEventToWM(window,
|
||||
_glfw.x11.NET_WM_STATE,
|
||||
_NET_WM_STATE_ADD,
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ,
|
||||
1, 0);
|
||||
XFlush(_glfw.x11.display);
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||
{
|
||||
XMapRaised(_glfw.x11.display, window->x11.handle);
|
||||
@@ -1863,6 +1913,31 @@ int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
||||
return wa.map_state == IsViewable;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
||||
{
|
||||
Atom* states;
|
||||
unsigned long i;
|
||||
GLFWbool maximized = GLFW_FALSE;
|
||||
const unsigned long count =
|
||||
_glfwGetWindowPropertyX11(window->x11.handle,
|
||||
_glfw.x11.NET_WM_STATE,
|
||||
XA_ATOM,
|
||||
(unsigned char**) &states);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
|
||||
states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
|
||||
{
|
||||
maximized = GLFW_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XFree(states);
|
||||
return maximized;
|
||||
}
|
||||
|
||||
void _glfwPlatformPollEvents(void)
|
||||
{
|
||||
int count = XPending(_glfw.x11.display);
|
||||
|
||||
Reference in New Issue
Block a user