Skip to content

Commit fbc170d

Browse files
committed
GPU Display: Add minimum window size
1 parent 54e5713 commit fbc170d

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontend.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface
8383
void waitForFPSLimit(); // Sleep until the next frame is due according to fpsRate (no sleep with maxFPSRate or fpsRate <= 0)
8484

8585
static constexpr int32_t INIT_WIDTH = 1024, INIT_HEIGHT = 768; // Initial window size, before maximizing
86+
static constexpr int32_t MIN_WIDTH = 200, MIN_HEIGHT = 150; // Minimum window size
8687
static constexpr const char* DISPLAY_WINDOW_NAME = "GPU CA Standalone Event Display"; // Title of event display set by backend
8788
// Constant key codes for special mKeys (to unify different treatment in X11 / Windows / GLUT / etc.)
8889
static constexpr int32_t KEY_UP = 1;

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.cxx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ int32_t GPUDisplayFrontendGlfw::FrontendMain()
291291
glfwSetWindowSizeCallback(mWindow, resize_callback);
292292
glfwSetWindowMaximizeCallback(mWindow, maximize_callback);
293293
glfwSetWindowFocusCallback(mWindow, focus_callback);
294+
glfwSetWindowSizeLimits(mWindow, MIN_WIDTH, MIN_HEIGHT, GLFW_DONT_CARE, GLFW_DONT_CARE);
294295
applyInitialWindowState();
295296
if (backend()->backendType() == GPUDisplayBackend::TYPE_OPENGL) {
296297
glfwSwapInterval(1);

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.cxx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,9 @@ int32_t GPUDisplayFrontendWayland::FrontendMain()
510510
xdg_toplevel_add_listener(mXdgToplevel, &mXdgToplevelListener, this);
511511

512512
xdg_toplevel_set_title(mXdgToplevel, DISPLAY_WINDOW_NAME);
513-
xdg_toplevel_set_app_id(mXdgToplevel, "o2-gpu-event-display"); // Used by the compositor for window grouping, window rules, and matching a .desktop file
514-
applyInitialWindowState(); // Must be requested before the first commit
513+
xdg_toplevel_set_min_size(mXdgToplevel, MIN_WIDTH, MIN_HEIGHT); // Logical size, avoids degenerate swapchains / projections
514+
xdg_toplevel_set_app_id(mXdgToplevel, "o2-gpu-event-display"); // Used by the compositor for window grouping, window rules, and matching a .desktop file
515+
applyInitialWindowState(); // Must be requested before the first commit
515516

516517
if (mDecManager) { // Must be requested before the first commit. Without the protocol (e.g. GNOME), the window has no decorations
517518
mXdgDecoration = zxdg_decoration_manager_v1_get_toplevel_decoration(mDecManager, mXdgToplevel);

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.cxx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ int32_t GPUDisplayFrontendX11::FrontendMain()
267267
mWindow = XCreateWindow(mXDisplay, win, 50, 50, INIT_WIDTH, INIT_HEIGHT, // Position / Width and height of window
268268
0, visualInfo->depth, InputOutput, visualInfo->visual, CWBorderPixel | CWColormap | CWEventMask, &windowAttributes);
269269
XSetStandardProperties(mXDisplay, mWindow, DISPLAY_WINDOW_NAME, DISPLAY_WINDOW_NAME, None, nullptr, 0, nullptr);
270+
XSizeHints sizeHints{};
271+
sizeHints.flags = PMinSize;
272+
sizeHints.min_width = MIN_WIDTH;
273+
sizeHints.min_height = MIN_HEIGHT;
274+
XSetWMNormalHints(mXDisplay, mWindow, &sizeHints);
270275
if (backend()->backendType() == GPUDisplayBackend::TYPE_OPENGL) {
271276
glXMakeCurrent(mXDisplay, mWindow, glxContext);
272277
}

0 commit comments

Comments
 (0)