diff options
| author | Rene Lindsay <rene@lunarg.com> | 2016-07-05 13:26:05 -0600 |
|---|---|---|
| committer | Rene Lindsay <rene@lunarg.com> | 2016-07-05 14:11:05 -0600 |
| commit | 814530ce0b0de10f3ceb8a0e55e1995a067f94c7 (patch) | |
| tree | 7dd16bcddfaf20b97f33f73bb6b05900dde1393d | |
| parent | b9403da30ac3ceb5cd9111b4af5dab41215815b8 (diff) | |
| download | usermoji-814530ce0b0de10f3ceb8a0e55e1995a067f94c7.tar.xz | |
demos: Set window minimum size for tri.c
| -rw-r--r-- | demos/tri.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/demos/tri.c b/demos/tri.c index 91c76ab9..95153236 100644 --- a/demos/tri.c +++ b/demos/tri.c @@ -152,6 +152,7 @@ struct demo { HINSTANCE connection; // hInstance - Windows Instance char name[APP_NAME_STR_LEN]; // Name to put on the window/icon HWND window; // hWnd - window handle + POINT minsize; // minimum window size #elif defined(VK_USE_PLATFORM_XCB_KHR) xcb_connection_t *connection; xcb_screen_t *screen; @@ -1618,6 +1619,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { demo_run(&demo); break; } + case WM_GETMINMAXINFO: // set window's minimum size + ((MINMAXINFO*)lParam)->ptMinTrackSize = demo.minsize; + return 0; case WM_SIZE: // Resize the application to the new window size, except when // it was minimized. Vulkan doesn't support images or swapchains @@ -1625,6 +1629,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (wParam != SIZE_MINIMIZED) { demo.width = lParam & 0xffff; demo.height = lParam & 0xffff0000 >> 16; + + if (demo.height < 64) demo.height = 64; + demo_resize(&demo); } break; @@ -1678,6 +1685,9 @@ static void demo_create_window(struct demo *demo) { fflush(stdout); exit(1); } + // Window client area size must be at least 1 pixel high, to prevent crash. + demo->minsize.x = GetSystemMetrics(SM_CXMINTRACK); + demo->minsize.y = GetSystemMetrics(SM_CYMINTRACK) + 1; } #elif defined(VK_USE_PLATFORM_XCB_KHR) static void demo_handle_event(struct demo *demo, |
