Allow using non-live resize in wxAUI with wxGTK3/X11

In this case we can still use wxClientDC, so let people do it if they
really want to for consistency with wxSplitterWindow and because it
doesn't really cost us anything.
This commit is contained in:
Vadim Zeitlin 2023-12-26 19:26:42 +01:00
parent fffe7f7170
commit 3e32e0fa67
3 changed files with 22 additions and 26 deletions

View file

@ -417,7 +417,7 @@ public:
void SetFlags(unsigned int flags);
unsigned int GetFlags() const;
static bool AlwaysUsesLiveResize();
static bool AlwaysUsesLiveResize(const wxWindow* window = nullptr);
bool HasLiveResize() const;
void SetManagedWindow(wxWindow* managedWnd);

View file

@ -219,12 +219,16 @@ public:
If this function returns true, ::wxAUI_MGR_LIVE_RESIZE flag is ignored
and live resize is always used, whether it's specified or not.
Currently this is the case for wxOSX and wxGTK3 ports, as live resizing
is the only implemented method there.
Currently this is the case for wxOSX and wxGTK3 when using Wayland, as
live resizing is the only implemented method there. See
wxClientDC::CanBeUsedForDrawing() for more details.
@param window The associated window, may be null (this parameter was
added in wxWidgets 3.3.0)
@since 3.1.4
*/
static bool AlwaysUsesLiveResize();
static bool AlwaysUsesLiveResize(const wxWindow* window);
/**
This function is used by controls to calculate the drop hint rectangle.

View file

@ -767,26 +767,17 @@ unsigned int wxAuiManager::GetFlags() const
return m_flags;
}
// With Core Graphics on Mac or GTK 3, it's not possible to show sash feedback,
// so we'll always use live update instead.
#if defined(__WXMAC__) || defined(__WXGTK3__)
#define wxUSE_AUI_LIVE_RESIZE_ALWAYS 1
#else
#define wxUSE_AUI_LIVE_RESIZE_ALWAYS 0
#endif
/* static */ bool wxAuiManager::AlwaysUsesLiveResize()
/* static */ bool wxAuiManager::AlwaysUsesLiveResize(const wxWindow* window)
{
return wxUSE_AUI_LIVE_RESIZE_ALWAYS;
// Not using live resize relies on wxClientDC being usable for drawing, so
// we have to use live resize if it can't be used on the current platform.
return !wxClientDC::CanBeUsedForDrawing(window);
}
bool wxAuiManager::HasLiveResize() const
{
#if wxUSE_AUI_LIVE_RESIZE_ALWAYS
return true;
#else
return (GetFlags() & wxAUI_MGR_LIVE_RESIZE) == wxAUI_MGR_LIVE_RESIZE;
#endif
return AlwaysUsesLiveResize(m_frame) ||
(GetFlags() & wxAUI_MGR_LIVE_RESIZE) == wxAUI_MGR_LIVE_RESIZE;
}
// don't use these anymore as they are deprecated
@ -3925,15 +3916,16 @@ void wxAuiManager::Repaint(wxDC* dc)
// make a client dc
if (!dc)
{
#if wxUSE_AUI_LIVE_RESIZE_ALWAYS
// We can't use wxClientDC in these ports.
m_frame->Refresh() ;
m_frame->Update() ;
return ;
#else
if ( AlwaysUsesLiveResize(m_frame) )
{
// We can't use wxClientDC in these ports.
m_frame->Refresh() ;
m_frame->Update() ;
return ;
}
client_dc.reset(new wxClientDC(m_frame));
dc = client_dc.get();
#endif
}
int w, h;