diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2017-04-18 14:58:49 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2017-04-18 14:59:08 +0200 |
commit | b382c7e3c6645c977cd9a7bf28b639a349d5bbde (patch) | |
tree | 18813fb8f00f4814749957bd37af31de3b2c1cc3 | |
parent | 37cb6cefcab6be0a1337e0a346d6e259f8dbbb5f (diff) |
Make visible() call into nativewindow and make Win32 windows invisible on creation.
-rw-r--r-- | plugingui/nativewindow.h | 3 | ||||
-rw-r--r-- | plugingui/nativewindow_win32.cc | 7 | ||||
-rw-r--r-- | plugingui/nativewindow_win32.h | 3 | ||||
-rw-r--r-- | plugingui/nativewindow_x11.cc | 12 | ||||
-rw-r--r-- | plugingui/nativewindow_x11.h | 1 | ||||
-rw-r--r-- | plugingui/widget.h | 2 | ||||
-rw-r--r-- | plugingui/window.cc | 9 | ||||
-rw-r--r-- | plugingui/window.h | 1 |
8 files changed, 31 insertions, 7 deletions
diff --git a/plugingui/nativewindow.h b/plugingui/nativewindow.h index b4429af..6dcb308 100644 --- a/plugingui/nativewindow.h +++ b/plugingui/nativewindow.h @@ -68,6 +68,9 @@ public: //! Hides the window. virtual void hide() = 0; + //! Return visibility state of the native window. + virtual bool visible() const = 0; + //! Sets the window caption in the title bar (if it has one). virtual void setCaption(const std::string &caption) = 0; diff --git a/plugingui/nativewindow_win32.cc b/plugingui/nativewindow_win32.cc index 01a2fa8..f2387c7 100644 --- a/plugingui/nativewindow_win32.cc +++ b/plugingui/nativewindow_win32.cc @@ -367,7 +367,7 @@ NativeWindowWin32::NativeWindowWin32(void* native_window, Window& window) m_hwnd = CreateWindowEx(0/*ex_style*/, m_className, "DGBasisWidget", - (native_window?WS_CHILD:WS_OVERLAPPEDWINDOW) | WS_VISIBLE, + (native_window?WS_CHILD:WS_OVERLAPPEDWINDOW), 0, 0, //window.x(), window.y(), 1, 1, //window.width(), window.height(), parent_window, nullptr, @@ -455,6 +455,11 @@ void NativeWindowWin32::hide() ShowWindow(m_hwnd, SW_HIDE); } +bool NativeWindowWin32::visible() const +{ + return IsWindowVisible(m_hwnd); +} + void NativeWindowWin32::redraw(const Rect& dirty_rect) { // Send WM_PAINT message. Buffer transfering is handled in MessageHandler. diff --git a/plugingui/nativewindow_win32.h b/plugingui/nativewindow_win32.h index c7d412a..bb407d8 100644 --- a/plugingui/nativewindow_win32.h +++ b/plugingui/nativewindow_win32.h @@ -50,9 +50,10 @@ public: void move(int x, int y) override; std::pair<int, int> getPosition() override; void show() override; - void setCaption(const std::string &caption) override; + bool visible() const override; void hide() override; void redraw(const Rect& dirty_rect) override; + void setCaption(const std::string &caption) override; void grabMouse(bool grab) override; EventQueue getEvents() override; void* getNativeWindowHandle() const override; diff --git a/plugingui/nativewindow_x11.cc b/plugingui/nativewindow_x11.cc index af2f4a6..ae8ad2c 100644 --- a/plugingui/nativewindow_x11.cc +++ b/plugingui/nativewindow_x11.cc @@ -225,6 +225,18 @@ void NativeWindowX11::hide() XUnmapWindow(display, xwindow); } +bool NativeWindowX11::visible() const +{ + if(display == nullptr) + { + return false; + } + + XWindowAttributes xwa; + XGetWindowAttributes(display, xwindow, &xwa); + return (xwa.map_state == IsViewable); +} + void NativeWindowX11::redraw(const Rect& dirty_rect) { if(display == nullptr) diff --git a/plugingui/nativewindow_x11.h b/plugingui/nativewindow_x11.h index c850318..c6c038e 100644 --- a/plugingui/nativewindow_x11.h +++ b/plugingui/nativewindow_x11.h @@ -53,6 +53,7 @@ public: std::pair<int, int> getPosition() override; void show() override; void hide() override; + bool visible() const override; void setCaption(const std::string &caption) override; void redraw(const Rect& dirty_rect) override; void grabMouse(bool grab) override; diff --git a/plugingui/widget.h b/plugingui/widget.h index 0485c32..3b17f1f 100644 --- a/plugingui/widget.h +++ b/plugingui/widget.h @@ -53,7 +53,7 @@ public: virtual void show(); virtual void hide(); void setVisible(bool visible); - bool visible() const; + virtual bool visible() const; //! Mark widget dirty and shedule redraw on next window redraw. void redraw(); diff --git a/plugingui/window.cc b/plugingui/window.cc index a38eeea..3840643 100644 --- a/plugingui/window.cc +++ b/plugingui/window.cc @@ -51,10 +51,6 @@ Window::Window(void* native_window) : Widget(nullptr) , wpixbuf(1, 1) { - // Defaults to true for widgets but the window should be considered invisble - // until show is called. - _visible = false; - // Make sure we have a valid size when initialising the NativeWindow _width = wpixbuf.width; _height = wpixbuf.height; @@ -122,6 +118,11 @@ void Window::hide() Widget::hide(); } +bool Window::visible() const +{ + return native->visible(); +} + Window* Window::window() { return this; diff --git a/plugingui/window.h b/plugingui/window.h index 218beec..e248b69 100644 --- a/plugingui/window.h +++ b/plugingui/window.h @@ -52,6 +52,7 @@ public: void move(int x, int y) override; void show() override; void hide() override; + bool visible() const override; Window* window() override; ImageCache& getImageCache() override; |