]> git.saurik.com Git - wxWidgets.git/commitdiff
wxX11:
authorRobert Roebling <robert@roebling.de>
Wed, 13 Feb 2002 16:43:18 +0000 (16:43 +0000)
committerRobert Roebling <robert@roebling.de>
Wed, 13 Feb 2002 16:43:18 +0000 (16:43 +0000)
    INtroduced OnInternalIdle as per wxGTK so that users
      cannot as easily lill the internals.
    Fixed pop-up transient window.
    Removed some #if 0 here and there.
    Made refresh code work in idle instead of directly.

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

include/wx/x11/window.h
src/gtk/app.cpp
src/gtk1/app.cpp
src/x11/app.cpp
src/x11/dcclient.cpp
src/x11/popupwin.cpp
src/x11/window.cpp

index 6693eaf5178b95c996f12c63759c1faf470fab2e..f79d378d50fb004e0a1a208e8f967ff8a0f8a985 100644 (file)
@@ -134,10 +134,15 @@ public:
     // smaller
     virtual wxPoint GetClientAreaOrigin() const;
     
     // smaller
     virtual wxPoint GetClientAreaOrigin() const;
     
-protected:
-    // event handlers (not virtual by design)
-    void OnIdle(wxIdleEvent& event);
+    // I don't want users to override what's done in idle so everything that
+    // has to be done in idle time in order for wxX11 to work is done in
+    // OnInternalIdle
+    virtual void OnInternalIdle();
+    
+    // For compatibility across platforms (not in event table)
+    void OnIdle(wxIdleEvent& WXUNUSED(event)) {}
     
     
+protected:
     // Makes an adjustment to the window position (for example, a frame that has
     // a toolbar that it manages itself).
     virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
     // Makes an adjustment to the window position (for example, a frame that has
     // a toolbar that it manages itself).
     virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
index 6b0b5276dfd766eae63fba54db2805b872a8ee6a..b25fce3b1ccc1364019e8e110bbccc1532d804e8 100644 (file)
@@ -515,7 +515,8 @@ bool wxApp::SendIdleEvents( wxWindow* win )
 
         node = node->Next();
     }
 
         node = node->Next();
     }
-    return needMore ;
+    
+    return needMore;
 }
 
 int wxApp::MainLoop()
 }
 
 int wxApp::MainLoop()
index 6b0b5276dfd766eae63fba54db2805b872a8ee6a..b25fce3b1ccc1364019e8e110bbccc1532d804e8 100644 (file)
@@ -515,7 +515,8 @@ bool wxApp::SendIdleEvents( wxWindow* win )
 
         node = node->Next();
     }
 
         node = node->Next();
     }
-    return needMore ;
+    
+    return needMore;
 }
 
 int wxApp::MainLoop()
 }
 
 int wxApp::MainLoop()
index 6b85093ad0bd4c724b2903f8143e571e65149b65..62cb336b789a4f0c5d9bf18a5dac9f65954d6b03 100644 (file)
@@ -446,12 +446,9 @@ void wxApp::ProcessXEvent(WXEvent* _event)
         {
             if (win)
             {
         {
             if (win)
             {
+                // Schedule update for later
                 win->GetUpdateRegion().Union( event->xexpose.x, event->xexpose.y,
                                               event->xexpose.width, event->xexpose.height);
                 win->GetUpdateRegion().Union( event->xexpose.x, event->xexpose.y,
                                               event->xexpose.width, event->xexpose.height);
-                if (event->xexpose.count == 0)
-                {
-                    win->X11SendPaintEvents();  // TODO let an idle handler do that
-                }
             }
 
             return;
             }
 
             return;
@@ -547,41 +544,28 @@ void wxApp::HandlePropertyChange(WXEvent *event)
 
 void wxApp::OnIdle(wxIdleEvent& event)
 {
 
 void wxApp::OnIdle(wxIdleEvent& event)
 {
-    static bool inOnIdle = FALSE;
+    static bool s_inOnIdle = FALSE;
 
     // Avoid recursion (via ProcessEvent default case)
 
     // Avoid recursion (via ProcessEvent default case)
-    if (inOnIdle)
+    if (s_inOnIdle)
         return;
 
         return;
 
-    inOnIdle = TRUE;
-
-    // If there are pending events, we must process them: pending events
-    // are either events to the threads other than main or events posted
-    // with wxPostEvent() functions
-    // GRG: I have moved this here so that all pending events are processed
-    //   before starting to delete any objects. This behaves better (in
-    //   particular, wrt wxPostEvent) and is coherent with wxGTK's current
-    //   behaviour. Also removed the '#if wxUSE_THREADS' around it.
-    //  Changed Mar/2000 before 2.1.14
+    s_inOnIdle = TRUE;
 
 
-    // Flush pending events.
+    // Resend in the main thread events which have been prepared in other
+    // threads
     ProcessPendingEvents();
 
     ProcessPendingEvents();
 
-    // 'Garbage' collection of windows deleted with Close().
+    // 'Garbage' collection of windows deleted with Close()
     DeletePendingObjects();
 
     DeletePendingObjects();
 
-    // flush the logged messages if any
-    wxLog *pLog = wxLog::GetActiveTarget();
-    if ( pLog != NULL && pLog->HasPendingMessages() )
-        pLog->Flush();
-
     // Send OnIdle events to all windows
     bool needMore = SendIdleEvents();
 
     if (needMore)
         event.RequestMore(TRUE);
 
     // Send OnIdle events to all windows
     bool needMore = SendIdleEvents();
 
     if (needMore)
         event.RequestMore(TRUE);
 
-    inOnIdle = FALSE;
+    s_inOnIdle = FALSE;
 }
 
 void wxWakeUpIdle()
 }
 
 void wxWakeUpIdle()
@@ -615,7 +599,10 @@ bool wxApp::SendIdleEvents(wxWindow* win)
 
     wxIdleEvent event;
     event.SetEventObject(win);
 
     wxIdleEvent event;
     event.SetEventObject(win);
-    win->ProcessEvent(event);
+
+    win->GetEventHandler()->ProcessEvent(event);
+
+    win->OnInternalIdle();
 
     if (event.MoreRequested())
         needMore = TRUE;
 
     if (event.MoreRequested())
         needMore = TRUE;
@@ -629,7 +616,8 @@ bool wxApp::SendIdleEvents(wxWindow* win)
 
         node = node->Next();
     }
 
         node = node->Next();
     }
