Skip to content

Commit

Permalink
Fixed window too large when maximized.
Browse files Browse the repository at this point in the history
Signed-off-by: weisj <weisj@arcor.de>
  • Loading branch information
weisJ committed Jan 21, 2020
1 parent 43df377 commit 8dd459b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/jniplatform/cpp/JNIDecorations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,23 @@ LRESULT CALLBACK WindowWrapper::WindowProc(_In_ HWND hwnd, _In_ UINT uMsg, _In_
}
else if (uMsg == WM_GETMINMAXINFO)
{
HMONITOR hPrimaryMonitor = MonitorFromWindow(nullptr, MONITOR_DEFAULTTOPRIMARY);
HMONITOR hTargetMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

MONITORINFO primaryMonitorInfo{sizeof(MONITORINFO)};
MONITORINFO targetMonitorInfo{sizeof(MONITORINFO)};

GetMonitorInfo(hPrimaryMonitor, &primaryMonitorInfo);
GetMonitorInfo(hTargetMonitor, &targetMonitorInfo);

MINMAXINFO *min_max_info = reinterpret_cast<MINMAXINFO *>(lParam);
RECT max_rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &max_rect, 0);
min_max_info->ptMaxSize.x = max_rect.right - max_rect.left;
min_max_info->ptMaxSize.y = max_rect.bottom - max_rect.top;
min_max_info->ptMaxPosition.x = max_rect.left;
min_max_info->ptMaxPosition.y = max_rect.top;
RECT max_rect = primaryMonitorInfo.rcWork;
RECT target_rect = targetMonitorInfo.rcWork;
int indent = 2;
min_max_info->ptMaxSize.x = target_rect.right - target_rect.left - 2 * indent;
min_max_info->ptMaxSize.y = target_rect.bottom - target_rect.top - 2 + indent;
min_max_info->ptMaxPosition.x = max_rect.left + indent;
min_max_info->ptMaxPosition.y = max_rect.top + indent;
return 0;
}

Expand All @@ -132,7 +142,7 @@ Java_com_github_weisj_darklaf_platform_windows_JNIDecorations_setResizable(JNIEn

JNIEXPORT void JNICALL
Java_com_github_weisj_darklaf_platform_windows_JNIDecorations_updateValues(JNIEnv *env, jclass obj, jlong hwnd,
jint l, jint r, jint h)
jint l, jint r, jint h)
{
HWND handle = reinterpret_cast<HWND>(hwnd);
auto wrap = wrapper_map[handle];
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 8dd459b

Please sign in to comment.