From 0531409611867ae8dad711e52d6534fa634d40cc Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 10 Sep 2017 17:52:32 +0200 Subject: Initial steps towards pugl domination! --- plugingui/nativewindow_x11.cc | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'plugingui/nativewindow_x11.cc') diff --git a/plugingui/nativewindow_x11.cc b/plugingui/nativewindow_x11.cc index 5faecc1..056c69f 100644 --- a/plugingui/nativewindow_x11.cc +++ b/plugingui/nativewindow_x11.cc @@ -130,25 +130,14 @@ void NativeWindowX11::setFixedSize(std::size_t width, std::size_t height) resize(width, height); - XSizeHints* size_hints; - size_hints = XAllocSizeHints(); + XSizeHints size_hints; + memset(&size_hints, 0, sizeof(size_hints)); - if(size_hints == nullptr) - { - ERR(X11,"XMallocSizeHints() failed"); - return; - } - - size_hints->flags = USPosition | PMinSize | PMaxSize; - size_hints->min_width = size_hints->max_width = width; - size_hints->min_height = size_hints->max_height = height; - - //size_hints->min_aspect.x = (float)window.width()/(float)window.height(); - //size_hints->max_aspect.x = (float)window.width()/(float)window.height(); - //size_hints->min_aspect.y = (float)window.width()/(float)window.height(); - //size_hints->max_aspect.y = size_hints->min_aspect.y; + size_hints.flags = PMinSize|PMaxSize; + size_hints.min_width = size_hints.max_width = (int)width; + size_hints.min_height = size_hints.max_height = (int)height; - XSetWMNormalHints(display, xwindow, size_hints); + XSetNormalHints(display, xwindow, &size_hints); } void NativeWindowX11::resize(std::size_t width, std::size_t height) @@ -161,7 +150,7 @@ void NativeWindowX11::resize(std::size_t width, std::size_t height) XResizeWindow(display, xwindow, width, height); } -std::pair NativeWindowX11::getSize() +std::pair NativeWindowX11::getSize() const { // XWindowAttributes attributes; // XGetWindowAttributes(display, xwindow, &attributes); @@ -175,7 +164,7 @@ std::pair NativeWindowX11::getSize() &x, &y, &width, &height, &border, &depth); - return std::make_pair(width, height); + return {width, height}; } void NativeWindowX11::move(int x, int y) @@ -188,7 +177,7 @@ void NativeWindowX11::move(int x, int y) XMoveWindow(display, xwindow, x, y); } -std::pair NativeWindowX11::getPosition() +std::pair NativeWindowX11::getPosition() const { ::Window root_window; ::Window child_window; -- cgit v1.2.3