| 299 | // Combined puglSetSizeHint using PUGL_MIN_SIZE and PUGL_FIXED_ASPECT |
| 300 | |
| 301 | PuglStatus puglSetGeometryConstraints(PuglView* const view, const uint width, const uint height, const bool aspect) |
| 302 | { |
| 303 | view->sizeHints[PUGL_MIN_SIZE].width = static_cast<PuglSpan>(width); |
| 304 | view->sizeHints[PUGL_MIN_SIZE].height = static_cast<PuglSpan>(height); |
| 305 | |
| 306 | if (aspect) |
| 307 | { |
| 308 | view->sizeHints[PUGL_FIXED_ASPECT].width = static_cast<PuglSpan>(width); |
| 309 | view->sizeHints[PUGL_FIXED_ASPECT].height = static_cast<PuglSpan>(height); |
| 310 | } |
| 311 | |
| 312 | #if defined(DISTRHO_OS_HAIKU) |
| 313 | #elif defined(DISTRHO_OS_MAC) |
| 314 | if (view->impl->window) |
| 315 | { |
| 316 | if (const PuglStatus status = puglUpdateSizeHints(view)) |
| 317 | return status; |
| 318 | } |
| 319 | #elif defined(DISTRHO_OS_WASM) |
| 320 | const char* const className = view->world->strings[PUGL_CLASS_NAME]; |
| 321 | EM_ASM({ |
| 322 | var canvasWrapper = document.getElementById(UTF8ToString($0)).parentElement; |
| 323 | canvasWrapper.style.setProperty("min-width", parseInt($1 / window.devicePixelRatio) + 'px'); |
| 324 | canvasWrapper.style.setProperty("min-height", parseInt($2 / window.devicePixelRatio) + 'px'); |
| 325 | }, className, width, height); |
| 326 | #elif defined(DISTRHO_OS_WINDOWS) |
| 327 | // nothing |
| 328 | #elif defined(HAVE_X11) |
| 329 | if (view->impl->win) |
| 330 | { |
| 331 | if (const PuglStatus status = puglUpdateSizeHints(view)) |
| 332 | return status; |
| 333 | |
| 334 | XFlush(view->world->impl->display); |
| 335 | } |
| 336 | #endif |
| 337 | |
| 338 | return PUGL_SUCCESS; |
| 339 | } |
| 340 | |
| 341 | // -------------------------------------------------------------------------------------------------------------------- |
| 342 | // set view as resizable (or not) during runtime |
no test coverage detected