Blame 4Pane-4.0-gtk320-sizing.patch

27f0a6
diff --git a/MyFiles.cpp b/MyFiles.cpp
27f0a6
index fdd6b50..fa088eb 100644
27f0a6
--- a/MyFiles.cpp
27f0a6
+++ b/MyFiles.cpp
27f0a6
@@ -249,6 +249,7 @@ CreateAcceleratorTable();                                   // Make a new one, w
27f0a6
 void FileGenericDirCtrl::DoSize()
27f0a6
 {
27f0a6
 int w, h; GetClientSize(&w, &h);
27f0a6
+if (w==0 || h==0) return; // Not yet ready for sizing
27f0a6
 
27f0a6
 GetTreeCtrl()->SetSize(0, HEADER_HEIGHT + 1, w, h - HEADER_HEIGHT - 1);  // Set the treectrl 'body' size
27f0a6
 headerwindow->SetSize(0, 0, w, HEADER_HEIGHT);              // Set the header-window size
27f0a6
diff --git a/MyFrame.cpp b/MyFrame.cpp
27f0a6
index 889feb4..074572c 100644
27f0a6
--- a/MyFrame.cpp
27f0a6
+++ b/MyFrame.cpp
27f0a6
@@ -619,6 +619,15 @@ Connect(wxID_ANY, PasteThreadType, PasteThreadEventHandler(MyFrame::OnPasteThrea
27f0a6
 #if defined __WXX11__
27f0a6
 Connect(wxEVT_IDLE, (wxObjectEventFunction)&MyFrame::OnIdle);
27f0a6
 #endif
27f0a6
+
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  // Workarounds for display glitches with gtk+3.20
27f0a6
+  m_resizetimer.SetOwner(this, 10000);
27f0a6
+  Connect(10000, wxEVT_TIMER, wxTimerEventHandler(MyFrame::OnResizeTimer), NULL, this);
27f0a6
+  m_resizetimer.Start(10);
27f0a6
+
27f0a6
+  Layout->m_notebook->StartTimer();
27f0a6
+#endif
27f0a6
 }
27f0a6
 
27f0a6
 #ifdef __WXX11__
27f0a6
@@ -631,6 +640,21 @@ Disconnect(wxID_ANY);
27f0a6
 }
27f0a6
 #endif
27f0a6
 
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+void MyFrame::OnResizeTimer(wxTimerEvent& WXUNUSED(event))
27f0a6
+{
27f0a6
+int x, y; GetSize(&x,&y);
27f0a6
+if (y > 50)
27f0a6
+  { static int count(0);
27f0a6
+    if (++count < 10) return;
27f0a6
+    if (count % 2)   SetSize(x-1, y);
27f0a6
+     else  SetSize(x+1, y);
27f0a6
+     
27f0a6
+    if (count > 11 && !(count % 2))  m_resizetimer.Stop();
27f0a6
+  }
27f0a6
+}
27f0a6
+#endif
27f0a6
+
27f0a6
 MyFrame::~MyFrame()
27f0a6
 {
27f0a6
 m_DragMutex.Unlock();
27f0a6
@@ -1850,6 +1874,10 @@ MyTab* tab = GetActiveTab();
27f0a6
 if (tab == NULL)   return;
27f0a6
 
27f0a6
 tab->PerformSplit(horizontal);
27f0a6
+
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  m_resizetimer.Start(10);
27f0a6
+#endif
27f0a6
 }
27f0a6
 
27f0a6
 void MyFrame::SplitVertical(wxCommandEvent& WXUNUSED(event))
27f0a6
@@ -1858,6 +1886,10 @@ MyTab* tab = GetActiveTab();
27f0a6
 if (tab == NULL)   return;
27f0a6
 
27f0a6
 tab->PerformSplit(vertical);
27f0a6
+
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  m_resizetimer.Start(10);
27f0a6
+#endif
27f0a6
 }
27f0a6
 
27f0a6
 void MyFrame::Unsplit(wxCommandEvent& WXUNUSED(event))
27f0a6
@@ -1866,11 +1898,19 @@ MyTab* tab = GetActiveTab();
27f0a6
 if (tab == NULL)   return;
27f0a6
 
27f0a6
 tab->PerformSplit(unsplit);
27f0a6
+
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  m_resizetimer.Start(10);
27f0a6
+#endif
27f0a6
 }
27f0a6
 
27f0a6
 void MyFrame::OnTabTemplateLoadMenu(wxCommandEvent& event)
27f0a6
 {
27f0a6
 Layout->m_notebook->LoadTemplate(event.GetId() - SHCUT_TABTEMPLATERANGE_START);
27f0a6
+
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  m_resizetimer.Start(10);
27f0a6
+#endif
27f0a6
 }
