]> git.saurik.com Git - wxWidgets.git/blobdiff - src/x11/app.cpp
fixed more printf() warnings
[wxWidgets.git] / src / x11 / app.cpp
index e923a61920f72c90864d4604adf16555875c7897..42749948e2e9a0b0bc52bd78375fc31c815b3b2e 100644 (file)
@@ -399,17 +399,21 @@ wxApp::wxApp()
     m_showIconic = FALSE;
     m_initialSize = wxDefaultSize;
     
     m_showIconic = FALSE;
     m_initialSize = wxDefaultSize;
     
+#if !wxUSE_NANOX
     m_visualColormap = NULL;
     m_colorCube = NULL;
     m_visualColormap = NULL;
     m_colorCube = NULL;
+#endif
 }
 
 wxApp::~wxApp()
 {
 }
 
 wxApp::~wxApp()
 {
+#if !wxUSE_NANOX
     if (m_colorCube)
         free( m_colorCube );
         
     if (m_visualColormap)
         delete [] (XColor*)m_visualColormap;
     if (m_colorCube)
         free( m_colorCube );
         
     if (m_visualColormap)
         delete [] (XColor*)m_visualColormap;
+#endif
 }
 
 bool wxApp::Initialized()
 }
 
 bool wxApp::Initialized()
@@ -505,7 +509,7 @@ bool wxApp::ProcessXEvent(WXEvent* _event)
     {
         case Expose:
         {
     {
         case Expose:
         {
-#if wxUSE_TWO_WINDOWS
+#if wxUSE_TWO_WINDOWS && !wxUSE_NANOX
             if (event->xexpose.window != (Window)win->GetClientWindow())
             {
                 XEvent tmp_event;
             if (event->xexpose.window != (Window)win->GetClientWindow())
             {
                 XEvent tmp_event;
@@ -564,9 +568,9 @@ bool wxApp::ProcessXEvent(WXEvent* _event)
         {
             printf( "GraphicExpose event\n" );
 
         {
             printf( "GraphicExpose event\n" );
 
-            // wxLogDebug( "GraphicsExpose from %s", win->GetName().c_str(),
-            //                              event->xgraphicsexpose.x, event->xgraphicsexpose.y,
-            //                              event->xgraphicsexpose.width, event->xgraphicsexpose.height);
+            wxLogTrace( _T("expose"), _T("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->GetUpdateRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
                                           event->xgraphicsexpose.width, event->xgraphicsexpose.height);
@@ -754,6 +758,15 @@ bool wxApp::ProcessXEvent(WXEvent* _event)
                     g_prevFocus = wxWindow::FindFocus();
                     g_nextFocus = win;
 
                     g_prevFocus = wxWindow::FindFocus();
                     g_nextFocus = win;
 
+                    wxLogTrace( _T("focus"), _T("About to call SetFocus on %s of type %s due to button press"), win->GetName().c_str(), win->GetClassInfo()->GetClassName() );
+
+                    // Record the fact that this window is
+                    // getting the focus, because we'll need to
+                    // check if its parent is getting a bogus
+                    // focus and duly ignore it.
+                    // TODO: may need to have this code in SetFocus, too.
+                    extern wxWindow* g_GettingFocus;
+                    g_GettingFocus = win;
                     win->SetFocus();
                 }
             }
                     win->SetFocus();
                 }
             }
@@ -777,14 +790,26 @@ bool wxApp::ProcessXEvent(WXEvent* _event)
                     (event->xfocus.mode == NotifyNormal))
 #endif
                 {
                     (event->xfocus.mode == NotifyNormal))
 #endif
                 {
-                    // wxLogDebug( "FocusIn from %s of type %s", win->GetName().c_str(), win->GetClassInfo()->GetClassName() );
-
-                    wxFocusEvent focusEvent(wxEVT_SET_FOCUS, win->GetId());
-                    focusEvent.SetEventObject(win);
-                    focusEvent.SetWindow( g_prevFocus );
-                    g_prevFocus = NULL;
+                    wxLogTrace( _T("focus"), _T("FocusIn from %s of type %s"), win->GetName().c_str(), win->GetClassInfo()->GetClassName() );
+                    
+                    extern wxWindow* g_GettingFocus;
+                    if (g_GettingFocus && g_GettingFocus->GetParent() == win)
+                    {
+                        // Ignore this, this can be a spurious FocusIn
+                        // caused by a child having its focus set.
+                        g_GettingFocus = NULL;
+                        wxLogTrace( _T("focus"), _T("FocusIn from %s of type %s being deliberately ignored"), win->GetName().c_str(), win->GetClassInfo()->GetClassName() );
+                        return TRUE;
+                    }
+                    else
+                    {
+                        wxFocusEvent focusEvent(wxEVT_SET_FOCUS, win->GetId());
+                        focusEvent.SetEventObject(win);
+                        focusEvent.SetWindow( g_prevFocus );
+                        g_prevFocus = NULL;
 
 
-                    return win->GetEventHandler()->ProcessEvent(focusEvent);
+                        return win->GetEventHandler()->ProcessEvent(focusEvent);
+                    }
                 }
                 return FALSE;
                 break;
                 }
                 return FALSE;
                 break;
@@ -796,7 +821,7 @@ bool wxApp::ProcessXEvent(WXEvent* _event)
                     (event->xfocus.mode == NotifyNormal))
 #endif
                 {
                     (event->xfocus.mode == NotifyNormal))
 #endif
                 {
-                    // wxLogDebug( "FocusOut from %s of type %s", win->GetName().c_str(), win->GetClassInfo()->GetClassName() );
+                    wxLogTrace( _T("focus"), _T("FocusOut from %s of type %s"), win->GetName().c_str(), win->GetClassInfo()->GetClassName() );
 
                     wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId());
                     focusEvent.SetEventObject(win);
 
                     wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId());
                     focusEvent.SetEventObject(win);
@@ -920,8 +945,6 @@ bool wxApp::SendIdleEvents(wxWindow* win)
 
     win->GetEventHandler()->ProcessEvent(event);
 
 
     win->GetEventHandler()->ProcessEvent(event);
 
-    win->OnInternalIdle();
-
     if (event.MoreRequested())
         needMore = TRUE;
 
     if (event.MoreRequested())
         needMore = TRUE;
 
@@ -935,6 +958,8 @@ bool wxApp::SendIdleEvents(wxWindow* win)
         node = node->Next();
     }
 
         node = node->Next();
     }
 
