From 728abec962f993309acf3ebb1317b5f3773f18c7 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 8 Feb 2017 22:22:00 +0100 Subject: UI resize refactoring part 1. --- plugingui/nativewindow_x11.cc | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'plugingui/nativewindow_x11.cc') diff --git a/plugingui/nativewindow_x11.cc b/plugingui/nativewindow_x11.cc index 92e1f3a..f50e01d 100644 --- a/plugingui/nativewindow_x11.cc +++ b/plugingui/nativewindow_x11.cc @@ -73,8 +73,8 @@ NativeWindowX11::NativeWindowX11(void* native_window, Window& window) swa.backing_store = Always; xwindow = XCreateWindow(display, parentWindow, - window.x(), window.y(), - window.width(), window.height(), + 0, 0, //window.x(), window.y(), + 1, 1, //window.width(), window.height(), 0, // border CopyFromParent, // depth CopyFromParent, // class @@ -119,7 +119,7 @@ NativeWindowX11::~NativeWindowX11() XCloseDisplay(display); } -void NativeWindowX11::setFixedSize(int width, int height) +void NativeWindowX11::setFixedSize(std::size_t width, std::size_t height) { if(display == nullptr) { @@ -149,7 +149,7 @@ void NativeWindowX11::setFixedSize(int width, int height) XSetWMNormalHints(display, xwindow, size_hints); } -void NativeWindowX11::resize(int width, int height) +void NativeWindowX11::resize(std::size_t width, std::size_t height) { if(display == nullptr) { @@ -159,6 +159,23 @@ void NativeWindowX11::resize(int width, int height) XResizeWindow(display, xwindow, width, height); } +std::pair NativeWindowX11::getSize() +{ +// XWindowAttributes attributes; +// XGetWindowAttributes(display, xwindow, &attributes); +// return std::make_pair(attributes.width, attributes.height); + + ::Window root_window; + int x, y; + unsigned int width, height, border, depth; + + XGetGeometry(display, xwindow, &root_window, + &x, &y, + &width, &height, &border, &depth); + + return std::make_pair(width, height); +} + void NativeWindowX11::move(int x, int y) { if(display == nullptr) @@ -169,6 +186,23 @@ void NativeWindowX11::move(int x, int y) XMoveWindow(display, xwindow, x, y); } +std::pair NativeWindowX11::getPosition() +{ + ::Window root_window; + ::Window child_window; + int x, y; + unsigned int width, height, border, depth; + + XGetGeometry(display, xwindow, &root_window, + &x, &y, + &width, &height, &border, &depth); + + XTranslateCoordinates(display, xwindow, root_window, + 0, 0, &x, &y, &child_window); + + return std::make_pair(x, y); +} + void NativeWindowX11::show() { if(display == nullptr) -- cgit v1.2.3