Signed-off-by: falkTX <falktx@falktx.com>pull/281/head
@@ -145,8 +145,10 @@ void Window::setSize(uint width, uint height) | |||
// handle geometry constraints here | |||
if (width < pData->minWidth) | |||
width = pData->minWidth; | |||
if (height < pData->minHeight) | |||
height = pData->minHeight; | |||
if (pData->keepAspectRatio) | |||
{ | |||
const double ratio = static_cast<double>(pData->minWidth) | |||
@@ -166,10 +168,6 @@ void Window::setSize(uint width, uint height) | |||
} | |||
} | |||
// FIXME add default and min props for this | |||
if (pData->minWidth == 0 && pData->minHeight == 0) | |||
puglSetDefaultSize(pData->view, static_cast<int>(width), static_cast<int>(height)); | |||
puglSetWindowSize(pData->view, width, height); | |||
} | |||
@@ -145,10 +145,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, | |||
modal() | |||
{ | |||
if (isEmbed) | |||
{ | |||
// puglSetDefaultSize(DEFAULT_WIDTH, DEFAULT_HEIGHT, height); | |||
puglSetParentWindow(view, parentWindowHandle); | |||
} | |||
initPre(DEFAULT_WIDTH, DEFAULT_HEIGHT, resizable); | |||
} | |||
@@ -177,10 +174,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, | |||
modal() | |||
{ | |||
if (isEmbed) | |||
{ | |||
puglSetDefaultSize(view, static_cast<int>(width), static_cast<int>(height)); | |||
puglSetParentWindow(view, parentWindowHandle); | |||
} | |||
initPre(width, height, resizable); | |||
} | |||
@@ -226,6 +220,9 @@ void Window::PrivateData::initPre(const uint width, const uint height, const boo | |||
puglSetMatchingBackendForCurrentBuild(view); | |||
puglClearMinSize(view); | |||
puglSetWindowSize(view, width, height); | |||
puglSetHandle(view, this); | |||
puglSetViewHint(view, PUGL_RESIZABLE, resizable ? PUGL_TRUE : PUGL_FALSE); | |||
puglSetViewHint(view, PUGL_IGNORE_KEY_REPEAT, PUGL_FALSE); | |||
@@ -233,11 +230,6 @@ void Window::PrivateData::initPre(const uint width, const uint height, const boo | |||
puglSetViewHint(view, PUGL_STENCIL_BITS, 8); | |||
// PUGL_SAMPLES ?? | |||
puglSetEventFunc(view, puglEventCallback); | |||
PuglRect rect = puglGetFrame(view); | |||
rect.width = width; | |||
rect.height = height; | |||
puglSetFrame(view, rect); | |||
} | |||
void Window::PrivateData::initPost() | |||
@@ -303,7 +295,6 @@ void Window::PrivateData::show() | |||
// FIXME | |||
PuglRect rect = puglGetFrame(view); | |||
puglSetDefaultSize(view, static_cast<int>(rect.width), static_cast<int>(rect.height)); | |||
puglSetWindowSize(view, static_cast<uint>(rect.width), static_cast<uint>(rect.height)); | |||
#ifdef DISTRHO_OS_WINDOWS | |||
@@ -562,10 +553,6 @@ void Window::PrivateData::startModal() | |||
// make parent give focus to us | |||
modal.parent->modal.child = this; | |||
// FIXME? | |||
PuglRect rect = puglGetFrame(view); | |||
puglSetDefaultSize(view, static_cast<int>(rect.width), static_cast<int>(rect.height)); | |||
// make sure both parent and ourselves are visible | |||
modal.parent->show(); | |||
show(); | |||
@@ -659,8 +646,8 @@ void Window::PrivateData::onPuglConfigure(const double width, const double heigh | |||
/* Some special care here, we call Widget::setSize instead of the TopLevelWidget one. | |||
* This is because we want TopLevelWidget::setSize to handle both window and widget size, | |||
* but we dont want to change window size here, because we are the window.. | |||
* | |||
* So we just call the Widget specific method manually. | |||
* | |||
* Alternatively, we could expose a resize function on the pData, like done with the display function. | |||
* But there is nothing extra we need to do in there, so this works fine. | |||
*/ | |||
@@ -674,7 +661,7 @@ void Window::PrivateData::onPuglConfigure(const double width, const double heigh | |||
void Window::PrivateData::onPuglExpose() | |||
{ | |||
DGL_DBGp("PUGL: onPuglExpose : %p\n", topLevelWidget); | |||
DGL_DBGp("PUGL: onPuglExpose\n"); | |||
puglOnDisplayPrepare(view); | |||
@@ -152,11 +152,20 @@ START_NAMESPACE_DGL | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// expose backend enter | |||
void puglBackendEnter(PuglView* view) | |||
void puglBackendEnter(PuglView* const view) | |||
{ | |||
view->backend->enter(view, NULL); | |||
} | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// clear minimum size to 0 | |||
void puglClearMinSize(PuglView* const view) | |||
{ | |||
view->minWidth = 0; | |||
view->minHeight = 0; | |||
} | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// missing in pugl, directly returns title char* pointer | |||
@@ -237,10 +246,13 @@ PuglStatus puglSetGeometryConstraints(PuglView* const view, const uint width, co | |||
} | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// set window size without changing frame x/y position | |||
// set window size with default size and without changing frame x/y position | |||
PuglStatus puglSetWindowSize(PuglView* const view, const uint width, const uint height) | |||
{ | |||
view->defaultWidth = width; | |||
view->defaultHeight = height; | |||
#if defined(DISTRHO_OS_HAIKU) || defined(DISTRHO_OS_MAC) | |||
// keep upstream behaviour | |||
const PuglRect frame = { view->frame.x, view->frame.y, (double)width, (double)height }; | |||
@@ -271,8 +283,30 @@ PuglStatus puglSetWindowSize(PuglView* const view, const uint width, const uint | |||
// matches upstream pugl, except we use XResizeWindow instead of XMoveResizeWindow | |||
if (view->impl->win) | |||
{ | |||
if (! XResizeWindow(view->world->impl->display, view->impl->win, width, height)) | |||
Display* const display = view->world->impl->display; | |||
if (! XResizeWindow(display, view->impl->win, width, height)) | |||
return PUGL_UNKNOWN_ERROR; | |||
#if 0 | |||
// custom handling for embed non-resizable windows | |||
if (view->parent != 0 && ! view->hints[PUGL_RESIZABLE]) | |||
{ | |||
XSizeHints sizeHints = {}; | |||
sizeHints.flags = PSize | PBaseSize | PMinSize | PMaxSize; | |||
sizeHints.width = static_cast<int>(width); | |||
sizeHints.height = static_cast<int>(height); | |||
sizeHints.base_width = width; | |||
sizeHints.base_height = height; | |||
sizeHints.min_width = width; | |||
sizeHints.min_height = height; | |||
sizeHints.max_width = width; | |||
sizeHints.max_height = height; | |||
XSetNormalHints(display, view->impl->win, &sizeHints); | |||
} | |||
#endif | |||
updateSizeHints(view); | |||
} | |||
#endif | |||
@@ -46,6 +46,10 @@ PUGL_BEGIN_DECLS | |||
PUGL_API void | |||
puglBackendEnter(PuglView* view); | |||
// clear minimum size to 0 | |||
PUGL_API void | |||
puglClearMinSize(PuglView* view); | |||
// missing in pugl, directly returns title char* pointer | |||
PUGL_API const char* | |||
puglGetWindowTitle(const PuglView* view); | |||
@@ -62,7 +66,7 @@ puglSetMatchingBackendForCurrentBuild(PuglView* view); | |||
PUGL_API PuglStatus | |||
puglSetGeometryConstraints(PuglView* view, unsigned int width, unsigned int height, bool aspect); | |||
// set window size without changing frame x/y position | |||
// set window size with default size and without changing frame x/y position | |||
PUGL_API PuglStatus | |||
puglSetWindowSize(PuglView* view, unsigned int width, unsigned int height); | |||
@@ -668,7 +668,7 @@ public: | |||
} | |||
else | |||
{ | |||
UIExporter tmpUI(nullptr, 0,fPlugin.getSampleRate(), | |||
UIExporter tmpUI(nullptr, 0, fPlugin.getSampleRate(), | |||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, | |||
fPlugin.getInstancePointer(), fLastScaleFactor); | |||
fVstRect.right = tmpUI.getWidth(); | |||
@@ -301,16 +301,7 @@ public: | |||
#else | |||
void setWindowTitle(const char* const uiTitle) | |||
{ | |||
// glWindow.setTitle(uiTitle); | |||
} | |||
void setWindowSize(const uint width, const uint height) | |||
{ | |||
DISTRHO_SAFE_ASSERT_RETURN(! changingSizeRecursionCheck,); | |||
changingSizeRecursionCheck = true; | |||
// glWindow.setSize(width, height); | |||
changingSizeRecursionCheck = false; | |||
uiData->window->setTitle(uiTitle); | |||
} | |||
void setWindowTransientWinId(const uintptr_t /*winId*/) | |||
@@ -322,10 +313,9 @@ public: | |||
bool setWindowVisible(const bool yesNo) | |||
{ | |||
// glWindow.setVisible(yesNo); | |||
uiData->window->setVisible(yesNo); | |||
// return ! glApp.isQuiting(); | |||
return true; | |||
return ! uiData->app.isQuiting(); | |||
} | |||
bool handlePluginKeyboard(const bool /*press*/, const uint /*key*/, const uint16_t /*mods*/) | |||