27f0a6
 
27f0a6
 void MyFrame::OnConfigureShortcuts(wxCommandEvent& WXUNUSED(event))
27f0a6
@@ -2053,6 +2093,10 @@ void LayoutWindows::UnShowBottom()    // If bottompanel is visible, unsplit it
27f0a6
 if (!m_splitterMain->IsSplit()) return;               // Can't unsplit it if it's not split
27f0a6
 
27f0a6
 m_splitterMain->Unsplit(bottompanel);
27f0a6
+
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  m_frame->m_resizetimer.Start(10);
27f0a6
+#endif
27f0a6
 }
27f0a6
 
27f0a6
 void LayoutWindows::DoTool(enum toolchoice whichtool) // Invoke the requested tool in the bottom panel
27f0a6
diff --git a/MyFrame.h b/MyFrame.h
27f0a6
index a54d089..85e4ec0 100644
27f0a6
--- a/MyFrame.h
27f0a6
+++ b/MyFrame.h
27f0a6
@@ -458,6 +458,13 @@ void OnIdle( wxIdleEvent& event );    // One-off to make the toolbar textctrl sh
27f0a6
 void OnMouseCaptureLost(wxMouseCaptureLostEvent& event) {OnEndDrag((wxMouseEvent&)event); } // If the mouse escapes, try and do something sensible
27f0a6
 #endif
27f0a6
 
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  void OnResizeTimer(wxTimerEvent& event);
27f0a6
+  public:
27f0a6
+  wxTimer m_resizetimer;
27f0a6
+#endif
27f0a6
+
27f0a6
+protected:
27f0a6
 void OnTextFilepathEnter(wxCommandEvent& WXUNUSED(event)){ TextFilepathEnter(); }
27f0a6
 
27f0a6
 void DoMiscUI(wxUpdateUIEvent& event);         //  UpdateUI for misc items
27f0a6
diff --git a/MyNotebook.cpp b/MyNotebook.cpp
27f0a6
index b628627..71faa53 100644
27f0a6
--- a/MyNotebook.cpp
27f0a6
+++ b/MyNotebook.cpp
27f0a6
@@ -27,6 +27,13 @@
27f0a6
 #include "MyFiles.h"
27f0a6
 #include "MyNotebook.h"
27f0a6
 
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  void ResizeTimer::Notify()
27f0a6
+  {
27f0a6
+  if (m_nb)
27f0a6
+      m_nb->OnTimerResize(); 
27f0a6
+  }
27f0a6
+#endif
27f0a6
 
27f0a6
 MyNotebook::MyNotebook(wxSplitterWindow *main, wxWindowID id,  const wxPoint& pos, const wxSize& size, long style)
27f0a6
                                                                           :  wxNotebook((wxWindow*)main, id, pos, size, style)
27f0a6
@@ -48,6 +55,10 @@ UnRedoManager::frame = MyFrame::mainframe;     // Tell UnRedoManager's (static)
27f0a6
 
27f0a6
 DeviceMan = new DeviceAndMountManager;         // Organises things to do with mounting partitions & devices
27f0a6
 LaunchFromMenu = new LaunchMiscTools;          // Launches user-defined external programs & scripts from the Tools menu
27f0a6
+
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  m_timer = new ResizeTimer(this);
27f0a6
+#endif
27f0a6
 }
27f0a6
 
27f0a6
 MyNotebook::~MyNotebook()
27f0a6
@@ -61,6 +72,10 @@ delete DeleteLocation;
27f0a6
 delete BookmarkMan;
27f0a6
 }
27f0a6
 
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  void MyNotebook::StartTimer() { if ( m_timer) m_timer->StartOnce(50); }
27f0a6
+#endif
27f0a6
+
27f0a6
 void MyNotebook::LoadTabs(int TemplateNo /*=-1*/, const wxString& startdir0 /*=""*/, const wxString& startdir1 /*=""*/)  // Load the default tabs, or if TemplateNo > -1, load that tab template
27f0a6
 {
27f0a6
 wxConfigBase* config = wxConfigBase::Get(); if (config==NULL)  return;
27f0a6
@@ -123,6 +138,10 @@ for (tab=0; tab < GetPageCount(); ++tab)            // We can now safely unhide
27f0a6
 
27f0a6
 MyFrame::mainframe->GetMenuBar()->Check(SHCUT_SAVETABS_ONEXIT, saveonexit);  // Set the menu item check according to bool
27f0a6
 DoLoadTemplateMenu();               // Get the correct no of loadable templates listed on the menu
27f0a6
+
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  StartTimer();
27f0a6
+#endif
27f0a6
 }
