[AlwaysOnTop] Release/recreate borders instead of hiding/showing (#15733)

This commit is contained in:
Seraphima Zykova
2022-01-26 09:54:54 +03:00
committed by GitHub
parent 941ff0a5a6
commit a1bb281386
5 changed files with 83 additions and 66 deletions

View File

@@ -61,6 +61,17 @@ WindowBorder::~WindowBorder()
}
}
std::unique_ptr<WindowBorder> WindowBorder::Create(HWND window, HINSTANCE hinstance)
{
auto self = std::unique_ptr<WindowBorder>(new WindowBorder(window));
if (self->Init(hinstance))
{
return self;
}
return nullptr;
}
bool WindowBorder::Init(HINSTANCE hinstance)
{
if (!m_trackingWindow)
@@ -118,7 +129,14 @@ bool WindowBorder::Init(HINSTANCE hinstance)
, SWP_NOMOVE | SWP_NOSIZE);
m_frameDrawer = FrameDrawer::Create(m_window);
return m_frameDrawer != nullptr;
if (!m_frameDrawer)
{
return false;
}
UpdateBorderProperties();
m_frameDrawer->Show();
return true;
}
void WindowBorder::UpdateBorderPosition() const
@@ -131,6 +149,7 @@ void WindowBorder::UpdateBorderPosition() const
auto rectOpt = GetFrameRect(m_trackingWindow);
if (!rectOpt.has_value())
{
m_frameDrawer->Hide();
return;
}
@@ -169,17 +188,6 @@ void WindowBorder::UpdateBorderProperties() const
m_frameDrawer->SetBorderRect(frameRect, color, AlwaysOnTopSettings::settings().frameThickness);
}
void WindowBorder::Show() const
{
UpdateBorderProperties();
m_frameDrawer->Show();
}
void WindowBorder::Hide() const
{
m_frameDrawer->Hide();
}
LRESULT WindowBorder::WndProc(UINT message, WPARAM wparam, LPARAM lparam) noexcept
{
switch (message)