GHOST/Wayland: set the minimum window size with libdecor

This commit is contained in:
Campbell Barton 2022-06-27 16:09:23 +10:00
parent 0e88c2fc59
commit 2b6c633b63
1 changed files with 9 additions and 7 deletions

View File

@ -406,27 +406,29 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system,
w->egl_window = wl_egl_window_create(w->wl_surface, int(w->size[0]), int(w->size[1]));
/* NOTE: The limit is in points (not pixels) so Hi-DPI will limit to larger number of pixels.
* This has the advantage that the size limit is the same when moving the window between monitors
* with different scales set. If it was important to limit in pixels it could be re-calculated
* when the `w->scale` changed. */
const int32_t size_min[2] = {320, 240};
#ifdef WITH_GHOST_WAYLAND_LIBDECOR
/* create window decorations */
w->decor_frame = libdecor_decorate(
m_system->decor_context(), w->wl_surface, &libdecor_frame_iface, w);
libdecor_frame_map(w->decor_frame);
libdecor_frame_set_min_content_size(w->decor_frame, size_min[0], size_min[1]);
if (parentWindow) {
libdecor_frame_set_parent(
w->decor_frame, dynamic_cast<const GHOST_WindowWayland *>(parentWindow)->w->decor_frame);
}
#else
w->xdg_surface = xdg_wm_base_get_xdg_surface(m_system->xdg_shell(), w->wl_surface);
w->xdg_toplevel = xdg_surface_get_toplevel(w->xdg_surface);
/* NOTE: The limit is in points (not pixels) so Hi-DPI will limit to larger number of pixels.
* This has the advantage that the size limit is the same when moving the window between monitors
* with different scales set. If it was important to limit in pixels it could be re-calculated
* when the `w->scale` changed. */
xdg_toplevel_set_min_size(w->xdg_toplevel, 320, 240);
xdg_toplevel_set_min_size(w->xdg_toplevel, size_min[0], size_min[1]);
if (m_system->xdg_decoration_manager()) {
w->xdg_toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(