diff --git a/source/libs/distrho/dgl/Window.hpp b/source/libs/distrho/dgl/Window.hpp index d94b3b0d1..73f5b5a12 100644 --- a/source/libs/distrho/dgl/Window.hpp +++ b/source/libs/distrho/dgl/Window.hpp @@ -17,7 +17,7 @@ #ifndef __DGL_WINDOW_HPP__ #define __DGL_WINDOW_HPP__ -#include "Base.hpp" +#include "Geometry.hpp" START_NAMESPACE_DISTRHO @@ -61,6 +61,10 @@ public: setVisible(false); } +#if DISTRHO_OS_WINDOWS + Rectangle getBounds(); +#endif + private: class Private; Private* const kPrivate; diff --git a/source/libs/distrho/dgl/src/ImageAboutWindow.cpp b/source/libs/distrho/dgl/src/ImageAboutWindow.cpp index 3f4f3653d..8c80fcaa0 100644 --- a/source/libs/distrho/dgl/src/ImageAboutWindow.cpp +++ b/source/libs/distrho/dgl/src/ImageAboutWindow.cpp @@ -25,7 +25,13 @@ ImageAboutWindow::ImageAboutWindow(App* app, Window* parent, const Image& image) Widget(this), fImgBackground(image) { +#if DISTRHO_OS_WINDOWS + // FIXME + Window::setSize(image.getWidth()+1, image.getHeight()+1); +#else Window::setSize(image.getWidth(), image.getHeight()); +#endif + Window::setWindowTitle("About"); Window::show(); } diff --git a/source/libs/distrho/dgl/src/Widget.cpp b/source/libs/distrho/dgl/src/Widget.cpp index 5eb3a0494..1891c9cf4 100644 --- a/source/libs/distrho/dgl/src/Widget.cpp +++ b/source/libs/distrho/dgl/src/Widget.cpp @@ -217,8 +217,15 @@ void Widget::onReshape(int width, int height) glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrtho(0, width, height, 0, 0, 1); + +#if DISTRHO_OS_WINDOWS + Rectangle r(fParent->getBounds()); + glOrtho(r.getX(), r.getWidth(), r.getHeight(), r.getY(), -1.0f, 1.0f); + glViewport(0, 0, r.getWidth() - r.getX(), r.getHeight() - r.getY()); +#else + glOrtho(0, width, height, 0, 0.0f, 1.0f); glViewport(0, 0, width, height); +#endif glMatrixMode(GL_MODELVIEW); glLoadIdentity(); diff --git a/source/libs/distrho/dgl/src/Window.cpp b/source/libs/distrho/dgl/src/Window.cpp index 0644bdce8..abb0c215a 100644 --- a/source/libs/distrho/dgl/src/Window.cpp +++ b/source/libs/distrho/dgl/src/Window.cpp @@ -85,6 +85,7 @@ public: #if DISTRHO_OS_WINDOWS hwnd = impl->hwnd; + #elif DISTRHO_OS_LINUX xDisplay = impl->display; xWindow = impl->win; @@ -222,7 +223,17 @@ public: void setSize(unsigned int width, unsigned int height) { -#if DISTRHO_OS_LINUX +#if DISTRHO_OS_WINDOWS + RECT rcClient; + RECT rcWindow; + POINT ptDiff; + GetClientRect(hwnd, &rcClient); + GetWindowRect(hwnd, &rcWindow); + ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right; + ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom; + SetWindowPos(hwnd, 0, 0, 0, width + ptDiff.x, height + ptDiff.y, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER); + UpdateWindow(hwnd); +#elif DISTRHO_OS_LINUX XSizeHints sizeHints; memset(&sizeHints, 0, sizeof(sizeHints)); @@ -273,6 +284,16 @@ public: fWidgets.remove(widget); } +#if DISTRHO_OS_WINDOWS + Rectangle getBounds() + { + RECT rcClient; + GetClientRect(hwnd, &rcClient); + + return Rectangle(rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); + } +#endif + protected: void onDisplay() { @@ -542,6 +563,13 @@ void Window::removeWidget(Widget* widget) kPrivate->removeWidget(widget); } +#if DISTRHO_OS_WINDOWS +Rectangle Window::getBounds() +{ + return kPrivate->getBounds(); +} +#endif + // ------------------------------------------------- END_NAMESPACE_DISTRHO diff --git a/source/libs/distrho/dgl/src/pugl/pugl_win.cpp b/source/libs/distrho/dgl/src/pugl/pugl_win.cpp index a5d71912d..d39efa886 100644 --- a/source/libs/distrho/dgl/src/pugl/pugl_win.cpp +++ b/source/libs/distrho/dgl/src/pugl/pugl_win.cpp @@ -74,8 +74,8 @@ puglCreate(PuglNativeWindow parent, impl->hwnd = CreateWindow( "Pugl", title, - (addToDesktop ? WS_VISIBLE : 0) | (parent ? WS_CHILD : (WS_POPUPWINDOW | WS_CAPTION)), - 0, 0, width, height, + (addToDesktop ? WS_VISIBLE : 0) | (parent ? WS_CHILD : (WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX)), + CW_USEDEFAULT, CW_USEDEFAULT, width, height, (HWND)parent, NULL, NULL, NULL); if (!impl->hwnd) { free(impl);