27f0a6
 
27f0a6
 void MyNotebook::DoLoadTemplateMenu()    // Get the correct no of loadable templates listed on the menu
27f0a6
@@ -298,8 +317,13 @@ if (after == -1)                                      // -1 flags to append, not
27f0a6
    { if (InsertPage(after, page, pageName, true))  ++nextpageno;
27f0a6
        else return;                                   // If page couldn't be created, bug out
27f0a6
   }
27f0a6
+
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  StartTimer();
27f0a6
+#endif
27f0a6
 }
27f0a6
 
27f0a6
+
27f0a6
 void MyNotebook::AppendTab()
27f0a6
 {
27f0a6
 CreateTab(GetPageCount());                          // By passing GetPageCount(), the correct tabdata should be used
27f0a6
@@ -359,8 +383,18 @@ if (InsertPage(page + 1, duppage, pageName, true))
27f0a6
 #if defined (__WXGTK__)
27f0a6
   ShowTabs(true);                                   // Show the tab heads now, as by definition there must be >1 tab
27f0a6
 #endif
27f0a6
+
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  StartTimer();
27f0a6
+#endif
27f0a6
 }
27f0a6
 
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  void MyNotebook::OnTimerResize()
27f0a6
+  {
27f0a6
+   int x, y; GetSize(&x,&y);  SetSize(x-1, y-1); wxSafeYield(); SetSize(x, y);
27f0a6
+  }
27f0a6
+#endif
27f0a6
 
27f0a6
 void MyNotebook::OnSelChange(wxNotebookEvent& event)
27f0a6
 {
27f0a6
diff --git a/MyNotebook.h b/MyNotebook.h
27f0a6
index 8fc36db..0287530 100644
27f0a6
--- a/MyNotebook.h
27f0a6
+++ b/MyNotebook.h
27f0a6
@@ -17,6 +17,23 @@ class DeviceAndMountManager;
27f0a6
 class Bookmarks;
27f0a6
 class LaunchMiscTools;
27f0a6
 
27f0a6
+#if defined __WXGTK__
27f0a6
+  #include <gtk/gtk.h>
27f0a6
+#endif
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  class MyNotebook;
27f0a6
+    
27f0a6
+  class ResizeTimer  :   public wxTimer
27f0a6
+    {
27f0a6
+    public:
27f0a6
+    ResizeTimer(MyNotebook* nb) : wxTimer(), m_nb(nb) {}
27f0a6
+    void Notify();
27f0a6
+
27f0a6
+    protected:
27f0a6
+    MyNotebook* m_nb;
27f0a6
+    };
27f0a6
+#endif
27f0a6
+
27f0a6
 class MyNotebook : public wxNotebook
27f0a6
 {
27f0a6
 public:
27f0a6
@@ -38,11 +55,19 @@ void OnAdvanceSelection(wxCommandEvent& event){AdvanceSelection(event.GetId() ==
27f0a6
   void OnSameTabSize(wxCommandEvent& event){ EqualSizedTabs = ! EqualSizedTabs; EqualWidthTabs(EqualSizedTabs); }
27f0a6
 #endif
27f0a6
 
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  void OnTimerResize();
27f0a6
+#endif
27f0a6
+
27f0a6
 void LoadTemplate(int TemplateNo);    // Triggered by a menu event, loads the selected tab template
27f0a6
 void SaveDefaults(int TemplateNo = -1, const wxString& title = wxT(""));// Save current tab setup.  If TemplateNo > -1 save as a template; otherwise just do a 'normal' save
27f0a6
 void SaveAsTemplate();                // Save the current tab setup as a template
27f0a6
 void DeleteTemplate();                // Delete an existing template
27f0a6
 
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+    void StartTimer();
27f0a6
+#endif
27f0a6
+
27f0a6
 DirectoryForDeletions* DeleteLocation; // Organises unique dirnames for deleted/trashed files
27f0a6
 UnRedoManager* UnRedoMan;             // The sole instance of UnRedoManager
27f0a6
 DeviceAndMountManager* DeviceMan;     // Find where floppy, cds are
27f0a6
@@ -76,6 +101,9 @@ void RenameTab();
27f0a6
   void EqualWidthTabs(bool equal_tabs);
27f0a6
 #endif
27f0a6
 int nextpageno;
27f0a6
+#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,20,0)
27f0a6
+  ResizeTimer* m_timer;
27f0a6
+#endif
27f0a6
 private:
27f0a6
 DECLARE_EVENT_TABLE()
27f0a6
 };