mirror of
https://github.com/glfw/glfw
synced 2026-09-26 16:18:21 +03:00
Merge 4126eaf799 into 92dcf4ce74
This commit is contained in:
commit
2f2d227be3
18 changed files with 88 additions and 0 deletions
|
|
@ -3484,6 +3484,17 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
|
|||
*/
|
||||
GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
|
||||
|
||||
/*! @brief Starts an interactive move of the window managed by the compositor.
|
||||
*
|
||||
* On Wayland this calls xdg_toplevel_move / libdecor_frame_move so the
|
||||
* compositor handles the drag. On X11 it sends _NET_WM_MOVERESIZE.
|
||||
* Call this from a left-button-press handler on your custom title bar.
|
||||
*
|
||||
* @param[in] window The window to move.
|
||||
* @ingroup window
|
||||
*/
|
||||
GLFWAPI void glfwStartInteractiveMove(GLFWwindow* window);
|
||||
|
||||
/*! @brief Retrieves the size of the content area of the specified window.
|
||||
*
|
||||
* This function retrieves the size, in screen coordinates, of the content area
|
||||
|
|
|
|||
|
|
@ -493,6 +493,7 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
|
|||
.setWindowIcon = _glfwSetWindowIconCocoa,
|
||||
.getWindowPos = _glfwGetWindowPosCocoa,
|
||||
.setWindowPos = _glfwSetWindowPosCocoa,
|
||||
.startInteractiveMove = _glfwStartInteractiveMoveCocoa,
|
||||
.getWindowSize = _glfwGetWindowSizeCocoa,
|
||||
.setWindowSize = _glfwSetWindowSizeCocoa,
|
||||
.setWindowSizeLimits = _glfwSetWindowSizeLimitsCocoa,
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@ void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title);
|
|||
void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||
void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosCocoa(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwStartInteractiveMoveCocoa(_GLFWwindow* window);
|
||||
void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwSetWindowSizeCocoa(_GLFWwindow* window, int width, int height);
|
||||
void _glfwSetWindowSizeLimitsCocoa(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||
|
|
|
|||
|
|
@ -1091,6 +1091,17 @@ void _glfwSetWindowPosCocoa(_GLFWwindow* window, int x, int y)
|
|||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwStartInteractiveMoveCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
NSEvent* event = [NSApp currentEvent];
|
||||
if (event)
|
||||
[window->ns.object performWindowDragWithEvent:event];
|
||||
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
|
|
|||
|
|
@ -721,6 +721,7 @@ struct _GLFWplatform
|
|||
void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*);
|
||||
void (*getWindowPos)(_GLFWwindow*,int*,int*);
|
||||
void (*setWindowPos)(_GLFWwindow*,int,int);
|
||||
void (*startInteractiveMove)(_GLFWwindow*);
|
||||
void (*getWindowSize)(_GLFWwindow*,int*,int*);
|
||||
void (*setWindowSize)(_GLFWwindow*,int,int);
|
||||
void (*setWindowSizeLimits)(_GLFWwindow*,int,int,int,int);
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
|
|||
.setWindowIcon = _glfwSetWindowIconNull,
|
||||
.getWindowPos = _glfwGetWindowPosNull,
|
||||
.setWindowPos = _glfwSetWindowPosNull,
|
||||
.startInteractiveMove = _glfwStartInteractiveMoveNull,
|
||||
.getWindowSize = _glfwGetWindowSizeNull,
|
||||
.setWindowSize = _glfwSetWindowSizeNull,
|
||||
.setWindowSizeLimits = _glfwSetWindowSizeLimitsNull,
|
||||
|
|
|
|||
|
|
@ -226,6 +226,7 @@ void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* ima
|
|||
void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||
void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwStartInteractiveMoveNull(_GLFWwindow* window);
|
||||
void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height);
|
||||
void _glfwSetWindowSizeLimitsNull(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||
|
|
|
|||
|
|
@ -242,6 +242,8 @@ void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos)
|
|||
}
|
||||
}
|
||||
|
||||
void _glfwStartInteractiveMoveNull(_GLFWwindow* window) {}
|
||||
|
||||
void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
if (width)
|
||||
|
|
|
|||
|
|
@ -611,6 +611,7 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
|
|||
.setWindowIcon = _glfwSetWindowIconWin32,
|
||||
.getWindowPos = _glfwGetWindowPosWin32,
|
||||
.setWindowPos = _glfwSetWindowPosWin32,
|
||||
.startInteractiveMove = _glfwStartInteractiveMoveWin32,
|
||||
.getWindowSize = _glfwGetWindowSizeWin32,
|
||||
.setWindowSize = _glfwSetWindowSizeWin32,
|
||||
.setWindowSizeLimits = _glfwSetWindowSizeLimitsWin32,
|
||||
|
|
|
|||
|
|
@ -488,6 +488,7 @@ void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title);
|
|||
void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||
void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwStartInteractiveMoveWin32(_GLFWwindow* window);
|
||||
void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwSetWindowSizeWin32(_GLFWwindow* window, int width, int height);
|
||||
void _glfwSetWindowSizeLimitsWin32(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||
|
|
|
|||
|
|
@ -1652,6 +1652,12 @@ void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos)
|
|||
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
|
||||
}
|
||||
|
||||
void _glfwStartInteractiveMoveWin32(_GLFWwindow* window)
|
||||
{
|
||||
ReleaseCapture();
|
||||
SendMessageW(window->win32.handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
|
||||
}
|
||||
|
||||
void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
RECT area;
|
||||
|
|
|
|||
10
src/window.c
10
src/window.c
|
|
@ -606,6 +606,16 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
|
|||
_glfw.platform.setWindowPos(window, xpos, ypos);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwStartInteractiveMove(GLFWwindow* handle)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_glfw.platform.startInteractiveMove(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
|
||||
{
|
||||
if (width)
|
||||
|
|
|
|||
|
|
@ -469,6 +469,7 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform)
|
|||
.setWindowIcon = _glfwSetWindowIconWayland,
|
||||
.getWindowPos = _glfwGetWindowPosWayland,
|
||||
.setWindowPos = _glfwSetWindowPosWayland,
|
||||
.startInteractiveMove = _glfwStartInteractiveMoveWayland,
|
||||
.getWindowSize = _glfwGetWindowSizeWayland,
|
||||
.setWindowSize = _glfwSetWindowSizeWayland,
|
||||
.setWindowSizeLimits = _glfwSetWindowSizeLimitsWayland,
|
||||
|
|
|
|||
|
|
@ -661,6 +661,7 @@ void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title);
|
|||
void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||
void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwStartInteractiveMoveWayland(_GLFWwindow* window);
|
||||
void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwSetWindowSizeWayland(_GLFWwindow* window, int width, int height);
|
||||
void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||
|
|
|
|||
|
|
@ -2546,6 +2546,19 @@ void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos)
|
|||
"Wayland: The platform does not support setting the window position");
|
||||
}
|
||||
|
||||
void _glfwStartInteractiveMoveWayland(_GLFWwindow* window)
|
||||
{
|
||||
struct xdg_toplevel* toplevel = NULL;
|
||||
|
||||
if (window->wl.libdecor.frame)
|
||||
toplevel = libdecor_frame_get_xdg_toplevel(window->wl.libdecor.frame);
|
||||
else
|
||||
toplevel = window->wl.xdg.toplevel;
|
||||
|
||||
if (toplevel)
|
||||
xdg_toplevel_move(toplevel, _glfw.wl.seat, _glfw.wl.serial);
|
||||
}
|
||||
|
||||
void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
if (width)
|
||||
|
|
|
|||
|
|
@ -1210,6 +1210,7 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
|
|||
.setWindowIcon = _glfwSetWindowIconX11,
|
||||
.getWindowPos = _glfwGetWindowPosX11,
|
||||
.setWindowPos = _glfwSetWindowPosX11,
|
||||
.startInteractiveMove = _glfwStartInteractiveMoveX11,
|
||||
.getWindowSize = _glfwGetWindowSizeX11,
|
||||
.setWindowSize = _glfwSetWindowSizeX11,
|
||||
.setWindowSizeLimits = _glfwSetWindowSizeLimitsX11,
|
||||
|
|
|
|||
|
|
@ -906,6 +906,7 @@ void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title);
|
|||
void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||
void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosX11(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwStartInteractiveMoveX11(_GLFWwindow* window);
|
||||
void _glfwGetWindowSizeX11(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwSetWindowSizeX11(_GLFWwindow* window, int width, int height);
|
||||
void _glfwSetWindowSizeLimitsX11(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||
|
|
|
|||
|
|
@ -2736,6 +2736,30 @@ void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled)
|
|||
XFlush(_glfw.x11.display);
|
||||
}
|
||||
|
||||
void _glfwStartInteractiveMoveX11(_GLFWwindow* window)
|
||||
{
|
||||
// Release the implicit grab the button press created so the WM can take over
|
||||
XUngrabPointer(_glfw.x11.display, CurrentTime);
|
||||
XFlush(_glfw.x11.display);
|
||||
|
||||
// Query the current pointer position in root coordinates
|
||||
Window dummyWin;
|
||||
int dummyInt;
|
||||
unsigned int dummyMask;
|
||||
int rootX = 0, rootY = 0;
|
||||
XQueryPointer(_glfw.x11.display, _glfw.x11.root,
|
||||
&dummyWin, &dummyWin,
|
||||
&rootX, &rootY,
|
||||
&dummyInt, &dummyInt,
|
||||
&dummyMask);
|
||||
|
||||
// Send _NET_WM_MOVERESIZE to ask the WM to begin an interactive move
|
||||
// direction 8 = _NET_WM_MOVERESIZE_MOVE, button 1, source 1 (application)
|
||||
Atom moveResize = XInternAtom(_glfw.x11.display, "_NET_WM_MOVERESIZE", False);
|
||||
sendEventToWM(window, moveResize, rootX, rootY, 8, 1, 1);
|
||||
XFlush(_glfw.x11.display);
|
||||
}
|
||||
|
||||
void _glfwSetWindowMousePassthroughX11(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
if (!_glfw.x11.xshape.available)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue