Optimize MSW wxNotebook background painting

MSWDefWindowProc(WM_PAINT, ...) in OnPaint causes performance issues on
large screens so only use it when an actual custom background colour is
set.

Closes #22308.

Closes #22320.
This commit is contained in:
Maarten Bent 2022-04-17 00:42:27 +02:00 committed by Vadim Zeitlin
parent 7d31e055c4
commit 4a3098aebb
2 changed files with 24 additions and 15 deletions

View File

@ -122,17 +122,9 @@ public:
// implementation only
// -------------------
virtual bool SetBackgroundColour(const wxColour& colour) wxOVERRIDE;
#if wxUSE_UXTHEME
virtual bool SetBackgroundColour(const wxColour& colour) wxOVERRIDE
{
if ( !wxNotebookBase::SetBackgroundColour(colour) )
return false;
UpdateBgBrush();
return true;
}
// draw child background
virtual bool MSWPrintChild(WXHDC hDC, wxWindow *win) wxOVERRIDE;

View File

@ -109,11 +109,6 @@ static bool HasTroubleWithNonTopTabs()
wxBEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase)
EVT_SIZE(wxNotebook::OnSize)
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
#if USE_NOTEBOOK_ANTIFLICKER
EVT_ERASE_BACKGROUND(wxNotebook::OnEraseBackground)
EVT_PAINT(wxNotebook::OnPaint)
#endif // USE_NOTEBOOK_ANTIFLICKER
wxEND_EVENT_TABLE()
// ============================================================================
@ -1081,6 +1076,28 @@ void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
}
}
bool wxNotebook::SetBackgroundColour(const wxColour& colour)
{
if ( !wxNotebookBase::SetBackgroundColour(colour) )
return false;
#if wxUSE_UXTHEME
UpdateBgBrush();
#endif // wxUSE_UXTHEME
#if USE_NOTEBOOK_ANTIFLICKER
Unbind(wxEVT_ERASE_BACKGROUND, &wxNotebook::OnEraseBackground, this);
Unbind(wxEVT_PAINT, &wxNotebook::OnPaint, this);
if ( m_hasBgCol || !wxUxThemeIsActive() )
{
Bind(wxEVT_ERASE_BACKGROUND, &wxNotebook::OnEraseBackground, this);
Bind(wxEVT_PAINT, &wxNotebook::OnPaint, this);
}
#endif // USE_NOTEBOOK_ANTIFLICKER
return true;
}
#if wxUSE_UXTHEME
WXHBRUSH wxNotebook::QueryBgBitmap()