]> git.saurik.com Git - wxWidgets.git/blobdiff - src/x11/window.cpp
implement GetBestSize() (patch 1386199)
[wxWidgets.git] / src / x11 / window.cpp
index dcd3dffb8076c30458d9f1e260466bd11a607c7d..7515a925466b7dc3cb64ad68963ca5154d1df2e6 100644 (file)
     #include "wx/listbox.h"
     #include "wx/scrolwin.h"
     #include "wx/layout.h"
+    #include "wx/menuitem.h"
+    #include "wx/module.h"
 #endif
 
-#include "wx/module.h"
-#include "wx/menuitem.h"
 #include "wx/fontutil.h"
 #include "wx/univ/renderer.h"
 
@@ -357,10 +357,13 @@ wxWindowX11::~wxWindowX11()
     }
 
     // Destroy the window
-    Window xwindow = (Window) m_mainWindow;
-    wxDeleteWindowFromTable( xwindow );
-    XDestroyWindow( wxGlobalDisplay(), xwindow );
-    m_mainWindow = NULL;
+    if ( m_mainWindow )
+    {
+        Window xwindow = (Window) m_mainWindow;
+        wxDeleteWindowFromTable( xwindow );
+        XDestroyWindow( wxGlobalDisplay(), xwindow );
+        m_mainWindow = NULL;
+    }
 }
 
 // ---------------------------------------------------------------------------
@@ -802,9 +805,11 @@ void wxWindowX11::DoScreenToClient(int *x, int *y) const
     Window thisWindow = (Window) m_clientWindow;
 
     Window childWindow;
-    int xx = *x;
-    int yy = *y;
-    XTranslateCoordinates(display, rootWindow, thisWindow, xx, yy, x, y, &childWindow);
+    int xx = x ? *x : 0;
+    int yy = y ? *y : 0;
+    XTranslateCoordinates(display, rootWindow, thisWindow,
+                          xx, yy, x ? x : &xx, y ? y : &yy,
+                          &childWindow);
 }
 
 void wxWindowX11::DoClientToScreen(int *x, int *y) const
@@ -814,9 +819,11 @@ void wxWindowX11::DoClientToScreen(int *x, int *y) const
     Window thisWindow = (Window) m_clientWindow;
 
     Window childWindow;
-    int xx = *x;
-    int yy = *y;
-    XTranslateCoordinates(display, thisWindow, rootWindow, xx, yy, x, y, &childWindow);
+    int xx = x ? *x : 0;
+    int yy = y ? *y : 0;
+    XTranslateCoordinates(display, thisWindow, rootWindow,
+                          xx, yy, x ? x : &xx, y ? y : &yy,
+                          &childWindow);
 }
 
 
@@ -1694,8 +1701,14 @@ int wxNoOptimize::ms_count = 0;
 class wxWinModule : public wxModule
 {
 public:
-    bool OnInit();
-    void OnExit();
+    wxWinModule()
+    {
+        // we must be cleaned up before the display is closed
+        AddDependency(wxClassInfo::FindClass(_T("wxX11DisplayModule")));
+    }
+
+    virtual bool OnInit();
+    virtual void OnExit();
 
 private:
     DECLARE_DYNAMIC_CLASS(wxWinModule)