// Author: Julian Smart
// Modified by:
// Created: 17/09/98
-// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/dnd.h"
#endif
+#include "wx/unix/utilsx11.h"
+
#include "wx/x11/private.h"
#include "X11/Xutil.h"
if (parent->GetInsertIntoMain())
{
// wxLogDebug( "Inserted into main: %s", GetName().c_str() );
- xparent = (Window) parent->GetMainWindow();
+ xparent = (Window) parent->X11GetMainWindow();
}
// Size (not including the border) must be nonzero (or a Value error results)!
}
#endif
- if (wxWindowIsVisible(xwindow))
+ XWindowAttributes wa;
+ XGetWindowAttributes(wxGlobalDisplay(), xwindow, &wa);
+
+ if (wa.map_state == IsViewable)
{
- wxLogTrace( _T("focus"), _T("wxWindowX11::SetFocus: %s"), GetClassInfo()->GetClassName());
+ wxLogTrace( wxT("focus"), wxT("wxWindowX11::SetFocus: %s"), GetClassInfo()->GetClassName());
// XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToNone, CurrentTime );
m_needsInputFocus = false;
msg.Printf(wxT("Failed to grab pointer for window %s"), this->GetClassInfo()->GetClassName());
wxLogDebug(msg);
if (res == GrabNotViewable)
+ {
wxLogDebug( wxT("This is not a viewable window - perhaps not shown yet?") );
+ }
g_captureWindow = NULL;
return;
wxCHECK_MSG( xwindow, false, wxT("invalid window") );
wxCursor cursorToUse;
- if (m_cursor.Ok())
+ if (m_cursor.IsOk())
cursorToUse = m_cursor;
else
cursorToUse = *wxSTANDARD_CURSOR;
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.
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.
#endif
}
-void wxWindowX11::GetTextExtent(const wxString& string,
- int *x, int *y,
- int *descent, int *externalLeading,
- const wxFont *theFont) const
+void wxWindowX11::DoGetTextExtent(const wxString& string,
+ int *x, int *y,
+ int *descent,
+ int *externalLeading,
+ const wxFont *theFont) const
{
wxFont fontToUse = GetFont();
if (theFont) fontToUse = *theFont;
- wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") );
+ wxCHECK_RET( fontToUse.IsOk(), wxT("invalid font") );
if (string.empty())
{
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;
x = sb->GetPosition().x;
Display *xdisplay = wxGlobalDisplay();
- Window xwindow = (Window) GetMainWindow();
+ Window xwindow = (Window) X11GetMainWindow();
Colormap cm = (Colormap) wxTheApp->GetMainColormap( wxGetDisplay() );
wxColour colour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
colour.CalcPixel( (WXColormap) cm );
// 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)
// X11-specific accessors
// ----------------------------------------------------------------------------
-WXWindow wxWindowX11::GetMainWindow() const
+WXWindow wxWindowX11::X11GetMainWindow() const
{
return m_mainWindow;
}
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
wxWindow *wxGetActiveWindow()
{
- // TODO
- wxFAIL_MSG(wxT("Not implemented"));
- return NULL;
+ return wxGetTopLevelParent(wxWindow::FindFocus());
}
/* static */
wxWinModule()
{
// we must be cleaned up before the display is closed
- AddDependency(wxClassInfo::FindClass(_T("wxX11DisplayModule")));
+ AddDependency(wxClassInfo::FindClass(wxT("wxX11DisplayModule")));
}
virtual bool OnInit();
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 );