summaryrefslogtreecommitdiff
path: root/platform/x11
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2019-03-12 19:09:16 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2019-03-12 19:09:16 +0200
commit85cc435103e539990f095966aaa3ea786a7dd386 (patch)
treec3a2d44f026b184810b1c7170f00316a4dd07e11 /platform/x11
parent51f6138cb3ef23af9e8c41ff3a4a83b7f28cc658 (diff)
[X11] Fix `get_window_position` to return absolute coordinates, change `set_window_position` to take window decorations into account.
Diffstat (limited to 'platform/x11')
-rw-r--r--platform/x11/os_x11.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 0fe91f3d00..bd0e738c99 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -1176,15 +1176,28 @@ Point2 OS_X11::get_window_position() const {
int x, y;
Window child;
XTranslateCoordinates(x11_display, x11_window, DefaultRootWindow(x11_display), 0, 0, &x, &y, &child);
-
- int screen = get_current_screen();
- Point2i screen_position = get_screen_position(screen);
-
- return Point2i(x - screen_position.x, y - screen_position.y);
+ return Point2i(x, y);
}
void OS_X11::set_window_position(const Point2 &p_position) {
- XMoveWindow(x11_display, x11_window, p_position.x, p_position.y);
+ int x = 0;
+ int y = 0;
+ if (get_borderless_window() == false) {
+ //exclude window decorations
+ XSync(x11_display, False);
+ Atom prop = XInternAtom(x11_display, "_NET_FRAME_EXTENTS", True);
+ Atom type;
+ int format;
+ unsigned long len;
+ unsigned long remaining;
+ unsigned char *data = NULL;
+ if (XGetWindowProperty(x11_display, x11_window, prop, 0, 4, False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) {
+ long *extents = (long *)data;
+ x = extents[0];
+ y = extents[2];
+ }
+ }
+ XMoveWindow(x11_display, x11_window, p_position.x - x, p_position.y - y);
update_real_mouse_position();
}