-    return needMore ;
+    
+    return needMore;
 }
 
 void wxApp::DeletePendingObjects()
 }
 
 void wxApp::DeletePendingObjects()
index c00bb29e357c26182a34e1fbf6a9c0e8a37c69c0..286375fa0e272b12f46140e9cd1320b200dcf9bf 100644 (file)
@@ -225,7 +225,6 @@ void wxWindowDC::SetUpDC()
         m_textGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxTEXT_SCREEN );
         m_bgGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxBG_SCREEN );
     }
         m_textGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxTEXT_SCREEN );
         m_bgGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxBG_SCREEN );
     }
-#if 0
     else
     if (m_isMemDC && (((wxMemoryDC*)this)->m_selected.GetDepth() == 1))
     {
     else
     if (m_isMemDC && (((wxMemoryDC*)this)->m_selected.GetDepth() == 1))
     {
@@ -234,7 +233,6 @@ void wxWindowDC::SetUpDC()
         m_textGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxTEXT_MONO );
         m_bgGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxBG_MONO );
     }
         m_textGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxTEXT_MONO );
         m_bgGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxBG_MONO );
     }
-#endif
     else
     {
         m_penGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxPEN_COLOUR );
     else
     {
         m_penGC = (WXGC*) wxGetPoolGC( (Window) m_window, wxPEN_COLOUR );
@@ -342,8 +340,6 @@ void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
 
         CalcBoundingBox(x1, y1);
         CalcBoundingBox(x2, y2);
 
         CalcBoundingBox(x1, y1);
         CalcBoundingBox(x2, y2);
-
-       wxLogDebug("Drawing line at %d, %d -> %d, %d", XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) );
     }
 }
 
     }
 }
 
@@ -751,7 +747,6 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h
 
     CalcBoundingBox( x, y );
     CalcBoundingBox( x + width, y + height );
 
     CalcBoundingBox( x, y );
     CalcBoundingBox( x + width, y + height );
-    wxLogDebug("Drawing rectangle at %d, %d (%dx%d)", x, y, width, height);
 }
 
 void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius )
 }
 
 void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius )
@@ -1535,14 +1530,14 @@ void wxWindowDC::SetBrush( const wxBrush &brush )
         else
         {
             XSetFillStyle( (Display*) m_display, (GC) m_brushGC, FillStippled );
         else
         {
             XSetFillStyle( (Display*) m_display, (GC) m_brushGC, FillStippled );
-//            XSetStipple( (Display*) m_display, (GC) m_brushGC, (Pixmap) m_brush.GetStipple()->GetBitmap() );
+            XSetStipple( (Display*) m_display, (GC) m_brushGC, (Pixmap) m_brush.GetStipple()->GetBitmap() );
         }
     }
 
     if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
     {
         XSetFillStyle( (Display*) m_display, (GC) m_textGC, FillOpaqueStippled );
         }
     }
 
     if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
     {
         XSetFillStyle( (Display*) m_display, (GC) m_textGC, FillOpaqueStippled );
-//        XSetStipple( (Display*) m_display, (GC) m_textGC, (Pixmap) m_brush.GetStipple()->GetMask()->GetBitmap() );
+        XSetStipple( (Display*) m_display, (GC) m_textGC, (Pixmap) m_brush.GetStipple()->GetMask()->GetBitmap() );
     }
 
     if (IS_HATCH(m_brush.GetStyle()))
     }
 
     if (IS_HATCH(m_brush.GetStyle()))
