From f809133f9eb30d4746c71098bbc14c621b94ef0d Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 24 Feb 2002 16:23:43 +0000 Subject: [PATCH] Added expose event compression. Made wxUniv scrollbars not accept any focus if they are owned by the window (in contrast to stand alone scrollbars). Further corrections to ScrollWindow() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14389 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/univ/scrolbar.h | 4 +++ samples/erase/erase.cpp | 14 +++++++++- src/common/popupcmn.cpp | 2 ++ src/univ/scrolbar.cpp | 18 +++++++++++++ src/x11/app.cpp | 54 +++++++++++++++++++++++++++++++++++--- src/x11/toplevel.cpp | 12 ++++----- src/x11/window.cpp | 4 +-- 7 files changed, 95 insertions(+), 13 deletions(-) diff --git a/include/wx/univ/scrolbar.h b/include/wx/univ/scrolbar.h index 2aa478414b..e1ec962adf 100644 --- a/include/wx/univ/scrolbar.h +++ b/include/wx/univ/scrolbar.h @@ -99,6 +99,10 @@ public: long numArg = 0, const wxString& strArg = wxEmptyString); + // The scrollbars around a normal window should not + // receive the focus. + virtual bool AcceptsFocus() const; + // wxScrollBar sub elements state (combination of wxCONTROL_XXX) void SetState(Element which, int flags); int GetState(Element which) const; diff --git a/samples/erase/erase.cpp b/samples/erase/erase.cpp index 54c6dfbbbc..ec15d7978e 100644 --- a/samples/erase/erase.cpp +++ b/samples/erase/erase.cpp @@ -180,18 +180,30 @@ void MyCanvas::OnPaint( wxPaintEvent &event ) { wxPaintDC dc(this); PrepareDC( dc ); - + +#if 0 wxRegionIterator upd( GetUpdateRegion() ); while (upd) { wxLogDebug( "Paint: %d %d %d %d", upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight() ); upd ++; } +#endif + +#if 0 + wxSize size = GetSize(); + wxSize client_size = GetClientSize(); + wxLogDebug( "size %d %d client_size %d %d", size.x, size.y, client_size.x, client_size.y ); +#endif dc.SetPen( *wxWHITE_PEN ); for (int i = 0; i < 20; i += 2) dc.DrawLine( i,i, i+100,i ); + dc.SetPen( *wxWHITE_PEN ); + for (int i = 200; i < 220; i += 2) + dc.DrawLine( i-200,i, i-100,i ); + wxRegion region( 110, 110, 80, 80 ); wxRegion hole( 130, 130, 40, 1 ); region.Intersect( hole ); diff --git a/src/common/popupcmn.cpp b/src/common/popupcmn.cpp index 7da199a713..db3250b429 100644 --- a/src/common/popupcmn.cpp +++ b/src/common/popupcmn.cpp @@ -427,6 +427,8 @@ void wxPopupFocusHandler::OnKillFocus(wxFocusEvent& event) win = win->GetParent(); } + printf( "Dismiss now.\n" ); + m_popup->DismissAndNotify(); } diff --git a/src/univ/scrolbar.cpp b/src/univ/scrolbar.cpp index e2f146b7d4..464681e645 100644 --- a/src/univ/scrolbar.cpp +++ b/src/univ/scrolbar.cpp @@ -164,6 +164,24 @@ wxScrollBar::~wxScrollBar() { } +bool wxScrollBar::AcceptsFocus() const +{ + if (!wxWindow::AcceptsFocus()) return FALSE; + + wxWindow *parent = (wxWindow*) GetParent(); + + if (parent) + { + if ((parent->GetScrollbar( wxHORIZONTAL ) == this) || + (parent->GetScrollbar( wxVERTICAL ) == this)) + { + return FALSE; + } + } + + return TRUE; +} + // ---------------------------------------------------------------------------- // scrollbar API // ---------------------------------------------------------------------------- diff --git a/src/x11/app.cpp b/src/x11/app.cpp index 58881f9d63..9d45e90a6d 100644 --- a/src/x11/app.cpp +++ b/src/x11/app.cpp @@ -411,7 +411,42 @@ int wxApp::MainLoop() return rt; } +//----------------------------------------------------------------------- +// X11 predicate function for exposure compression +//----------------------------------------------------------------------- + +struct wxExposeInfo +{ + Window window; + Bool found_non_matching; +}; + +static Bool expose_predicate (Display *display, XEvent *xevent, XPointer arg) +{ + wxExposeInfo *info = (wxExposeInfo*) arg; + + if (info->found_non_matching) + return FALSE; + + if (xevent->xany.type != Expose) + { + info->found_non_matching = TRUE; + return FALSE; + } + + if (xevent->xexpose.window != info->window) + { + info->found_non_matching = TRUE; + return FALSE; + } + + return TRUE; +} + +//----------------------------------------------------------------------- // Processes an X event. +//----------------------------------------------------------------------- + void wxApp::ProcessXEvent(WXEvent* _event) { XEvent* event = (XEvent*) _event; @@ -541,13 +576,23 @@ void wxApp::ProcessXEvent(WXEvent* _event) win->GetClearRegion().Union( XExposeEventGetX(event), XExposeEventGetY(event), XExposeEventGetWidth(event), XExposeEventGetHeight(event)); + #if !wxUSE_NANOX - if (event->xexpose.count == 0) -#endif + XEvent tmp_event; + wxExposeInfo info; + info.window = event->xexpose.window; + info.found_non_matching = FALSE; + while (XCheckIfEvent( wxGlobalDisplay(), &tmp_event, expose_predicate, (XPointer) &info )) { - // Only erase background, paint in idle time. - win->SendEraseEvents(); + win->GetUpdateRegion().Union( tmp_event.xexpose.x, tmp_event.xexpose.y, + tmp_event.xexpose.width, tmp_event.xexpose.height ); + + win->GetClearRegion().Union( tmp_event.xexpose.x, tmp_event.xexpose.y, + tmp_event.xexpose.width, tmp_event.xexpose.height ); } +#endif + + win->SendEraseEvents(); return; } @@ -621,6 +666,7 @@ void wxApp::ProcessXEvent(WXEvent* _event) focusEvent.SetEventObject(win); focusEvent.SetWindow( g_prevFocus ); g_prevFocus = NULL; + win->GetEventHandler()->ProcessEvent(focusEvent); } break; diff --git a/src/x11/toplevel.cpp b/src/x11/toplevel.cpp index 400891ac1d..69a6f46c17 100644 --- a/src/x11/toplevel.cpp +++ b/src/x11/toplevel.cpp @@ -585,11 +585,11 @@ void wxTopLevelWindowX11::DoSetClientSize(int width, int height) void wxTopLevelWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags) { - wxLogDebug( "Setting pos: %d, %d", x, y ); + // wxLogDebug( "Setting pos: %d, %d", x, y ); wxWindowX11::DoSetSize(x, y, width, height, sizeFlags); wxPoint pt = GetPosition(); - wxLogDebug( "After, pos: %d, %d", pt.x, pt.y ); + // wxLogDebug( "After, pos: %d, %d", pt.x, pt.y ); #if 0 XSync(wxGlobalDisplay(), False); int w, h; @@ -605,14 +605,14 @@ void wxTopLevelWindowX11::DoSetSize(int x, int y, int width, int height, int siz if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { - int yy = 0; + int yy = 0; AdjustForParentClientOrigin( x, yy, sizeFlags); windowChanges.x = x; valueMask |= CWX; } if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { - int xx = 0; + int xx = 0; AdjustForParentClientOrigin( xx, y, sizeFlags); windowChanges.y = y; valueMask |= CWY; @@ -647,12 +647,12 @@ void wxTopLevelWindowX11::DoGetPosition(int *x, int *y) const int offsetY = 0; #if !wxUSE_NANOX - wxLogDebug("Translating..."); + // wxLogDebug("Translating..."); Window childWindow; XTranslateCoordinates(wxGlobalDisplay(), window, XDefaultRootWindow(wxGlobalDisplay()), 0, 0, & offsetX, & offsetY, & childWindow); - wxLogDebug("Offset: %d, %d", offsetX, offsetY); + // wxLogDebug("Offset: %d, %d", offsetX, offsetY); #endif XWindowAttributes attr; diff --git a/src/x11/window.cpp b/src/x11/window.cpp index cb7c133691..cd6575da0c 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -562,8 +562,8 @@ void wxWindowX11::ScrollWindow(int dx, int dy, const wxRect *rect) else { wxRect rect; - if (dx < 0) rect.x = cw+dx; else rect.x = s_x; - if (dy < 0) rect.y = ch+dy; else rect.y = s_y; + if (dx < 0) rect.x = cw+dx + offset.x; else rect.x = s_x; + if (dy < 0) rect.y = ch+dy + offset.y; else rect.y = s_y; if (dy != 0) rect.width = cw; else rect.width = abs(dx); if (dx != 0) rect.height = ch; else rect.height = abs(dy); -- 2.45.2