mirror of
https://github.com/glfw/glfw.git
synced 2025-10-05 06:06:36 +00:00
Merge 71bb507172
into 731ff91acd
This commit is contained in:
commit
a99cdc6c75
@ -907,6 +907,15 @@ extern "C" {
|
||||
#define GLFW_EGL_CONTEXT_API 0x00036002
|
||||
#define GLFW_OSMESA_CONTEXT_API 0x00036003
|
||||
|
||||
#define GLFW_WINDOW_LEFT 0
|
||||
#define GLFW_WINDOW_TOP 1
|
||||
#define GLFW_WINDOW_RIGHT 2
|
||||
#define GLFW_WINDOW_BOTTOM 3
|
||||
#define GLFW_WINDOW_TOPLEFT 4
|
||||
#define GLFW_WINDOW_TOPRIGHT 5
|
||||
#define GLFW_WINDOW_BOTTOMLEFT 6
|
||||
#define GLFW_WINDOW_BOTTOMRIGHT 7
|
||||
|
||||
/*! @defgroup shapes Standard cursor shapes
|
||||
* @brief Standard system cursor shapes.
|
||||
*
|
||||
@ -2784,6 +2793,36 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window);
|
||||
*/
|
||||
GLFWAPI void glfwFocusWindow(GLFWwindow* window);
|
||||
|
||||
/*! @brief Starts a resize operation with the specified window.
|
||||
*
|
||||
* This function starts a resize operation on one of the borders of the
|
||||
* specified window.
|
||||
*
|
||||
* The borders are [GLFW_WINDOW_LEFT](@ref GLFW_GLFW_WINDOW_LEFT),
|
||||
* [GLFW_WINDOW_TOP](@ref GLFW_WINDOW_TOP),
|
||||
* [GLFW_WINDOW_RIGHT](@ref GLFW_WINDOW_RIGHT),
|
||||
* [GLFW_WINDOW_BOTTOM](@ref GLFW_WINDOW_BOTTOM),
|
||||
* [GLFW_WINDOW_TOPLEFT](@ref GLFW_WINDOW_TOPLEFT),
|
||||
* [GLFW_WINDOW_TOPRIGHT](@ref GLFW_WINDOW_TOPRIGHT),
|
||||
* [GLFW_WINDOW_BOTTOMLEFT](@ref GLFW_WINDOW_BOTTOMLEFT) and
|
||||
* [GLFW_WINDOW_BOTTOMRIGHT](@ref GLFW_WINDOW_BOTTOMRIGHT).
|
||||
*
|
||||
* @param[in] window The window to start the resize operation.
|
||||
* @param[in] border One of the window borders.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
* @sa @ref window_resize
|
||||
*
|
||||
* @since Added in version 3.3.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
GLFWAPI void glfwResizeWindow(GLFWwindow* window, int border);
|
||||
|
||||
/*! @brief Returns the monitor that the window uses for full screen mode.
|
||||
*
|
||||
* This function returns the handle of the monitor that the specified window is
|
||||
|
@ -1288,6 +1288,10 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||
[window->ns.object makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
void _glfwPlatformResizeWindow(_GLFWwindow* window, int border)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
_GLFWmonitor* monitor,
|
||||
int xpos, int ypos,
|
||||
|
@ -632,6 +632,7 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformHideWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformFocusWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformResizeWindow(_GLFWwindow* window, int border);
|
||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||
int _glfwPlatformWindowFocused(_GLFWwindow* window);
|
||||
int _glfwPlatformWindowIconified(_GLFWwindow* window);
|
||||
|
@ -576,6 +576,10 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||
"Mir: Unsupported function %s", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
void _glfwPlatformResizeWindow(_GLFWwindow* window, int border)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
_GLFWmonitor* monitor,
|
||||
int xpos, int ypos,
|
||||
|
@ -1323,6 +1323,39 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||
SetFocus(window->win32.handle);
|
||||
}
|
||||
|
||||
void _glfwPlatformResizeWindow(_GLFWwindow* window, int border)
|
||||
{
|
||||
WPARAM wBorder;
|
||||
switch (border)
|
||||
{
|
||||
case GLFW_WINDOW_LEFT:
|
||||
wBorder = HTLEFT;
|
||||
break;
|
||||
case GLFW_WINDOW_TOP:
|
||||
wBorder = HTTOP;
|
||||
break;
|
||||
case GLFW_WINDOW_RIGHT:
|
||||
wBorder = HTRIGHT;
|
||||
break;
|
||||
case GLFW_WINDOW_BOTTOM:
|
||||
wBorder = HTBOTTOM;
|
||||
break;
|
||||
case GLFW_WINDOW_TOPLEFT:
|
||||
wBorder = HTTOPLEFT;
|
||||
break;
|
||||
case GLFW_WINDOW_TOPRIGHT:
|
||||
wBorder = HTTOPRIGHT;
|
||||
break;
|
||||
case GLFW_WINDOW_BOTTOMLEFT:
|
||||
wBorder = HTBOTTOMLEFT;
|
||||
break;
|
||||
case GLFW_WINDOW_BOTTOMRIGHT:
|
||||
wBorder = HTBOTTOMRIGHT;
|
||||
}
|
||||
ReleaseCapture();
|
||||
SendMessage(window->win32.handle, WM_NCLBUTTONDOWN, wBorder, 0);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
_GLFWmonitor* monitor,
|
||||
int xpos, int ypos,
|
||||
|
13
src/window.c
13
src/window.c
@ -698,6 +698,19 @@ GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
|
||||
_glfwPlatformFocusWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwResizeWindow(GLFWwindow* handle, int border)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (border < GLFW_WINDOW_LEFT || border > GLFW_WINDOW_BOTTOMRIGHT)
|
||||
return;
|
||||
|
||||
_glfwPlatformResizeWindow(window, border);
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
@ -605,6 +605,41 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||
"Wayland: Focusing a window requires user interaction");
|
||||
}
|
||||
|
||||
void _glfwPlatformResizeWindow(_GLFWwindow* window, int border)
|
||||
{
|
||||
int wlBorder;
|
||||
switch (border)
|
||||
{
|
||||
case GLFW_WINDOW_LEFT:
|
||||
wlBorder = WL_SHELL_SURFACE_RESIZE_LEFT;
|
||||
break;
|
||||
case GLFW_WINDOW_TOP:
|
||||
wlBorder = WL_SHELL_SURFACE_RESIZE_TOP;
|
||||
break;
|
||||
case GLFW_WINDOW_RIGHT:
|
||||
wlBorder = WL_SHELL_SURFACE_RESIZE_RIGHT;
|
||||
break;
|
||||
case GLFW_WINDOW_BOTTOM:
|
||||
wlBorder = WL_SHELL_SURFACE_RESIZE_BOTTOM;
|
||||
break;
|
||||
case GLFW_WINDOW_TOPLEFT:
|
||||
wlBorder = WL_SHELL_SURFACE_RESIZE_TOP_LEFT;
|
||||
break;
|
||||
case GLFW_WINDOW_TOPRIGHT:
|
||||
wlBorder = WL_SHELL_SURFACE_RESIZE_TOP_RIGHT;
|
||||
break;
|
||||
case GLFW_WINDOW_BOTTOMLEFT:
|
||||
wlBorder = WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT;
|
||||
break;
|
||||
case GLFW_WINDOW_BOTTOMRIGHT:
|
||||
wlBorder = WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT;
|
||||
}
|
||||
wl_shell_surface_resize(window->wl.shellSurface,
|
||||
_glfw.wl.seat,
|
||||
_glfw.wl.pointerSerial,
|
||||
wlBorder);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
_GLFWmonitor* monitor,
|
||||
int xpos, int ypos,
|
||||
|
@ -43,6 +43,15 @@
|
||||
#define _NET_WM_STATE_REMOVE 0
|
||||
#define _NET_WM_STATE_ADD 1
|
||||
#define _NET_WM_STATE_TOGGLE 2
|
||||
#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
|
||||
#define _NET_WM_MOVERESIZE_SIZE_TOP 1
|
||||
#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
|
||||
#define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
|
||||
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
|
||||
#define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
|
||||
#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
|
||||
#define _NET_WM_MOVERESIZE_SIZE_LEFT 7
|
||||
|
||||
|
||||
// Additional mouse button names for XButtonEvent
|
||||
#define Button6 6
|
||||
@ -2091,6 +2100,53 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||
XFlush(_glfw.x11.display);
|
||||
}
|
||||
|
||||
void _glfwPlatformResizeWindow(_GLFWwindow* window, int border)
|
||||
{
|
||||
int winXpos, winYpos;
|
||||
double curXpos, curYpos;
|
||||
XClientMessageEvent xclient;
|
||||
memset(&xclient, 0, sizeof(XClientMessageEvent));
|
||||
XUngrabPointer(_glfw.x11.display, 0);
|
||||
XFlush(_glfw.x11.display);
|
||||
_glfwPlatformGetCursorPos(window, &curXpos, &curYpos);
|
||||
_glfwPlatformGetWindowPos(window, &winXpos, &winYpos);
|
||||
xclient.type = ClientMessage;
|
||||
xclient.window = window->x11.handle;
|
||||
xclient.message_type = XInternAtom(_glfw.x11.display, "_NET_WM_MOVERESIZE", False);
|
||||
xclient.format = 32;
|
||||
xclient.data.l[0] = winXpos + curXpos;
|
||||
xclient.data.l[1] = winYpos + curYpos;
|
||||
switch (border)
|
||||
{
|
||||
case GLFW_WINDOW_LEFT:
|
||||
xclient.data.l[2] = _NET_WM_MOVERESIZE_SIZE_LEFT;
|
||||
break;
|
||||
case GLFW_WINDOW_TOP:
|
||||
xclient.data.l[2] = _NET_WM_MOVERESIZE_SIZE_TOP;
|
||||
break;
|
||||
case GLFW_WINDOW_RIGHT:
|
||||
xclient.data.l[2] = _NET_WM_MOVERESIZE_SIZE_RIGHT;
|
||||
break;
|
||||
case GLFW_WINDOW_BOTTOM:
|
||||
xclient.data.l[2] = _NET_WM_MOVERESIZE_SIZE_BOTTOM;
|
||||
break;
|
||||
case GLFW_WINDOW_TOPLEFT:
|
||||
xclient.data.l[2] = _NET_WM_MOVERESIZE_SIZE_TOPLEFT;
|
||||
break;
|
||||
case GLFW_WINDOW_TOPRIGHT:
|
||||
xclient.data.l[2] = _NET_WM_MOVERESIZE_SIZE_TOPRIGHT;
|
||||
break;
|
||||
case GLFW_WINDOW_BOTTOMLEFT:
|
||||
xclient.data.l[2] = _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT;
|
||||
break;
|
||||
case GLFW_WINDOW_BOTTOMRIGHT:
|
||||
xclient.data.l[2] = _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT;
|
||||
}
|
||||
xclient.data.l[3] = 0;
|
||||
xclient.data.l[4] = 0;
|
||||
XSendEvent(_glfw.x11.display, _glfw.x11.root, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&xclient);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
_GLFWmonitor* monitor,
|
||||
int xpos, int ypos,
|
||||
|
Loading…
Reference in New Issue
Block a user