X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1180fb81d990408decf4d74cac18fd495ba0667d..59c962bf54667cab735353b2ec3b7a2438464f22:/src/x11/window.cpp diff --git a/src/x11/window.cpp b/src/x11/window.cpp index da1a164a6d..89ba9d056a 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -49,12 +49,6 @@ #include -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -static const int SCROLL_MARGIN = 4; - // ---------------------------------------------------------------------------- // global variables for this module // ---------------------------------------------------------------------------- @@ -78,7 +72,6 @@ IMPLEMENT_ABSTRACT_CLASS(wxWindowX11, wxWindowBase) BEGIN_EVENT_TABLE(wxWindowX11, wxWindowBase) EVT_SYS_COLOUR_CHANGED(wxWindowX11::OnSysColourChanged) - EVT_IDLE(wxWindowX11::OnIdle) END_EVENT_TABLE() // ============================================================================ @@ -138,6 +131,7 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); m_backgroundColour.CalcPixel( (WXColormap) cm ); + m_hasBgCol = TRUE; m_foregroundColour = *wxBLACK; m_foregroundColour.CalcPixel( (WXColormap) cm ); @@ -149,7 +143,7 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, xdisplay, parentWindow, x, y, w, h, 0, m_backgroundColour.GetPixel(), - m_foregroundColour.GetPixel() ); + m_backgroundColour.GetPixel() ); m_mainWidget = (WXWindow) window; @@ -258,17 +252,23 @@ bool wxWindowX11::Enable(bool enable) bool wxWindowX11::Show(bool show) { - if ( !wxWindowBase::Show(show) ) - return FALSE; + wxWindowBase::Show(show); Window xwin = (Window) GetXWindow(); Display *xdisp = (Display*) GetXDisplay(); if (show) { + wxString msg; + msg.Printf("Mapping window of type %s", GetClassInfo()->GetClassName()); + wxLogDebug(msg); XMapWindow(xdisp, xwin); + XSync(xdisp, False); } else { + wxString msg; + msg.Printf("Unmapping window of type %s", GetClassInfo()->GetClassName()); + wxLogDebug(msg); XUnmapWindow(xdisp, xwin); } @@ -291,10 +291,21 @@ void wxWindowX11::Lower() void wxWindowX11::DoCaptureMouse() { - g_captureWindow = (wxWindow*) this; + if ((g_captureWindow != NULL) && (g_captureWindow != this)) + { + wxASSERT_MSG(FALSE, "Trying to capture before mouse released."); + + // Core dump now + int *tmp = NULL; + (*tmp) = 1; + return; + } + if ( m_winCaptured ) return; + g_captureWindow = (wxWindow*) this; + if (GetMainWindow()) { int res = XGrabPointer(wxGlobalDisplay(), (Window) GetMainWindow(), @@ -308,10 +319,19 @@ void wxWindowX11::DoCaptureMouse() if (res != GrabSuccess) { - wxLogDebug("Failed to grab pointer."); + wxString msg; + msg.Printf("Failed to grab pointer for window %s", this->GetClassInfo()->GetClassName()); + wxLogDebug(msg); + if (res == GrabNotViewable) + { + wxLogDebug("This is not a viewable window - perhaps not shown yet?"); + } + g_captureWindow = NULL; return; } + wxLogDebug("Grabbed pointer"); +#if 0 res = XGrabButton(wxGlobalDisplay(), AnyButton, AnyModifier, (Window) GetMainWindow(), FALSE, @@ -320,14 +340,16 @@ void wxWindowX11::DoCaptureMouse() GrabModeAsync, None, None); - + if (res != GrabSuccess) { wxLogDebug("Failed to grab mouse buttons."); XUngrabPointer(wxGlobalDisplay(), CurrentTime); return; } +#endif +#if 0 res = XGrabKeyboard(wxGlobalDisplay(), (Window) GetMainWindow(), #if 0 ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask, @@ -342,11 +364,14 @@ void wxWindowX11::DoCaptureMouse() { wxLogDebug("Failed to grab keyboard."); XUngrabPointer(wxGlobalDisplay(), CurrentTime); +#if 0 XUngrabButton(wxGlobalDisplay(), AnyButton, AnyModifier, (Window) GetMainWindow()); +#endif return; } - +#endif + m_winCaptured = TRUE; } } @@ -362,10 +387,13 @@ void wxWindowX11::DoReleaseMouse() if ( wMain ) { XUngrabPointer(wxGlobalDisplay(), wMain); +#if 0 XUngrabButton(wxGlobalDisplay(), AnyButton, AnyModifier, wMain); XUngrabKeyboard(wxGlobalDisplay(), CurrentTime); +#endif } + wxLogDebug("Ungrabbed pointer"); m_winCaptured = FALSE; } @@ -395,11 +423,10 @@ bool wxWindowX11::SetCursor(const wxCursor& cursor) else cursor2 = wxSTANDARD_CURSOR; - WXDisplay *dpy = GetXDisplay(); - WXCursor x_cursor = cursor2->GetXCursor(dpy); + WXCursor x_cursor = cursor2->GetCursor(); Window win = (Window) GetMainWindow(); - XDefineCursor((Display*) dpy, win, (Cursor) x_cursor); + XDefineCursor((Display*) wxGlobalDisplay(), win, (Cursor) x_cursor); return TRUE; } @@ -719,11 +746,15 @@ void wxWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags) if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { + int yy = 0; + AdjustForParentClientOrigin( x, yy, sizeFlags); windowChanges.x = x; valueMask |= CWX; } if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { + int xx = 0; + AdjustForParentClientOrigin( xx, y, sizeFlags); windowChanges.y = y; valueMask |= CWY; } @@ -737,7 +768,6 @@ void wxWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags) windowChanges.height = height /* -m_borderSize*2*/; valueMask |= CWHeight; } - AdjustForParentClientOrigin( x, y, sizeFlags); XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(), valueMask, & windowChanges); @@ -858,13 +888,12 @@ void wxWindowX11::GetTextExtent(const wxString& string, int *descent, int *externalLeading, const wxFont *theFont) const { - wxFont *fontToUse = (wxFont *)theFont; - if (!fontToUse) - fontToUse = (wxFont *) & m_font; + wxFont fontToUse = m_font; + if (theFont) fontToUse = *theFont; - wxCHECK_RET( fontToUse->Ok(), "valid window font needed" ); - - WXFontStructPtr pFontStruct = theFont->GetFontStruct(1.0, GetXDisplay()); + wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") ); + + WXFontStructPtr pFontStruct = fontToUse.GetFontStruct(1.0, GetXDisplay()); int direction, ascent, descent2; XCharStruct overall; @@ -876,7 +905,7 @@ void wxWindowX11::GetTextExtent(const wxString& string, &ascent, &descent2, &overall); #endif - XTextExtents((XFontStruct*) pFontStruct, string, slen, + XTextExtents((XFontStruct*) pFontStruct, string.c_str(), slen, &direction, &ascent, &descent2, &overall); if ( x ) @@ -921,16 +950,13 @@ void wxWindowX11::Refresh(bool eraseBack, const wxRect *rect) } else { - int height,width; - GetSize( &width, &height ); + int height,width; + GetSize( &width, &height ); // Schedule for later Updating in ::Update() or ::OnInternalIdle(). m_updateRegion.Clear(); m_updateRegion.Union( 0, 0, width, height ); } - - // Actually don't schedule yet.. - Update(); } void wxWindowX11::Update() @@ -953,7 +979,7 @@ void wxWindowX11::X11SendPaintEvents() { m_clipPaintRegion = TRUE; - if (!m_clearRegion.IsEmpty()) + // if (!m_clearRegion.IsEmpty()) { wxWindowDC dc( (wxWindow*)this ); dc.SetClippingRegion( m_clearRegion ); @@ -982,6 +1008,8 @@ void wxWindowX11::X11SendPaintEvents() paint_event.SetEventObject( this ); GetEventHandler()->ProcessEvent( paint_event ); + m_updateRegion.Clear(); + m_clipPaintRegion = FALSE; } @@ -1008,8 +1036,11 @@ void wxWindowX11::OnSysColourChanged(wxSysColourChangedEvent& event) } } -void wxWindowX11::OnIdle(wxIdleEvent& WXUNUSED(event)) +void wxWindowX11::OnInternalIdle() { + // Update invalidated regions. + Update(); + // This calls the UI-update mechanism (querying windows for // menu/toolbar/control state information) UpdateWindowUI(); @@ -1310,8 +1341,7 @@ int wxComputeColours (Display *display, wxColour * back, wxColour * fore) bool wxWindowX11::SetBackgroundColour(const wxColour& col) { - if ( !wxWindowBase::SetBackgroundColour(col) ) - return FALSE; + wxWindowBase::SetBackgroundColour(col); if (!GetMainWindow()) return FALSE;