summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-03-12 17:08:07 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2017-03-23 20:17:52 +0100
commit54d0e5d4b13b18668b1c044f197fe528bb43d4a2 (patch)
tree201f88f96619d0cf3a5d2f3b1cc5805e5846d100
parentbc661e52f925cdf5fe1effdbae2f81bd796eac32 (diff)
Track and propagate parent window size changes.
-rw-r--r--plugingui/nativewindow_x11.cc18
-rw-r--r--plugingui/nativewindow_x11.h1
2 files changed, 15 insertions, 4 deletions
diff --git a/plugingui/nativewindow_x11.cc b/plugingui/nativewindow_x11.cc
index 1482d47..de2f1d1 100644
--- a/plugingui/nativewindow_x11.cc
+++ b/plugingui/nativewindow_x11.cc
@@ -58,21 +58,23 @@ NativeWindowX11::NativeWindowX11(void* native_window, Window& window)
visual = DefaultVisual(display, screen);
depth = DefaultDepth(display, screen);
- ::Window parentWindow;
if(native_window)
{
- parentWindow = (::Window)native_window;
+ parent_window = (::Window)native_window;
+
+ // Track size changes on the parent window
+ XSelectInput(display, parent_window, StructureNotifyMask);
}
else
{
- parentWindow = DefaultRootWindow(display);
+ parent_window = DefaultRootWindow(display);
}
// Create the window
XSetWindowAttributes swa;
swa.backing_store = Always;
xwindow = XCreateWindow(display,
- parentWindow,
+ parent_window,
0, 0, //window.x(), window.y(),
1, 1, //window.width(), window.height(),
0, // border
@@ -302,6 +304,14 @@ void NativeWindowX11::translateXMessage(XEvent& xevent)
case ConfigureNotify:
//DEBUG(x11, "ConfigureNotify");
+
+ // The parent window size changed, reflect the new size in our own window.
+ if(xevent.xconfigure.window == parent_window)
+ {
+ resize(xevent.xconfigure.width, xevent.xconfigure.height);
+ return;
+ }
+
{
if((window.width() != (std::size_t)xevent.xconfigure.width) ||
(window.height() != (std::size_t)xevent.xconfigure.height))
diff --git a/plugingui/nativewindow_x11.h b/plugingui/nativewindow_x11.h
index 1604734..dd2010e 100644
--- a/plugingui/nativewindow_x11.h
+++ b/plugingui/nativewindow_x11.h
@@ -87,6 +87,7 @@ private:
int depth{0};
Visual* visual{nullptr};
Atom wmDeleteMessage{0};
+ ::Window parent_window;
EventQueue event_queue;
};