From: Robert Roebling <robert@roebling.de>
Date: Fri, 15 Feb 2002 20:25:40 +0000 (+0000)
Subject:   wxX11:
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/4125131be6577c7770c9991b22fee98eff9e0e7f

  wxX11:
    Added new scrolling code.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14241 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/src/univ/winuniv.cpp b/src/univ/winuniv.cpp
index 0f5b590014..719515c231 100644
--- a/src/univ/winuniv.cpp
+++ b/src/univ/winuniv.cpp
@@ -763,6 +763,12 @@ int wxWindow::GetScrollRange(int orient) const
 
 void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
 {
+#ifdef __WXX11__
+
+    wxWindowX11::ScrollWindow( dx, dy, rect );
+
+#else
+
     // before scrolling it, ensure that we don't have any unpainted areas
     Update();
 
@@ -779,6 +785,8 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
         r = ScrollNoRefresh(0, dy, rect);
         Refresh(TRUE /* erase bkgnd */, &r);
     }
+    
+#endif
 }
 
 wxRect wxWindow::ScrollNoRefresh(int dx, int dy, const wxRect *rectTotal)
diff --git a/src/x11/app.cpp b/src/x11/app.cpp
index 21eff48925..9f7b82c9d7 100644
--- a/src/x11/app.cpp
+++ b/src/x11/app.cpp
@@ -405,7 +405,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
     wxWindow* win = NULL;
     Window window = event->xany.window;
     Window actualWindow = window;
-
+    
     // Find the first wxWindow that corresponds to this event window
     // Because we're receiving events after a window
     // has been destroyed, assume a 1:1 match between
@@ -548,6 +548,26 @@ void wxApp::ProcessXEvent(WXEvent* _event)
 
             return;
         }
+        case GraphicsExpose:
+        {
+            if (win)
+            {
+                wxLogDebug( "GraphicsExpose from %s", win->GetName().c_str(),
+                                              event->xgraphicsexpose.x, event->xgraphicsexpose.y,
+                                              event->xgraphicsexpose.width, event->xgraphicsexpose.height);
+                    
+                win->GetUpdateRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
+                                              event->xgraphicsexpose.width, event->xgraphicsexpose.height);
+                                              
+                win->GetClearRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
+                                             event->xgraphicsexpose.width, event->xgraphicsexpose.height);
+                                              
+                // if (event->xgraphicsexpose.count == 0)
+                //    win->Update();
+            }
+
+            return;
+        }
         case EnterNotify:
         case LeaveNotify:
         case ButtonPress:
@@ -585,7 +605,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
                 if (win && event->xfocus.detail != NotifyPointer)
 #endif
                 {
-                    wxLogDebug( "FocusOut from %s\n", win->GetName().c_str() );
+                    wxLogDebug( "FocusOut from %s", win->GetName().c_str() );
                     
                     wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId());
                     focusEvent.SetEventObject(win);
diff --git a/src/x11/window.cpp b/src/x11/window.cpp
index 75c41eb94c..39614cd0c1 100644
--- a/src/x11/window.cpp
+++ b/src/x11/window.cpp
@@ -469,34 +469,55 @@ void wxWindowX11::ScrollWindow(int dx, int dy, const wxRect *rect)
     GC xgc = XCreateGC( xdisplay, xwindow, 0, NULL );
     XSetGraphicsExposures( xdisplay, xgc, True );
 
-    int cw = 0;
-    int ch = 0;
-    GetClientSize( &cw, &ch );
+    int s_x;
+    int s_y;
+    int cw;
+    int ch;
+    if (rect)
+    {
+        s_x = rect->x;
+        s_y = rect->y;
+        cw = rect->width;
+        ch = rect->height;
+    }
+    else
+    {
+        s_x = 0;
+        s_y = 0;
+        GetClientSize( &cw, &ch );
+    }
+    
+    wxPoint offset = GetClientAreaOrigin();
+    s_x += offset.x;
+    s_y += offset.y;
+
     int w = cw - abs(dx);
     int h = ch - abs(dy);
-
+        
     if ((h < 0) || (w < 0))
     {
         Refresh();
     }
     else
     {
-        int s_x = 0;
-        int s_y = 0;
-        if (dx < 0) s_x = -dx;
-        if (dy < 0) s_y = -dy;
-        int d_x = 0;
-        int d_y = 0;
+        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 (dy != 0) rect.width = cw; else rect.width = abs(dx);
+        if (dx != 0) rect.height = ch; else rect.height = abs(dy);
+    
+        int d_x = s_x;
+        int d_y = s_y;
+        if (dx < 0) s_x += -dx;
+        if (dy < 0) s_y += -dy;
         if (dx > 0) d_x = dx;
         if (dy > 0) d_y = dy;
 
         XCopyArea( xdisplay, xwindow, xwindow, xgc, s_x, s_y, w, h, d_x, d_y );
+        
+        // printf( "s_x %d s_y %d w %d h %d d_x %d d_y %d\n", s_x, s_y, w, h, d_x, d_y );
 
-        wxRect rect;
-        if (dx < 0) rect.x = cw+dx; else rect.x = 0;
-        if (dy < 0) rect.y = ch+dy; else rect.y = 0;
-        if (dy != 0) rect.width = cw; else rect.width = abs(dx);
-        if (dx != 0) rect.height = ch; else rect.height = abs(dy);
+        // printf( "rect %d %d %d %d\n", rect.x, rect.y, rect.width, rect.height );
 
         m_updateRegion.Union( rect );
         m_clearRegion.Union( rect );