diff --git a/src/she/skia/skia_display.cpp b/src/she/skia/skia_display.cpp index 8982077fc..4b84803e3 100644 --- a/src/she/skia/skia_display.cpp +++ b/src/she/skia/skia_display.cpp @@ -109,6 +109,11 @@ bool SkiaDisplay::isMaximized() const return m_window.isMaximized(); } +bool SkiaDisplay::isMinimized() const +{ + return m_window.isMinimized(); +} + void SkiaDisplay::setTitleBar(const std::string& title) { m_window.setTitle(title); @@ -140,6 +145,16 @@ void SkiaDisplay::releaseMouse() m_window.releaseMouse(); } +std::string SkiaDisplay::getLayout() +{ + return m_window.getLayout(); +} + +void SkiaDisplay::setLayout(const std::string& layout) +{ + m_window.setLayout(layout); +} + DisplayHandle SkiaDisplay::nativeHandle() { return (DisplayHandle)m_window.handle(); diff --git a/src/she/skia/skia_display.h b/src/she/skia/skia_display.h index 21ab24189..00b77debf 100644 --- a/src/she/skia/skia_display.h +++ b/src/she/skia/skia_display.h @@ -44,6 +44,7 @@ public: void flip(const gfx::Rect& bounds) override; void maximize() override; bool isMaximized() const override; + bool isMinimized() const override; void setTitleBar(const std::string& title) override; NativeCursor nativeMouseCursor() override; bool setNativeMouseCursor(NativeCursor cursor) override; @@ -51,6 +52,9 @@ public: void captureMouse() override; void releaseMouse() override; + std::string getLayout() override; + void setLayout(const std::string& layout) override; + // Returns the HWND on Windows. DisplayHandle nativeHandle() override; diff --git a/src/she/skia/skia_window_osx.h b/src/she/skia/skia_window_osx.h index 8012f4f9b..c8785d1be 100644 --- a/src/she/skia/skia_window_osx.h +++ b/src/she/skia/skia_window_osx.h @@ -31,6 +31,7 @@ public: void setVisible(bool visible); void maximize(); bool isMaximized() const; + bool isMinimized() const; gfx::Size clientSize() const; gfx::Size restoredSize() const; void setTitle(const std::string& title); @@ -39,6 +40,8 @@ public: void setMousePosition(const gfx::Point& position); bool setNativeMouseCursor(NativeCursor cursor); void updateWindow(const gfx::Rect& bounds); + std::string getLayout() { return ""; } + void setLayout(const std::string& layout) { } void* handle(); private: diff --git a/src/she/skia/skia_window_osx.mm b/src/she/skia/skia_window_osx.mm index 89d2f6516..82d9ee736 100644 --- a/src/she/skia/skia_window_osx.mm +++ b/src/she/skia/skia_window_osx.mm @@ -195,7 +195,7 @@ private: [m_nsGL setView:m_window.contentView]; } catch (const std::exception& ex) { - LOG("Cannot create GL context: %s\n", ex.what()); + //LOG("Cannot create GL context: %s\n", ex.what()); detachGL(); return false; } @@ -340,6 +340,11 @@ bool SkiaWindow::isMaximized() const return false; } +bool SkiaWindow::isMinimized() const +{ + return false; +} + gfx::Size SkiaWindow::clientSize() const { if (!m_impl) diff --git a/src/she/skia/skia_window_win.cpp b/src/she/skia/skia_window_win.cpp index 602df48ad..94728debd 100644 --- a/src/she/skia/skia_window_win.cpp +++ b/src/she/skia/skia_window_win.cpp @@ -157,7 +157,7 @@ bool SkiaWindow::attachGL() (GrBackendContext)m_glCtx->gl())); } catch (const std::exception& ex) { - LOG("Cannot create GL context: %s\n", ex.what()); + //LOG("Cannot create GL context: %s\n", ex.what()); detachGL(); } } diff --git a/src/she/win/window.h b/src/she/win/window.h index bad64f5f2..f16f76438 100644 --- a/src/she/win/window.h +++ b/src/she/win/window.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "gfx/size.h" #include "she/event.h" @@ -73,6 +74,10 @@ namespace she { return (IsZoomed(m_hwnd) ? true: false); } + bool isMinimized() const { + return (GetWindowLong(m_hwnd, GWL_STYLE) & WS_MINIMIZE ? true: false); + } + gfx::Size clientSize() const { return m_clientSize; } @@ -162,6 +167,54 @@ namespace she { UpdateWindow(m_hwnd); } + std::string getLayout() { + WINDOWPLACEMENT wp; + wp.length = sizeof(WINDOWPLACEMENT); + if (GetWindowPlacement(m_hwnd, &wp)) { + std::ostringstream s; + s << 1 << ' ' + << wp.flags << ' ' + << wp.showCmd << ' ' + << wp.ptMinPosition.x << ' ' + << wp.ptMinPosition.y << ' ' + << wp.ptMaxPosition.x << ' ' + << wp.ptMaxPosition.y << ' ' + << wp.rcNormalPosition.left << ' ' + << wp.rcNormalPosition.top << ' ' + << wp.rcNormalPosition.right << ' ' + << wp.rcNormalPosition.bottom; + return s.str(); + } + return ""; + } + + void setLayout(const std::string& layout) { + WINDOWPLACEMENT wp; + wp.length = sizeof(WINDOWPLACEMENT); + + std::istringstream s(layout); + int ver; + s >> ver; + if (ver == 1) { + s >> wp.flags + >> wp.showCmd + >> wp.ptMinPosition.x + >> wp.ptMinPosition.y + >> wp.ptMaxPosition.x + >> wp.ptMaxPosition.y + >> wp.rcNormalPosition.left + >> wp.rcNormalPosition.top + >> wp.rcNormalPosition.right + >> wp.rcNormalPosition.bottom; + } + else + return; + + if (SetWindowPlacement(m_hwnd, &wp)) { + // TODO use the return value + } + } + HWND handle() { return m_hwnd; }