]> git.saurik.com Git - wxWidgets.git/blobdiff - src/x11/app.cpp
don't give error messages if ws2_32.dll is not available in wxGetHostName()
[wxWidgets.git] / src / x11 / app.cpp
index 87fcdb4ea1792c699228ddba9c61c00437f1aad2..306e7b4081b09d192ec2b512d04698c03cc4bd91 100644 (file)
@@ -9,7 +9,7 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
     #pragma implementation "app.h"
 #endif
 
     #pragma implementation "app.h"
 #endif
 
@@ -88,7 +88,7 @@ WXDisplay *wxApp::ms_display = NULL;
 IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
 
 BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
 IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
 
 BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
-    EVT_IDLE(wxApp::OnIdle)
+    EVT_IDLE(wxAppBase::OnIdle)
 END_EVENT_TABLE()
 
 bool wxApp::Initialize(int& argc, wxChar **argv)
 END_EVENT_TABLE()
 
 bool wxApp::Initialize(int& argc, wxChar **argv)
@@ -98,7 +98,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
     gs_pfnXErrorHandler = XSetErrorHandler( wxXErrorHandler );
 #endif // __WXDEBUG__
 
     gs_pfnXErrorHandler = XSetErrorHandler( wxXErrorHandler );
 #endif // __WXDEBUG__
 
-    char *displayName = NULL;
+    wxString displayName;
     bool syncDisplay = FALSE;
 
     int argcOrig = argc;
     bool syncDisplay = FALSE;
 
     int argcOrig = argc;
@@ -126,7 +126,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
                 if (wxSscanf(argv[i], _T("%dx%d"), &w, &h) != 2)
                 {
                     wxLogError( _("Invalid geometry specification '%s'"),
                 if (wxSscanf(argv[i], _T("%dx%d"), &w, &h) != 2)
                 {
                     wxLogError( _("Invalid geometry specification '%s'"),
-                                wxString::FromAscii(argv[i]).c_str() );
+                                wxString(argv[i]).c_str() );
                 }
                 else
                 {
                 }
                 else
                 {
@@ -166,7 +166,11 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
     }
 
     // X11 display stuff
     }
 
     // X11 display stuff
-    Display *xdisplay = XOpenDisplay( displayName );
+    Display *xdisplay;
+    if ( displayName.empty() )
+        xdisplay = XOpenDisplay( NULL );
+    else
+        xdisplay = XOpenDisplay( displayName.ToAscii() );
     if (!xdisplay)
     {
         wxLogError( _("wxWindows could not open display. Exiting.") );
     if (!xdisplay)
     {
         wxLogError( _("wxWindows could not open display. Exiting.") );
@@ -224,7 +228,6 @@ wxApp::wxApp()
     m_mainColormap = (WXColormap) NULL;
     m_topLevelWidget = (WXWindow) NULL;
     m_maxRequestSize = 0;
     m_mainColormap = (WXColormap) NULL;
     m_topLevelWidget = (WXWindow) NULL;
     m_maxRequestSize = 0;
-    m_mainLoop = NULL;
     m_showIconic = FALSE;
     m_initialSize = wxDefaultSize;
 
     m_showIconic = FALSE;
     m_initialSize = wxDefaultSize;
 
@@ -240,26 +243,6 @@ wxApp::~wxApp()
 #endif
 }
 
 #endif
 }
 
-bool wxApp::Initialized()
-{
-    if (GetTopWindow())
-        return TRUE;
-    else
-        return FALSE;
-}
-
-int wxApp::MainLoop()
-{
-    int rt;
-    m_mainLoop = new wxEventLoop;
-
-    rt = m_mainLoop->Run();
-
-    delete m_mainLoop;
-    m_mainLoop = NULL;
-    return rt;
-}
-
 #if !wxUSE_NANOX
 //-----------------------------------------------------------------------
 // X11 predicate function for exposure compression
 #if !wxUSE_NANOX
 //-----------------------------------------------------------------------
 // X11 predicate function for exposure compression
@@ -392,8 +375,6 @@ bool wxApp::ProcessXEvent(WXEvent* _event)
 #if !wxUSE_NANOX
         case GraphicsExpose:
         {
 #if !wxUSE_NANOX
         case GraphicsExpose:
         {
-            printf( "GraphicExpose event\n" );
-
             wxLogTrace( _T("expose"), _T("GraphicsExpose from %s"), win->GetName().c_str());
 
             win->GetUpdateRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
             wxLogTrace( _T("expose"), _T("GraphicsExpose from %s"), win->GetName().c_str());
 
             win->GetUpdateRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
@@ -611,97 +592,59 @@ bool wxApp::ProcessXEvent(WXEvent* _event)
             return win->GetEventHandler()->ProcessEvent( wxevent );
         }
         case FocusIn:
             return win->GetEventHandler()->ProcessEvent( wxevent );
         }
         case FocusIn:
