1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

Implement window_start_drag on Windows and Linux.

This commit is contained in:
Pāvels Nadtočajevs
2024-12-16 10:01:07 +02:00
parent 4364ed6ccd
commit 293be04ec8
9 changed files with 82 additions and 1 deletions

View File

@@ -69,6 +69,8 @@
#define _NET_WM_STATE_REMOVE 0L // remove/unset property
#define _NET_WM_STATE_ADD 1L // add/set property
#define _NET_WM_MOVERESIZE_MOVE 8L
// 2.2 is the first release with multitouch
#define XINPUT_CLIENT_VERSION_MAJOR 2
#define XINPUT_CLIENT_VERSION_MINOR 2
@@ -5422,6 +5424,40 @@ DisplayServer::VSyncMode DisplayServerX11::window_get_vsync_mode(WindowID p_wind
return DisplayServer::VSYNC_ENABLED;
}
void DisplayServerX11::window_start_drag(WindowID p_window) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
XClientMessageEvent m;
memset(&m, 0, sizeof(m));
XUngrabPointer(x11_display, CurrentTime);
Window root_return, child_return;
int root_x, root_y, win_x, win_y;
unsigned int mask_return;
Bool xquerypointer_result = XQueryPointer(x11_display, wd.x11_window, &root_return, &child_return, &root_x, &root_y, &win_x, &win_y, &mask_return);
m.type = ClientMessage;
m.window = wd.x11_window;
m.message_type = XInternAtom(x11_display, "_NET_WM_MOVERESIZE", True);
m.format = 32;
if (xquerypointer_result) {
m.data.l[0] = root_x;
m.data.l[1] = root_y;
m.data.l[3] = Button1;
}
m.data.l[2] = _NET_WM_MOVERESIZE_MOVE;
m.data.l[4] = 1; // Source - normal application.
XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&m);
XSync(x11_display, 0);
}
Vector<String> DisplayServerX11::get_rendering_drivers_func() {
Vector<String> drivers;