+    win->OnInternalIdle();
+
     return needMore;
 }
 
     return needMore;
 }
 
@@ -989,6 +1014,7 @@ bool wxApp::OnInitGui()
 
     m_maxRequestSize = XMaxRequestSize( (Display*) wxApp::GetDisplay() );
 
 
     m_maxRequestSize = XMaxRequestSize( (Display*) wxApp::GetDisplay() );
 
+#if !wxUSE_NANOX
     // Get info about the current visual. It is enough
     // to do this once here unless we support different
     // visuals, displays and screens. Given that wxX11
     // Get info about the current visual. It is enough
     // to do this once here unless we support different
     // visuals, displays and screens. Given that wxX11
@@ -1082,6 +1108,7 @@ bool wxApp::OnInitGui()
             }
         }
     }
             }
         }
     }
+#endif
     
     return TRUE;
 }
     
     return TRUE;
 }
@@ -1192,12 +1219,14 @@ bool wxApp::Yield(bool onlyIfNeeded)
     return TRUE;
 }
 
     return TRUE;
 }
 
-void wxApp::OnAssert(const wxChar *file, int line, const wxChar *msg)
+#ifdef __WXDEBUG__
+
+void wxApp::OnAssert(const wxChar *file, int line, const wxChar* cond, const wxChar *msg)
 {
     // While the GUI isn't working that well, just print out the
     // message.
 {
     // While the GUI isn't working that well, just print out the
     // message.
-#if 0
-    wxAppBase::OnAssert(file, line, msg);
+#if 1
+    wxAppBase::OnAssert(file, line, cond, msg);
 #else
     wxString msg2;
     msg2.Printf("At file %s:%d: %s", file, line, msg);
 #else
     wxString msg2;
     msg2.Printf("At file %s:%d: %s", file, line, msg);
@@ -1205,3 +1234,5 @@ void wxApp::OnAssert(const wxChar *file, int line, const wxChar *msg)
 #endif
 }
 
 #endif
 }
 
+#endif // __WXDEBUG__
+