-            {
 #if !wxUSE_NANOX
 #if !wxUSE_NANOX
-                if ((event->xfocus.detail != NotifyPointer) &&
-                    (event->xfocus.mode == NotifyNormal))
+            if ((event->xfocus.detail != NotifyPointer) &&
+                (event->xfocus.mode == NotifyNormal))
 #endif
 #endif
+            {
+                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
                 {
                 {
-                    wxLogTrace( _T("focus"), _T("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;
 
 
-                    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;
+
         case FocusOut:
         case FocusOut:
-            {
 #if !wxUSE_NANOX
 #if !wxUSE_NANOX
-                if ((event->xfocus.detail != NotifyPointer) &&
-                    (event->xfocus.mode == NotifyNormal))
+            if ((event->xfocus.detail != NotifyPointer) &&
+                (event->xfocus.mode == NotifyNormal))
 #endif
 #endif
-                {
-                    wxLogTrace( _T("focus"), _T("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);
-                    focusEvent.SetWindow( g_nextFocus );
-                    g_nextFocus = NULL;
-                    return win->GetEventHandler()->ProcessEvent(focusEvent);
-                }
-                return FALSE;
-                break;
+                wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId());
+                focusEvent.SetEventObject(win);
+                focusEvent.SetWindow( g_nextFocus );
+                g_nextFocus = NULL;
+                return win->GetEventHandler()->ProcessEvent(focusEvent);
             }
             }
-        default:
-        {
+            return FALSE;
+
 #ifdef __WXDEBUG__
 #ifdef __WXDEBUG__
+        default:
             //wxString eventName = wxGetXEventName(XEvent& event);
             //wxLogDebug(wxT("Event %s not handled"), eventName.c_str());
             //wxString eventName = wxGetXEventName(XEvent& event);
             //wxLogDebug(wxT("Event %s not handled"), eventName.c_str());
-#endif
-            return FALSE;
             break;
             break;
-        }
+#endif // __WXDEBUG__
     }
     }
-    return FALSE;
-}
-
-// Returns TRUE if more time is needed.
-// Note that this duplicates wxEventLoopImpl::SendIdleEvent
-// but ProcessIdle may be needed by apps, so is kept.
-bool wxApp::ProcessIdle()
-{
-    wxIdleEvent event;
-    event.SetEventObject(this);
-    ProcessEvent(event);
-
-    wxUpdateUIEvent::ResetUpdateTime();
-    
-    return event.MoreRequested();
-}
-
-void wxApp::ExitMainLoop()
-{
-    if (m_mainLoop)
-        m_mainLoop->Exit(0);
-}
-
-// Is a message/event pending?
-bool wxApp::Pending()
-{
-    return wxEventLoop::GetActive()->Pending();
-}
 
 
-// Dispatch a message.
-void wxApp::Dispatch()
-{
-    wxEventLoop::GetActive()->Dispatch();
+    return FALSE;
 }
 
 // This should be redefined in a derived class for
 }
 
 // This should be redefined in a derived class for
@@ -714,32 +657,6 @@ bool wxApp::HandlePropertyChange(WXEvent *event)
     return FALSE;
 }
 
     return FALSE;
 }
 
-void wxApp::OnIdle(wxIdleEvent& event)
-{
-    static bool s_inOnIdle = FALSE;
-
-    // Avoid recursion (via ProcessEvent default case)
-    if (s_inOnIdle)
-        return;
-
-    s_inOnIdle = TRUE;
-
-    // Resend in the main thread events which have been prepared in other
-    // threads
-    ProcessPendingEvents();
-
-    // 'Garbage' collection of windows deleted with Close()
-    DeletePendingObjects();
-
-    // Send OnIdle events to all windows
-    bool needMore = SendIdleEvents();
-
-    if (needMore)
-        event.RequestMore(TRUE);
-
-    s_inOnIdle = FALSE;
-}
-
 void wxApp::WakeUpIdle()
 {
     // TODO: use wxMotif implementation?
 void wxApp::WakeUpIdle()
 {
     // TODO: use wxMotif implementation?
@@ -748,51 +665,6 @@ void wxApp::WakeUpIdle()
 }
 
 
 }
 
 
-// Send idle event to all top-level windows
-bool wxApp::SendIdleEvents()
-{
-    bool needMore = FALSE;
-
-    wxWindowList::Node* node = wxTopLevelWindows.GetFirst();
-    while (node)
-    {
-        wxWindow* win = node->GetData();
-        if (SendIdleEvents(win))
-            needMore = TRUE;
-        node = node->GetNext();
-    }
-
-    return needMore;
-}
-
-// Send idle event to window and all subwindows
-bool wxApp::SendIdleEvents(wxWindow* win)
-{
-    bool needMore = FALSE;
-
-    wxIdleEvent event;
-    event.SetEventObject(win);
-
-    win->GetEventHandler()->ProcessEvent(event);
-
-    if (event.MoreRequested())
-        needMore = TRUE;
-
-    wxWindowListNode* node = win->GetChildren().GetFirst();
-    while (node)
-    {
-        wxWindow* win = (wxWindow*) node->GetData();
-        if (SendIdleEvents(win))
-            needMore = TRUE;
-
-        node = node->GetNext();
-    }
-
-    win->OnInternalIdle();
-
-    return needMore;
-}
-
 // Create display, and other initialization
 bool wxApp::OnInitGui()
 {
 // Create display, and other initialization
 bool wxApp::OnInitGui()
 {
@@ -870,7 +742,7 @@ WXColormap wxApp::GetMainColormap(WXDisplay* display)
 
 Window wxGetWindowParent(Window window)
 {
 
 Window wxGetWindowParent(Window window)
 {
-    wxASSERT_MSG( window, "invalid window" );
+    wxASSERT_MSG( window, _T("invalid window") );
 
     return (Window) 0;
 
 
     return (Window) 0;