@@ -1586,7 +1581,7 @@ void wxWindowDC::SetBackground( const wxBrush &brush )
         else
         {
             XSetFillStyle( (Display*) m_display, (GC) m_bgGC, FillStippled );
         else
         {
             XSetFillStyle( (Display*) m_display, (GC) m_bgGC, FillStippled );
-//            XSetStipple( (Display*) m_display, (GC) m_bgGC, (Pixmap) m_backgroundBrush.GetStipple()->GetBitmap() );
+            XSetStipple( (Display*) m_display, (GC) m_bgGC, (Pixmap) m_backgroundBrush.GetStipple()->GetBitmap() );
         }
     }
 
         }
     }
 
index 4c62f44df5b18c711f645b2eed179b12f4f5eda0..debfbf577ba383558178b3288dc311c69661073c 100644 (file)
@@ -62,13 +62,12 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
     
     long xattributes_mask =
         CWOverrideRedirect |
     
     long xattributes_mask =
         CWOverrideRedirect |
+        CWSaveUnder |
         CWBorderPixel | CWBackPixel;
     xattributes.background_pixel = BlackPixel( xdisplay, xscreen );
     xattributes.border_pixel = BlackPixel( xdisplay, xscreen );
         CWBorderPixel | CWBackPixel;
     xattributes.background_pixel = BlackPixel( xdisplay, xscreen );
     xattributes.border_pixel = BlackPixel( xdisplay, xscreen );
-
-    // Trying True in order to stop WM decorating it
-    //xattributes.override_redirect = False;
-    xattributes.override_redirect = TRUE;
+    xattributes.override_redirect = True;
+    xattributes.save_under = True;
 
     Window xwindow = XCreateWindow( xdisplay, xparent, pos.x, pos.y, size.x, size.y, 
        0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes );
 
     Window xwindow = XCreateWindow( xdisplay, xparent, pos.x, pos.y, size.x, size.y, 
        0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes );
index 1983d4bb41770e1c7d8d762832debed691c21b30..89ba9d056a6b7f6a9688852592ecae56343d91c6 100644 (file)
 
 #include <string.h>
 
 
 #include <string.h>
 
-// ----------------------------------------------------------------------------
-// constants
-// ----------------------------------------------------------------------------
-
-static const int SCROLL_MARGIN = 4;
-
 // ----------------------------------------------------------------------------
 // global variables for this module
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // 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)
 
 BEGIN_EVENT_TABLE(wxWindowX11, wxWindowBase)
     EVT_SYS_COLOUR_CHANGED(wxWindowX11::OnSysColourChanged)
-    EVT_IDLE(wxWindowX11::OnIdle)
 END_EVENT_TABLE()
 
 // ============================================================================
 END_EVENT_TABLE()
 
 // ============================================================================
@@ -895,13 +888,12 @@ void wxWindowX11::GetTextExtent(const wxString& string,
                              int *descent, int *externalLeading,
                              const wxFont *theFont) const
 {
                              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;
 
     int direction, ascent, descent2;
     XCharStruct overall;
@@ -913,7 +905,7 @@ void wxWindowX11::GetTextExtent(const wxString& string,
         &ascent, &descent2, &overall);
 #endif
 
         &ascent, &descent2, &overall);
 #endif
 
-    XTextExtents((XFontStruct*) pFontStruct, string, slen,
+    XTextExtents((XFontStruct*) pFontStruct, string.c_str(), slen,
                  &direction, &ascent, &descent2, &overall);
 
     if ( x )
                  &direction, &ascent, &descent2, &overall);
 
     if ( x )
@@ -958,16 +950,13 @@ void wxWindowX11::Refresh(bool eraseBack, const wxRect *rect)
     }
     else
     {
     }
     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 );
     }
             
         // 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()
 }
 
 void wxWindowX11::Update()
@@ -1019,6 +1008,8 @@ void wxWindowX11::X11SendPaintEvents()
     paint_event.SetEventObject( this );
     GetEventHandler()->ProcessEvent( paint_event );
 
     paint_event.SetEventObject( this );
     GetEventHandler()->ProcessEvent( paint_event );
 
+    m_updateRegion.Clear();
+    
     m_clipPaintRegion = FALSE;
 }
 
     m_clipPaintRegion = FALSE;
 }
 
@@ -1045,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();
     // This calls the UI-update mechanism (querying windows for
     // menu/toolbar/control state information)
     UpdateWindowUI();