Workaround for wx bug causing layout problems in recovery dialog
authorMartin Steghöfer <martin@steghoefer.eu>
Wed, 6 Jun 2018 10:55:07 +0000 (11:55 +0100)
committerJames Cowgill <jcowgill@debian.org>
Wed, 6 Jun 2018 10:55:07 +0000 (11:55 +0100)
Forwarded: lllucius@gmail.com, 2014-10-20
Bug-Debian: http://bugs.debian.org/765341

Workaround for a bug in wxWidgets 3.0 that causes the Fit()
function to fail in certain desktop environments (gnome, xfce)
before the first window of the same style class is shown on
screen (http://trac.wxwidgets.org/ticket/16440). As a workaround,
call Fit() and other methods that depend on its results again
*after* we know that the window has been shown. While the bug
may affect other calls to Fit() on a low level, the workaround
is necessary only for the recovery dialog, which is particularly
vulnerable because:
1. It is shown very, very early in the program execution and
therefore very likely to be the first dialog of its style class
shown on screen.
2. It doesn't have scrollbars or flexible-size controls that
could compensate the wrong dialog size.

Gbp-Pq: Name 0002-workaround-wxwidgets-fit-recovery.patch

src/AutoRecovery.cpp

index 3c6589340a1e06725adfcdb4017362bb0d35b8ea..7b185e60ea98ee5c16a5e5f699e205dbd7983fdc 100644 (file)
@@ -46,6 +46,10 @@ class AutoRecoveryDialog final : public wxDialogWrapper
 public:
    AutoRecoveryDialog(wxWindow *parent);
 
+#if defined(__WXGTK__) && wxCHECK_VERSION(3, 0, 0)
+   void OnShow(wxShowEvent & event);
+#endif
+
 private:
    void PopulateList();
    void PopulateOrExchange(ShuttleGui & S);
@@ -74,6 +78,9 @@ BEGIN_EVENT_TABLE(AutoRecoveryDialog, wxDialogWrapper)
    EVT_BUTTON(ID_RECOVER_ALL, AutoRecoveryDialog::OnRecoverAll)
    EVT_BUTTON(ID_RECOVER_NONE, AutoRecoveryDialog::OnRecoverNone)
    EVT_BUTTON(ID_QUIT_AUDACITY, AutoRecoveryDialog::OnQuitAudacity)
+#if defined(__WXGTK__) && wxCHECK_VERSION(3, 0, 0)
+   EVT_SHOW(AutoRecoveryDialog::OnShow)
+#endif
 END_EVENT_TABLE()
 
 void AutoRecoveryDialog::PopulateOrExchange(ShuttleGui& S)
@@ -115,6 +122,22 @@ void AutoRecoveryDialog::PopulateOrExchange(ShuttleGui& S)
    Center();
 }
 
+#if defined(__WXGTK__) && wxCHECK_VERSION(3, 0, 0)
+void AutoRecoveryDialog::OnShow(wxShowEvent & event)
+{
+   // Workaround for wxWidgets bug #16440:
+   // http://trac.wxwidgets.org/ticket/16440
+   // Fit() doesn't work correctly in some desktop environments
+   // with GTK. But it does work after the first window of the
+   // same style class has been shown on screen. So re-execute
+   // Fit() and other methods that depend on its result AFTER
+   // we know that the window has been shown.
+   Fit();
+   SetMinSize(GetSize());
+   Center();
+}
+#endif
+
 void AutoRecoveryDialog::PopulateList()
 {
    mFileList->DeleteAllItems();