X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/58ec225526177917a3806c6cd394ab56d18280e1..cc77c86d1e71bae248f59f83904971d83e78c1a5:/src/x11/window.cpp diff --git a/src/x11/window.cpp b/src/x11/window.cpp index 9fa7e4d83f..ad5607f4d2 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -127,15 +127,6 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, parent->AddChild(this); - int w = size.GetWidth(); - int h = size.GetHeight(); - int x = size.GetX(); - int y = size.GetY(); - if (w == -1) w = 20; - if (h == -1) h = 20; - if (x == -1) x = 0; - if (y == -1) y = 0; - Display *xdisplay = (Display*) wxGlobalDisplay(); int xscreen = DefaultScreen( xdisplay ); Visual *xvisual = DefaultVisual( xdisplay, xscreen ); @@ -147,7 +138,7 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, m_foregroundColour = *wxBLACK; m_foregroundColour.CalcPixel( (WXColormap) cm ); - Window xparent = (Window) parent->GetClientWindow(); + Window xparent = (Window) parent->GetClientAreaWindow(); // Add window's own scrollbars to main window, not to client window if (parent->GetInsertIntoMain()) @@ -156,17 +147,19 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, xparent = (Window) parent->GetMainWindow(); } + // Size (not including the border) must be nonzero (or a Value error results)! + // Note: The Xlib manual doesn't mention this restriction of XCreateWindow. wxSize size2(size); - if (size2.x == -1) - size2.x = 20; - if (size2.y == -1) - size2.y = 20; + if (size2.x <= 0) + size2.x = 20; + if (size2.y <= 0) + size2.y = 20; wxPoint pos2(pos); if (pos2.x == -1) - pos2.x = 0; + pos2.x = 0; if (pos2.y == -1) - pos2.y = 0; + pos2.y = 0; #if wxUSE_TWO_WINDOWS bool need_two_windows = @@ -242,18 +235,26 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, pos2.y = 2; size2.x -= 4; size2.y -= 4; - } else - if (HasFlag( wxSIMPLE_BORDER )) + } + else if (HasFlag( wxSIMPLE_BORDER )) { pos2.x = 1; pos2.y = 1; size2.x -= 2; size2.y -= 2; - } else + } + else { pos2.x = 0; pos2.y = 0; } + + // Make again sure the size is nonzero. + if (size2.x <= 0) + size2.x = 1; + if (size2.y <= 0) + size2.y = 1; + #if wxUSE_NANOX backColor = GR_RGB(m_backgroundColour.Red(), m_backgroundColour.Green(), m_backgroundColour.Blue()); foreColor = GR_RGB(m_foregroundColour.Red(), m_foregroundColour.Green(), m_foregroundColour.Blue()); @@ -602,7 +603,7 @@ void wxWindowX11::ScrollWindow(int dx, int dy, const wxRect *rect) m_clearRegion.Intersect( 0, 0, cw, ch ); } - Window xwindow = (Window) GetClientWindow(); + Window xwindow = (Window) GetClientAreaWindow(); wxCHECK_RET( xwindow, wxT("invalid window") ); @@ -1129,7 +1130,7 @@ void wxWindowX11::SendEraseEvents() if (!GetEventHandler()->ProcessEvent(erase_event) ) { Display *xdisplay = wxGlobalDisplay(); - Window xwindow = (Window) GetClientWindow(); + Window xwindow = (Window) GetClientAreaWindow(); XSetForeground( xdisplay, g_eraseGC, m_backgroundColour.GetPixel() ); wxRegionIterator upd( m_clearRegion ); @@ -1267,7 +1268,7 @@ bool wxAddWindowToTable(Window w, wxWindow *win) wxWidgetHashTable->Put((long) w, win); wxLogTrace("widget", "XWindow 0x%08x <-> window %p (%s)", - w, win, win->GetClassInfo()->GetClassName()); + (unsigned int) w, win, win->GetClassInfo()->GetClassName()); return TRUE; } @@ -1299,7 +1300,7 @@ bool wxAddClientWindowToTable(Window w, wxWindow *win) wxClientWidgetHashTable->Put((long) w, win); wxLogTrace("widget", "XWindow 0x%08x <-> window %p (%s)", - w, win, win->GetClassInfo()->GetClassName()); + (unsigned int) w, win, win->GetClassInfo()->GetClassName()); return TRUE; } @@ -1327,7 +1328,7 @@ WXWindow wxWindowX11::GetMainWindow() const return m_mainWindow; } -WXWindow wxWindowX11::GetClientWindow() const +WXWindow wxWindowX11::GetClientAreaWindow() const { return m_clientWindow; }