Compare commits
4 Commits
master
...
drag-windo
Author | SHA1 | Date | |
---|---|---|---|
|
cad8f2f7d5 | ||
|
ea46ea0929 | ||
|
ce87a1142e | ||
|
a4c76fbeed |
@ -138,6 +138,8 @@ information on what to include when reporting a bug.
|
|||||||
for retrieving gamepad input state (#900)
|
for retrieving gamepad input state (#900)
|
||||||
- Added `glfwRequestWindowAttention` function for requesting attention from the
|
- Added `glfwRequestWindowAttention` function for requesting attention from the
|
||||||
user (#732,#988)
|
user (#732,#988)
|
||||||
|
- Added `glfwDragWindow` function for starting a drag operation on a window
|
||||||
|
(#987)
|
||||||
- Added `glfwGetKeyScancode` function that allows retrieving platform dependent
|
- Added `glfwGetKeyScancode` function that allows retrieving platform dependent
|
||||||
scancodes for keys (#830)
|
scancodes for keys (#830)
|
||||||
- Added `glfwSetWindowMaximizeCallback` and `GLFWwindowmaximizefun` for
|
- Added `glfwSetWindowMaximizeCallback` and `GLFWwindowmaximizefun` for
|
||||||
|
@ -2929,6 +2929,21 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window);
|
|||||||
*/
|
*/
|
||||||
GLFWAPI void glfwFocusWindow(GLFWwindow* window);
|
GLFWAPI void glfwFocusWindow(GLFWwindow* window);
|
||||||
|
|
||||||
|
/*! @brief Starts drag operation to the specified window.
|
||||||
|
*
|
||||||
|
* This function starts the drag operation of the specified window.
|
||||||
|
*
|
||||||
|
* @param[in] window The window to start the dragging operation.
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref window_drag
|
||||||
|
*
|
||||||
|
* @since Added in version 3.3.
|
||||||
|
*
|
||||||
|
* @ingroup window
|
||||||
|
*/
|
||||||
|
GLFWAPI void glfwDragWindow(GLFWwindow* handle);
|
||||||
|
|
||||||
/*! @brief Requests user attention to the specified window.
|
/*! @brief Requests user attention to the specified window.
|
||||||
*
|
*
|
||||||
* This function requests user attention to the specified window. On
|
* This function requests user attention to the specified window. On
|
||||||
|
@ -1298,6 +1298,11 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
|||||||
[window->ns.object makeKeyAndOrderFront:nil];
|
[window->ns.object makeKeyAndOrderFront:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformDragWindow(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
[window->ns.object performWindowDragWithEvent:[NSApp currentEvent]];
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||||
_GLFWmonitor* monitor,
|
_GLFWmonitor* monitor,
|
||||||
int xpos, int ypos,
|
int xpos, int ypos,
|
||||||
|
@ -674,6 +674,7 @@ void _glfwPlatformShowWindow(_GLFWwindow* window);
|
|||||||
void _glfwPlatformHideWindow(_GLFWwindow* window);
|
void _glfwPlatformHideWindow(_GLFWwindow* window);
|
||||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window);
|
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window);
|
||||||
void _glfwPlatformFocusWindow(_GLFWwindow* window);
|
void _glfwPlatformFocusWindow(_GLFWwindow* window);
|
||||||
|
void _glfwPlatformDragWindow(_GLFWwindow* window);
|
||||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||||
int _glfwPlatformWindowFocused(_GLFWwindow* window);
|
int _glfwPlatformWindowFocused(_GLFWwindow* window);
|
||||||
int _glfwPlatformWindowIconified(_GLFWwindow* window);
|
int _glfwPlatformWindowIconified(_GLFWwindow* window);
|
||||||
|
@ -582,6 +582,10 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
|||||||
"Mir: Unsupported function %s", __PRETTY_FUNCTION__);
|
"Mir: Unsupported function %s", __PRETTY_FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformDragWindow(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||||
_GLFWmonitor* monitor,
|
_GLFWmonitor* monitor,
|
||||||
int xpos, int ypos,
|
int xpos, int ypos,
|
||||||
|
@ -189,6 +189,10 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformDragWindow(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int _glfwPlatformWindowFocused(_GLFWwindow* window)
|
int _glfwPlatformWindowFocused(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
@ -1328,6 +1328,12 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
|||||||
SetFocus(window->win32.handle);
|
SetFocus(window->win32.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformDragWindow(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
ReleaseCapture();
|
||||||
|
SendMessage(window->win32.handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||||
_GLFWmonitor* monitor,
|
_GLFWmonitor* monitor,
|
||||||
int xpos, int ypos,
|
int xpos, int ypos,
|
||||||
|
10
src/window.c
10
src/window.c
@ -708,6 +708,16 @@ GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
|
|||||||
_glfwPlatformFocusWindow(window);
|
_glfwPlatformFocusWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwDragWindow(GLFWwindow* handle)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
|
assert(window != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
|
_glfwPlatformDragWindow(window);
|
||||||
|
}
|
||||||
|
|
||||||
GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
|
@ -612,6 +612,11 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
|||||||
"Wayland: Focusing a window requires user interaction");
|
"Wayland: Focusing a window requires user interaction");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformDragWindow(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
wl_shell_surface_move(window->wl.shellSurface, _glfw.wl.seat, _glfw.wl.pointerSerial);
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||||
_GLFWmonitor* monitor,
|
_GLFWmonitor* monitor,
|
||||||
int xpos, int ypos,
|
int xpos, int ypos,
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#define _NET_WM_STATE_REMOVE 0
|
#define _NET_WM_STATE_REMOVE 0
|
||||||
#define _NET_WM_STATE_ADD 1
|
#define _NET_WM_STATE_ADD 1
|
||||||
#define _NET_WM_STATE_TOGGLE 2
|
#define _NET_WM_STATE_TOGGLE 2
|
||||||
|
#define _NET_WM_MOVERESIZE_MOVE 8
|
||||||
|
|
||||||
// Additional mouse button names for XButtonEvent
|
// Additional mouse button names for XButtonEvent
|
||||||
#define Button6 6
|
#define Button6 6
|
||||||
@ -2143,6 +2144,28 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
|||||||
XFlush(_glfw.x11.display);
|
XFlush(_glfw.x11.display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformDragWindow(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
xclient.data.l[2] = _NET_WM_MOVERESIZE_MOVE;
|
||||||
|
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,
|
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||||
_GLFWmonitor* monitor,
|
_GLFWmonitor* monitor,
|
||||||
int xpos, int ypos,
|
int xpos, int ypos,
|
||||||
|
@ -88,6 +88,12 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
|
||||||
|
{
|
||||||
|
if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS)
|
||||||
|
glfwDragWindow(window);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int i, ch;
|
int i, ch;
|
||||||
@ -131,6 +137,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
glfwSetKeyCallback(windows[i], key_callback);
|
glfwSetKeyCallback(windows[i], key_callback);
|
||||||
|
glfwSetMouseButtonCallback(windows[i], mouse_button_callback);
|
||||||
|
|
||||||
glfwMakeContextCurrent(windows[i]);
|
glfwMakeContextCurrent(windows[i]);
|
||||||
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
||||||
|
Loading…
Reference in New Issue
Block a user