diff options
author | Marcelo Fernandez <marcelofg55@gmail.com> | 2018-02-12 14:17:29 -0300 |
---|---|---|
committer | Marcelo Fernandez <marcelofg55@gmail.com> | 2018-02-12 15:45:41 -0300 |
commit | ea1d726a4603fdd6bd4dfa6c1fa3128cfb2915c7 (patch) | |
tree | 109889d417d20c47442d9bcae765fb7f0703018d /platform/x11 | |
parent | f961ba004b1d67cbc0835202930fa8d16b8ff07a (diff) |
Added OS::center_window to center the window precisely on desktop platforms
Diffstat (limited to 'platform/x11')
-rw-r--r-- | platform/x11/os_x11.cpp | 20 | ||||
-rw-r--r-- | platform/x11/os_x11.h | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index eaf72d4dbf..bd2abc1094 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -924,6 +924,26 @@ Size2 OS_X11::get_window_size() const { return Size2i(current_videomode.width, current_videomode.height); } +Size2 OS_X11::get_real_window_size() const { + XWindowAttributes xwa; + XSync(x11_display, False); + XGetWindowAttributes(x11_display, x11_window, &xwa); + int w = xwa.width; + int h = xwa.height; + 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; + w += extents[0] + extents[1]; // left, right + h += extents[2] + extents[3]; // top, bottom + } + return Size2(w, h); +} + void OS_X11::set_window_size(const Size2 p_size) { // If window resizable is disabled we need to update the attributes first if (is_window_resizable() == false) { diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index ee62b89227..3347b37f47 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -251,6 +251,7 @@ public: virtual Point2 get_window_position() const; virtual void set_window_position(const Point2 &p_position); virtual Size2 get_window_size() const; + virtual Size2 get_real_window_size() const; virtual void set_window_size(const Size2 p_size); virtual void set_window_fullscreen(bool p_enabled); virtual bool is_window_fullscreen() const; |