]> git.saurik.com Git - wxWidgets.git/commitdiff
Added expose event compression.
authorRobert Roebling <robert@roebling.de>
Sun, 24 Feb 2002 16:23:43 +0000 (16:23 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 24 Feb 2002 16:23:43 +0000 (16:23 +0000)
  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
samples/erase/erase.cpp
src/common/popupcmn.cpp
src/univ/scrolbar.cpp
src/x11/app.cpp
src/x11/toplevel.cpp
src/x11/window.cpp

index 2aa478414bbbabb067a5e915924f24383622099e..e1ec962adf3e5291bb6baa4a833d034ca27313ee 100644 (file)
@@ -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;
index 54c6dfbbbceed09965231ebf0b78b761136706f7..ec15d7978ea227ec6febaf1f13f84c583b945f04 100644 (file)
@@ -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 );
index 7da199a713f50435b6fb8f8ed782070433954f7d..db3250b429b5df64b2ab6fba369a635abfa3155b 100644 (file)
@@ -427,6 +427,8 @@ void wxPopupFocusHandler::OnKillFocus(wxFocusEvent& event)
         win = win->GetParent();
     }
     
+    printf( "Dismiss now.\n" );
+    
     m_popup->DismissAndNotify();
 }
 
index e2f146b7d42f1d7e270f74545f21c7c65c47fde1..464681e6453fa9801ea676af6bc63fac175796cc 100644 (file)
@@ -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
 // ----------------------------------------------------------------------------
index 58881f9d6344bdbe145cc9df6405dc3c75207631..9d45e90a6d90aec068b3028b8f613963e186713f 100644 (file)
@@ -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;
index 400891ac1d6aea2621f158abf20eb2d469c782dc..69a6f46c178211dba22d5ba5c58cb5349002d30f 100644 (file)
@@ -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;
index cb7c1336914d8f649284cfdbe49c6fb92cee815d..cd6575da0c1d4ca8de8d7e1f834d9abe322b5006 100644 (file)
@@ -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);