FIX: [STUDIO-2702] fix maximize size offset, ad7bda2

Change-Id: I4f65ef25dc4241bf7c1c3d15c38198ea2b40b337
This commit is contained in:
chunmao.guo 2023-05-18 20:23:49 +08:00 committed by Lane.Wei
parent 9352f34ad0
commit c770926142
2 changed files with 21 additions and 14 deletions

View file

@ -505,7 +505,13 @@ void BBLTopbar::OnFullScreen(wxAuiToolBarEvent& event)
else {
wxDisplay display(this);
auto size = display.GetClientArea().GetSize();
m_frame->SetMaxSize(size + wxSize{16, 16});
#ifdef __WXMSW__
HWND hWnd = m_frame->GetHandle();
RECT borderThickness;
SetRectEmpty(&borderThickness);
AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, 0);
m_frame->SetMaxSize(size + wxSize{-borderThickness.left + borderThickness.right, -borderThickness.top + borderThickness.bottom});
#endif // __WXMSW__
m_normalRect = m_frame->GetRect();
m_frame->Maximize();
}
@ -530,16 +536,8 @@ void BBLTopbar::OnMouseLeftDClock(wxMouseEvent& mouse)
return;
#endif // __WXMSW__
if (m_frame->IsMaximized()) {
m_frame->Restore();
}
else {
wxDisplay display(this);
auto size = display.GetClientArea().GetSize();
m_frame->SetMaxSize(size + wxSize{16, 16});
m_normalRect = m_frame->GetRect();
m_frame->Maximize();
}
wxAuiToolBarEvent evt;
OnFullScreen(evt);
}
void BBLTopbar::OnFileToolItem(wxAuiToolBarEvent& evt)

View file

@ -384,18 +384,27 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
auto setMaxSize = [this]() {
wxDisplay display(this);
auto size = display.GetClientArea().GetSize();
// 8 pixels shadow
SetMaxSize(size + wxSize{16, 16});
HWND hWnd = GetHandle();
RECT borderThickness;
SetRectEmpty(&borderThickness);
AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, 0);
SetMaxSize(size + wxSize{-borderThickness.left + borderThickness.right, -borderThickness.top + borderThickness.bottom});
};
this->Bind(wxEVT_DPI_CHANGED, [setMaxSize](auto & e) {
setMaxSize();
e.Skip();
});
setMaxSize();
// SetMaximize already position window at left/top corner, even if Windows Task Bar is at left side.
// Not known why, but fix it here
this->Bind(wxEVT_MAXIMIZE, [this](auto &e) {
wxDisplay display(this);
auto pos = display.GetClientArea().GetPosition();
Move(pos - wxPoint{8, 8});
HWND hWnd = GetHandle();
RECT borderThickness;
SetRectEmpty(&borderThickness);
AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, 0);
Move(pos + wxPoint{borderThickness.left, borderThickness.top});
e.Skip();
});
#endif // WIN32