X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/be82fa69894de6a44094e8f9fdceed610fcb3dc3..12bb29f5432174ecbd65549bda832d70d34a98ae:/src/x11/window.cpp diff --git a/src/x11/window.cpp b/src/x11/window.cpp index a04296c7f9..fccabf677d 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -47,7 +47,6 @@ #include "wx/layout.h" #include "wx/menuitem.h" #include "wx/module.h" - #include "wx/unix/utilsx11.h" #endif #include "wx/fontutil.h" @@ -57,6 +56,8 @@ #include "wx/dnd.h" #endif +#include "wx/unix/utilsx11.h" + #include "wx/x11/private.h" #include "X11/Xutil.h" @@ -396,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 ); @@ -578,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; @@ -1027,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. @@ -1055,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. @@ -1088,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()) { @@ -1103,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; @@ -1317,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) @@ -1485,6 +1486,7 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, button = xevent->xbutton.button; wxevent.m_linesPerAction = 3; + wxevent.m_columnsPerAction = 3; wxevent.m_wheelDelta = WHEEL_DELTA; // Button 4 means mousewheel up, 5 means down @@ -1746,6 +1748,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 );