]> git.saurik.com Git - wxWidgets.git/commitdiff
Updated the erase/paint event logic.
authorRobert Roebling <robert@roebling.de>
Thu, 14 Feb 2002 21:08:45 +0000 (21:08 +0000)
committerRobert Roebling <robert@roebling.de>
Thu, 14 Feb 2002 21:08:45 +0000 (21:08 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14216 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/x11/window.h
src/x11/app.cpp
src/x11/popupwin.cpp
src/x11/toplevel.cpp
src/x11/window.cpp

index 426505a5fdee0a5ba66ba468719299160ee0eff3..5e747f150d57b5419dc03b9af61092de11e736ca 100644 (file)
@@ -111,7 +111,7 @@ public:
     WXDisplay *GetXDisplay() const;
     
     void SetLastClick(int button, long timestamp)
-    { m_lastButton = button; m_lastTS = timestamp; }
+        { m_lastButton = button; m_lastTS = timestamp; }
     
     int GetLastClickedButton() const { return m_lastButton; }
     long GetLastClickTime() const { return m_lastTS; }
@@ -126,6 +126,9 @@ public:
     // Clip to paint region?
     bool GetClipPaintRegion() { return m_clipPaintRegion; }
     
+    // Return clear region
+    wxRegion &GetClearRegion() { return m_clearRegion; }
+    
     // sets the fore/background colour for the given widget
     static void DoChangeForegroundColour(WXWindow widget, wxColour& foregroundColour);
     static void DoChangeBackgroundColour(WXWindow widget, wxColour& backgroundColour, bool changeArmColour = FALSE);
index 4d43a26b1726e7e58dd5dbfa26062c5758afb878..1133927b8d4ca57fa1cd805905565ecbd4322f27 100644 (file)
@@ -144,7 +144,7 @@ void wxApp::CleanUp()
     // wxDebugContext, too.
     if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
     {
-        wxLogDebug("There were memory leaks.\n");
+        wxLogDebug("There were memory leaks.");
         wxDebugContext::Dump();
         wxDebugContext::PrintStatistics();
     }
@@ -368,6 +368,8 @@ void wxApp::ProcessXEvent(WXEvent* _event)
                 {
                     wxKeyEvent keyEvent(wxEVT_KEY_DOWN);
                     wxTranslateKeyEvent(keyEvent, win, window, event);
+                    
+                    wxLogDebug( "OnKey from %s", win->GetName().c_str() );
         
                     // We didn't process wxEVT_KEY_DOWN, so send
                     // wxEVT_CHAR
@@ -464,9 +466,14 @@ void wxApp::ProcessXEvent(WXEvent* _event)
         {
             if (win)
             {
-                // Schedule update for later
                 win->GetUpdateRegion().Union( event->xexpose.x, event->xexpose.y,
                                               event->xexpose.width, event->xexpose.height);
+                                              
+                win->GetClearRegion().Union( event->xexpose.x, event->xexpose.y,
+                                             event->xexpose.width, event->xexpose.height);
+                                              
+                // if (event->xexpose.count == 0)
+                //    win->Update();
             }
 
             return;
@@ -492,6 +499,8 @@ void wxApp::ProcessXEvent(WXEvent* _event)
             {
                 if (win && event->xfocus.detail != NotifyPointer)
                 {
+                    wxLogDebug( "FocusIn from %s", win->GetName().c_str() );
+                    
                     wxFocusEvent focusEvent(wxEVT_SET_FOCUS, win->GetId());
                     focusEvent.SetEventObject(win);
                     win->GetEventHandler()->ProcessEvent(focusEvent);
@@ -502,6 +511,8 @@ void wxApp::ProcessXEvent(WXEvent* _event)
             {
                 if (win && event->xfocus.detail != NotifyPointer)
                 {
+                    wxLogDebug( "FocusOut from %s\n", win->GetName().c_str() );
+                    
                     wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId());
                     focusEvent.SetEventObject(win);
                     win->GetEventHandler()->ProcessEvent(focusEvent);
index e4d809c98cfbd3b6fb345e27b4ce4cce388de6ad..df21552719435f69279c0266c5941429219a8734 100644 (file)
@@ -77,6 +77,10 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
     m_mainWidget = (WXWindow) xwindow;
     wxAddWindowToTable( xwindow, (wxWindow*) this );
 
+    // Set background to None which will prevent X11 from clearing the
+    // background comletely.
+    XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
+
     XSetTransientForHint( xdisplay, xwindow, xparent );
 
     XWMHints wm_hints;
index 632a4e48b71a66a29a348d56fb97a575704d0dee..2a22dcb0b2dce4bf2b8968b9f4e753951e8dad0a 100644 (file)
@@ -135,6 +135,10 @@ bool wxTopLevelWindowX11::Create(wxWindow *parent,
 
     wxAddWindowToTable( xwindow, (wxWindow*) this );
 
+    // Set background to None which will prevent X11 from clearing the
+    // background completely.
+    XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
+
     // Messes up window management
     //    XSetTransientForHint( xdisplay, xwindow, xparent );
 
index 49966f1ae50328a96014605c2a2cc47994335dc5..a29ba888bf4b1ec16a21df2b19487dced7fe3a41 100644 (file)
@@ -129,11 +129,9 @@ 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 ); 
-    
 
     Window parentWindow = (Window) parent->GetMainWindow();
 
@@ -149,31 +147,35 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
     if (pos2.y == -1)
        pos2.y = 100;
     
-    Window window = XCreateSimpleWindow( 
+    Window xwindow = XCreateSimpleWindow( 
         xdisplay, parentWindow,
         pos2.x, pos2.y, size2.x, size2.y, 0, 
         m_backgroundColour.GetPixel(),
         m_backgroundColour.GetPixel() );
         
-    m_mainWidget = (WXWindow) window;
+    m_mainWidget = (WXWindow) xwindow;
 
     // Select event types wanted
-    XSelectInput( wxGlobalDisplay(), window,
+    XSelectInput( xdisplay, xwindow,
         ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
         ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
         KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
         PropertyChangeMask);
 
-    wxAddWindowToTable(window, (wxWindow*) this);
+    wxAddWindowToTable( xwindow, (wxWindow*) this );
 
     // Is a subwindow, so map immediately
     m_isShown = TRUE;
-    XMapWindow(wxGlobalDisplay(), window);
+    XMapWindow( xdisplay, xwindow );
 
     // Without this, the cursor may not be restored properly (e.g. in splitter
     // sample).
     SetCursor(*wxSTANDARD_CURSOR);
     SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
+    
+    // Set background to None which will prevent X11 from clearing the
+    // background comletely.
+    XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
 
     // Don't call this, it can have nasty repercussions for composite controls,
     // for example
@@ -226,11 +228,11 @@ void wxWindowX11::SetFocus()
     if (wxWindowIsVisible(xwindow))
     {
         XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
-       m_needsInputFocus = FALSE;
+        m_needsInputFocus = FALSE;
     }
     else
     {
-       m_needsInputFocus = TRUE;
+        m_needsInputFocus = TRUE;
     }
 }
 
@@ -994,6 +996,7 @@ void wxWindowX11::Update()
 {
     if (!m_updateRegion.IsEmpty())
     {
+        // Actually send erase and paint events.
         X11SendPaintEvents();
     }
 }
@@ -1010,7 +1013,7 @@ void wxWindowX11::X11SendPaintEvents()
 {
     m_clipPaintRegion = TRUE;
 
-    //    if (!m_clearRegion.IsEmpty())
+    if (!m_clearRegion.IsEmpty())
     {
         wxWindowDC dc( (wxWindow*)this );
         dc.SetClippingRegion( m_clearRegion );
@@ -1020,11 +1023,17 @@ void wxWindowX11::X11SendPaintEvents()
     
         if (!GetEventHandler()->ProcessEvent(erase_event))
         {
+            printf( "Hallo!\n" );
+            Window xwindow = (Window) GetMainWindow();
+            Display *xdisplay = wxGlobalDisplay();
+            GC xgc = XCreateGC( xdisplay, xwindow, 0, NULL );
+            XSetFillStyle( xdisplay, xgc, FillSolid );
+            XSetForeground( xdisplay, xgc, m_backgroundColour.GetPixel() );
             wxRegionIterator upd( m_clearRegion );
             while (upd)
             {
-                XClearArea( wxGlobalDisplay(), (Window) m_mainWidget, 
-                            upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight(), False );
+                XFillRectangle( xdisplay, xwindow, xgc,
+                                upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight() );
                 upd ++;
             }
         }
@@ -1315,16 +1324,16 @@ bool wxWindowX11::SetBackgroundColour(const wxColour& col)
 {
     wxWindowBase::SetBackgroundColour(col);
 
-    if (!GetMainWindow())
-        return FALSE;
-
     Display *xdisplay = (Display*) wxGlobalDisplay();
     int xscreen = DefaultScreen( xdisplay );
     Colormap cm = DefaultColormap( xdisplay, xscreen );
 
-    wxColour colour( col );
-    colour.CalcPixel( (WXColormap) cm );
+    m_backgroundColour.CalcPixel( (WXColormap) cm );
     
+    if (!GetMainWindow())
+        return FALSE;
+
+/*
     XSetWindowAttributes attrib;
     attrib.background_pixel = colour.GetPixel();
 
@@ -1332,6 +1341,7 @@ bool wxWindowX11::SetBackgroundColour(const wxColour& col)
         (Window) GetMainWindow(),
         CWBackPixel,
         & attrib);
+*/
 
     return TRUE;
 }