From 66cb7089f8a258bb452f780b59e3be873830a7fa Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 20 Feb 2022 17:47:16 +0100 Subject: [PATCH] Add logging to wxGTK wxTopLevelWindow size-related functions This can be helpful when debugging size-related problems and doesn't do any harm as long as the corresponding tracing category is disabled. --- src/gtk/toplevel.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index f9eef429ef..13b1857c6b 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -50,6 +50,8 @@ #include #endif +#define TRACE_TLWSIZE "tlwsize" + // ---------------------------------------------------------------------------- // data // ---------------------------------------------------------------------------- @@ -271,6 +273,11 @@ size_allocate(GtkWidget*, GtkAllocation* alloc, wxTopLevelWindowGTK* win) if (win->m_clientWidth != alloc->width || win->m_clientHeight != alloc->height) { + wxLogTrace(TRACE_TLWSIZE, "Size changed for %s (%d, %d) -> (%d, %d)", + wxDumpWindow(win), + win->m_clientWidth, win->m_clientHeight, + alloc->width, alloc->height); + wxRecursionGuard setInSizeAllocate(g_inSizeAllocate); win->m_clientWidth = alloc->width; @@ -1293,6 +1300,9 @@ void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int si if (m_width != oldSize.x || m_height != oldSize.y) { + wxLogTrace(TRACE_TLWSIZE, "Size set for %s (%d, %d) -> (%d, %d)", + wxDumpWindow(this), oldSize.x, oldSize.y, m_width, m_height); + m_deferShowAllowed = true; m_useCachedClientSize = false; @@ -1341,6 +1351,9 @@ static gboolean reset_size_request(void* data) void wxTopLevelWindowGTK::DoSetClientSize(int width, int height) { + wxLogTrace(TRACE_TLWSIZE, "Client size set for %s: (%d, %d)", + wxDumpWindow(this), width, height); + base_type::DoSetClientSize(width, height); // Since client size is being explicitly set, don't change it later @@ -1399,6 +1412,9 @@ void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH, int maxW, int maxH, int incW, int incH ) { + wxLogTrace(TRACE_TLWSIZE, "Size hints for %s set to (%d, %d)", + wxDumpWindow(this), minW, minH); + base_type::DoSetSizeHints(minW, minH, maxW, maxH, incW, incH); if (!HasFlag(wxRESIZE_BORDER)) @@ -1589,6 +1605,9 @@ void wxTopLevelWindowGTK::GTKDoAfterShow() void wxTopLevelWindowGTK::GTKUpdateClientSizeIfNecessary() { + wxLogTrace(TRACE_TLWSIZE, "GTKUpdateClientSizeIfNecessary() for %s, pending=%d", + wxDumpWindow(this), m_pendingFittingClientSizeFlags); + if ( m_pendingFittingClientSizeFlags ) { WXSetInitialFittingClientSize(m_pendingFittingClientSizeFlags); @@ -1599,6 +1618,8 @@ void wxTopLevelWindowGTK::GTKUpdateClientSizeIfNecessary() void wxTopLevelWindowGTK::SetMinSize(const wxSize& minSize) { + wxLogTrace(TRACE_TLWSIZE, "SetMinSize() for %s", wxDumpWindow(this)); + wxTopLevelWindowBase::SetMinSize(minSize); // Explicitly set minimum size should override the pending size, if any. @@ -1608,6 +1629,9 @@ void wxTopLevelWindowGTK::SetMinSize(const wxSize& minSize) void wxTopLevelWindowGTK::WXSetInitialFittingClientSize(int flags, wxSizer* sizer) { + wxLogTrace(TRACE_TLWSIZE, "WXSetInitialFittingClientSize(%d) for %s (%s)", + flags, wxDumpWindow(this), IsShown() ? "shown" : "hidden"); + // In any case, update the size immediately. wxTopLevelWindowBase::WXSetInitialFittingClientSize(flags, sizer);