X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/80f4c796428fb7fa5934a0b9305007f820b8eaac..13b4df952c77383f50696e51fcbaa2d8bbd3b3b9:/src/x11/window.cpp

diff --git a/src/x11/window.cpp b/src/x11/window.cpp
index 7c2e5ae15b..fcd2ee3dea 100644
--- a/src/x11/window.cpp
+++ b/src/x11/window.cpp
@@ -397,7 +397,10 @@ void wxWindowX11::SetFocus()
     }
 #endif
 
-    if (wxWindowIsVisible(xwindow))
+    XWindowAttributes wa;
+    XGetWindowAttributes(wxGlobalDisplay(), xwindow, &wa);
+
+    if (wa.map_state == IsViewable)
     {
         wxLogTrace( wxT("focus"), wxT("wxWindowX11::SetFocus: %s"), GetClassInfo()->GetClassName());
         //        XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
@@ -579,7 +582,7 @@ bool wxWindowX11::SetCursor(const wxCursor& cursor)
     wxCHECK_MSG( xwindow, false, wxT("invalid window") );
 
     wxCursor cursorToUse;
-    if (m_cursor.Ok())
+    if (m_cursor.IsOk())
         cursorToUse = m_cursor;
     else
         cursorToUse = *wxSTANDARD_CURSOR;
@@ -1028,7 +1031,7 @@ void wxWindowX11::DoSetSizeHints(int minW, int minH, int maxW, int maxH, int inc
 int wxWindowX11::GetCharHeight() const
 {
     wxFont font(GetFont());
-    wxCHECK_MSG( font.Ok(), 0, wxT("valid window font needed") );
+    wxCHECK_MSG( font.IsOk(), 0, wxT("valid window font needed") );
 
 #if wxUSE_UNICODE
     // There should be an easier way.
@@ -1056,7 +1059,7 @@ int wxWindowX11::GetCharHeight() const
 int wxWindowX11::GetCharWidth() const
 {
     wxFont font(GetFont());
-    wxCHECK_MSG( font.Ok(), 0, wxT("valid window font needed") );
+    wxCHECK_MSG( font.IsOk(), 0, wxT("valid window font needed") );
 
 #if wxUSE_UNICODE
     // There should be an easier way.
@@ -1089,7 +1092,7 @@ void wxWindowX11::DoGetTextExtent(const wxString& string,
     wxFont fontToUse = GetFont();
     if (theFont) fontToUse = *theFont;
 
-    wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") );
+    wxCHECK_RET( fontToUse.IsOk(), wxT("invalid font") );
 
     if (string.empty())
     {
@@ -1104,7 +1107,7 @@ void wxWindowX11::DoGetTextExtent(const wxString& string,
     PangoFontDescription *desc = fontToUse.GetNativeFontInfo()->description;
     pango_layout_set_font_description(layout, desc);
 
-    const wxCharBuffer data = wxConvUTF8.cWC2MB( string );
+    const wxCharBuffer data = wxConvUTF8.cWC2MB( string.wc_str() );
     pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data ));
 
     PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
@@ -1318,10 +1321,7 @@ void wxWindowX11::OnInternalIdle()
     // Update invalidated regions.
     Update();
 
-    // This calls the UI-update mechanism (querying windows for
-    // menu/toolbar/control state information)
-    if (wxUpdateUIEvent::CanUpdate((wxWindow*) this) && IsShownOnScreen())
-        UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
+    wxWindowBase::OnInternalIdle();
 
     // Set the input focus if couldn't do it before
     if (m_needsInputFocus)
@@ -1747,6 +1747,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxWinModule, wxModule)
 bool wxWinModule::OnInit()
 {
     Display *xdisplay = wxGlobalDisplay();
+    if ( !xdisplay )
+    {
+        // This module may be linked into a console program when using
+        // monolithic library and in this case it's perfectly normal not to
+        // have a display, so just return without doing anything and avoid
+        // crashing below.
+        return true;
+    }
+
     int xscreen = DefaultScreen( xdisplay );
     Window xroot = RootWindow( xdisplay, xscreen );
     g_eraseGC = XCreateGC( xdisplay, xroot, 0, NULL );