Skip to content

Commit

Permalink
Set minimum size limits through WM_GETMINMAXINFO
Browse files Browse the repository at this point in the history
  • Loading branch information
Aemony committed May 17, 2024
1 parent a714e3d commit 29a97ec
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/imgui/imgui_impl_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,7 @@ static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd,
extern ImVec2 SKIF_vecHorizonModeDefault; // Does not include the status bar
extern ImVec2 SKIF_vecHorizonModeAdjusted; // Adjusted for status bar and tooltips
extern ImVec2 SKIF_vecServiceModeDefault;
extern ImVec2 SKIF_vecServiceMode;
extern ImVec2 SKIF_vecCurrentMode;
extern ImVec2 SKIF_vecCurrentModeNext;
extern HWND SKIF_Notify_hWnd;
Expand Down Expand Up @@ -1809,14 +1810,19 @@ static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd,

#endif

//#define SKIF_Win32_CenterMaximize
#ifdef SKIF_Win32_CenterMaximize

// This is used to inform Windows of the min/max size of the viewport, so
// that features such as Aero Snap takes the enforced size into account
case WM_GETMINMAXINFO:
{
MINMAXINFO* mmi = reinterpret_cast<MINMAXINFO*>(lParam);

// The minimum tracking size is the smallest window size that can be produced by using the borders to size the window.
// For SKIF that's the service/mini mode size.
mmi->ptMinTrackSize.x = static_cast<long> (SKIF_vecServiceMode.x);
mmi->ptMinTrackSize.y = static_cast<long> (SKIF_vecServiceMode.y);

//#define SKIF_Win32_CenterMaximize
#ifdef SKIF_Win32_CenterMaximize
static POINT sizeMin, sizeMax, pos;

// For systems with multiple monitors, the ptMaxSize and ptMaxPosition members describe the maximized size and position of the window on the primary monitor,
Expand Down Expand Up @@ -1845,12 +1851,11 @@ static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd,
mmi->ptMinTrackSize = sizeMax; // Minimum tracking size
mmi->ptMaxTrackSize = sizeMax; // Maximum tracking size

return 0;
#endif
//return 0; // We don't return 0 to allow DefWindowProc() the opportunity to also process the message
break;
}

#endif

case WM_DPICHANGED:
{
int g_dpi = HIWORD (wParam);
Expand Down

0 comments on commit 29a97ec

Please sign in to comment.