1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "app.h"
19 #include "wx/gdicmn.h"
21 #include "wx/dialog.h"
23 #include "wx/module.h"
24 #include "wx/memory.h"
27 #include "wx/evtloop.h"
29 #include "wx/filename.h"
32 #include "wx/univ/theme.h"
33 #include "wx/univ/renderer.h"
36 #include "wx/thread.h"
39 #include "wx/x11/private.h"
43 //------------------------------------------------------------------------
45 //------------------------------------------------------------------------
47 extern wxList wxPendingDelete
;
49 wxHashTable
*wxWidgetHashTable
= NULL
;
50 wxHashTable
*wxClientWidgetHashTable
= NULL
;
52 // This is set within wxEntryStart -- too early on
53 // to put these in wxTheApp
54 static bool g_showIconic
= FALSE
;
55 static wxSize g_initialSize
= wxDefaultSize
;
57 // This is required for wxFocusEvent::SetWindow(). It will only
58 // work for focus events which we provoke ourselves (by calling
59 // SetFocus()). It will not work for those events, which X11
61 static wxWindow
*g_nextFocus
= NULL
;
62 static wxWindow
*g_prevFocus
= NULL
;
64 //------------------------------------------------------------------------
66 //------------------------------------------------------------------------
69 typedef int (*XErrorHandlerFunc
)(Display
*, XErrorEvent
*);
71 XErrorHandlerFunc gs_pfnXErrorHandler
= 0;
73 static int wxXErrorHandler(Display
*dpy
, XErrorEvent
*xevent
)
75 // just forward to the default handler for now
76 if (gs_pfnXErrorHandler
)
77 return gs_pfnXErrorHandler(dpy
, xevent
);
83 //------------------------------------------------------------------------
85 //------------------------------------------------------------------------
87 long wxApp::sm_lastMessageTime
= 0;
88 WXDisplay
*wxApp::ms_display
= NULL
;
90 IMPLEMENT_DYNAMIC_CLASS(wxApp
, wxEvtHandler
)
92 BEGIN_EVENT_TABLE(wxApp
, wxEvtHandler
)
93 EVT_IDLE(wxApp::OnIdle
)
96 bool wxApp::Initialize()
98 wxClassInfo::InitializeClasses();
101 wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
104 // GL: I'm annoyed ... I don't know where to put this and I don't want to
105 // create a module for that as it's part of the core.
107 wxPendingEventsLocker
= new wxCriticalSection();
110 wxTheColourDatabase
= new wxColourDatabase(wxKEY_STRING
);
111 wxTheColourDatabase
->Initialize();
113 wxInitializeStockLists();
114 wxInitializeStockObjects();
116 wxWidgetHashTable
= new wxHashTable(wxKEY_INTEGER
);
117 wxClientWidgetHashTable
= new wxHashTable(wxKEY_INTEGER
);
119 wxModule::RegisterModules();
120 if (!wxModule::InitializeModules()) return FALSE
;
125 void wxApp::CleanUp()
127 delete wxWidgetHashTable
;
128 wxWidgetHashTable
= NULL
;
129 delete wxClientWidgetHashTable
;
130 wxClientWidgetHashTable
= NULL
;
132 wxModule::CleanUpModules();
134 delete wxTheColourDatabase
;
135 wxTheColourDatabase
= NULL
;
137 wxDeleteStockObjects();
139 wxDeleteStockLists();
144 wxClassInfo::CleanUpClasses();
147 delete wxPendingEvents
;
148 delete wxPendingEventsLocker
;
151 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
152 // At this point we want to check if there are any memory
153 // blocks that aren't part of the wxDebugContext itself,
154 // as a special case. Then when dumping we need to ignore
155 // wxDebugContext, too.
156 if (wxDebugContext::CountObjectsLeft(TRUE
) > 0)
158 wxLogDebug("There were memory leaks.");
159 wxDebugContext::Dump();
160 wxDebugContext::PrintStatistics();
164 // do it as the very last thing because everything else can log messages
165 wxLog::DontCreateOnDemand();
166 // do it as the very last thing because everything else can log messages
167 delete wxLog::SetActiveTarget(NULL
);
170 // NB: argc and argv may be changed here, pass by reference!
171 int wxEntryStart( int& argc
, char *argv
[] )
175 // install the X error handler
176 gs_pfnXErrorHandler
= XSetErrorHandler( wxXErrorHandler
);
178 #endif // __WXDEBUG__
180 char *displayName
= NULL
;
181 bool syncDisplay
= FALSE
;
184 for (i
= 0; i
< argc
; i
++)
186 if (strcmp( argv
[i
], "-display") == 0)
191 displayName
= argv
[i
];
195 else if (strcmp( argv
[i
], "-geometry") == 0)
201 if (sscanf(argv
[i
], "%dx%d", &w
, &h
) != 2)
203 wxLogError( _("Invalid geometry specification '%s'"), wxString::FromAscii(argv
[i
]).c_str() );
207 g_initialSize
= wxSize(w
, h
);
212 else if (strcmp( argv
[i
], "-sync") == 0)
217 else if (strcmp( argv
[i
], "-iconic") == 0)
227 Display
* xdisplay
= XOpenDisplay( displayName
);
230 wxLogError( _("wxWindows could not open display. Exiting.") );
235 XSynchronize(xdisplay
, True
);
237 wxApp::ms_display
= (WXDisplay
*) xdisplay
;
239 XSelectInput( xdisplay
, XDefaultRootWindow(xdisplay
), PropertyChangeMask
);
242 wxSetDetectableAutoRepeat( TRUE
);
245 // Glib's type system required by Pango
249 if (!wxApp::Initialize())
259 if ( !wxTheApp
->OnInitGui() )
266 int wxEntry( int argc
, char *argv
[] )
268 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
269 // This seems to be necessary since there are 'rogue'
270 // objects present at this point (perhaps global objects?)
271 // Setting a checkpoint will ignore them as far as the
272 // memory checking facility is concerned.
273 // Of course you may argue that memory allocated in globals should be
274 // checked, but this is a reasonable compromise.
275 wxDebugContext::SetCheckpoint();
277 int err
= wxEntryStart(argc
, argv
);
283 if (!wxApp::GetInitializerFunction())
285 printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" );
289 wxTheApp
= (wxApp
*) (* wxApp::GetInitializerFunction()) ();
294 printf( "wxWindows error: wxTheApp == NULL\n" );
298 // Command line argument stuff
299 wxTheApp
->argc
= argc
;
301 wxTheApp
->argv
= new wxChar
*[argc
+1];
303 while (mb_argc
< argc
)
305 wxString tmp
= wxString::FromAscii( argv
[mb_argc
] );
306 wxTheApp
->argv
[mb_argc
] = wxStrdup( tmp
.c_str() );
309 wxTheApp
->argv
[mb_argc
] = (wxChar
*)NULL
;
311 wxTheApp
->argv
= argv
;
314 if (wxTheApp
->argc
> 0)
316 wxFileName
fname( wxTheApp
->argv
[0] );
317 wxTheApp
->SetAppName( fname
.GetName() );
320 wxTheApp
->m_showIconic
= g_showIconic
;
321 wxTheApp
->m_initialSize
= g_initialSize
;
324 retValue
= wxEntryInitGui();
326 // Here frames insert themselves automatically into wxTopLevelWindows by
327 // getting created in OnInit().
330 if ( !wxTheApp
->OnInit() )
336 if (wxTheApp
->Initialized()) retValue
= wxTheApp
->OnRun();
339 // flush the logged messages if any
340 wxLog
*pLog
= wxLog::GetActiveTarget();
341 if ( pLog
!= NULL
&& pLog
->HasPendingMessages() )
344 delete wxLog::SetActiveTarget(new wxLogStderr
); // So dialog boxes aren't used
345 // for further messages
347 if (wxTheApp
->GetTopWindow())
349 delete wxTheApp
->GetTopWindow();
350 wxTheApp
->SetTopWindow(NULL
);
353 wxTheApp
->DeletePendingObjects();
364 // TODO: parse the command line
368 m_mainColormap
= (WXColormap
) NULL
;
369 m_topLevelWidget
= (WXWindow
) NULL
;
370 m_maxRequestSize
= 0;
372 m_showIconic
= FALSE
;
373 m_initialSize
= wxDefaultSize
;
387 bool wxApp::Initialized()
395 int wxApp::MainLoop()
398 m_mainLoop
= new wxEventLoop
;
400 rt
= m_mainLoop
->Run();
408 //-----------------------------------------------------------------------
409 // X11 predicate function for exposure compression
410 //-----------------------------------------------------------------------
415 Bool found_non_matching
;
418 static Bool
expose_predicate (Display
*display
, XEvent
*xevent
, XPointer arg
)
420 wxExposeInfo
*info
= (wxExposeInfo
*) arg
;
422 if (info
->found_non_matching
)
425 if (xevent
->xany
.type
!= Expose
)
427 info
->found_non_matching
= TRUE
;
431 if (xevent
->xexpose
.window
!= info
->window
)
433 info
->found_non_matching
= TRUE
;
442 //-----------------------------------------------------------------------
443 // Processes an X event, returning TRUE if the event was processed.
444 //-----------------------------------------------------------------------
446 bool wxApp::ProcessXEvent(WXEvent
* _event
)
448 XEvent
* event
= (XEvent
*) _event
;
450 wxWindow
* win
= NULL
;
451 Window window
= XEventGetWindow(event
);
453 Window actualWindow
= window
;
456 // Find the first wxWindow that corresponds to this event window
457 // Because we're receiving events after a window
458 // has been destroyed, assume a 1:1 match between
459 // Window and wxWindow, so if it's not in the table,
460 // it must have been destroyed.
462 win
= wxGetWindowFromTable(window
);
465 #if wxUSE_TWO_WINDOWS
466 win
= wxGetClientWindowFromTable(window
);
473 wxString windowClass
= win
->GetClassInfo()->GetClassName();
480 #if wxUSE_TWO_WINDOWS && !wxUSE_NANOX
481 if (event
->xexpose
.window
!= (Window
)win
->GetClientAreaWindow())
485 info
.window
= event
->xexpose
.window
;
486 info
.found_non_matching
= FALSE
;
487 while (XCheckIfEvent( wxGlobalDisplay(), &tmp_event
, expose_predicate
, (XPointer
) &info
))
489 // Don't worry about optimizing redrawing the border etc.
491 win
->NeedUpdateNcAreaInIdle();
496 win
->GetUpdateRegion().Union( XExposeEventGetX(event
), XExposeEventGetY(event
),
497 XExposeEventGetWidth(event
), XExposeEventGetHeight(event
));
498 win
->GetClearRegion().Union( XExposeEventGetX(event
), XExposeEventGetY(event
),
499 XExposeEventGetWidth(event
), XExposeEventGetHeight(event
));
504 info
.window
= event
->xexpose
.window
;
505 info
.found_non_matching
= FALSE
;
506 while (XCheckIfEvent( wxGlobalDisplay(), &tmp_event
, expose_predicate
, (XPointer
) &info
))
508 win
->GetUpdateRegion().Union( tmp_event
.xexpose
.x
, tmp_event
.xexpose
.y
,
509 tmp_event
.xexpose
.width
, tmp_event
.xexpose
.height
);
511 win
->GetClearRegion().Union( tmp_event
.xexpose
.x
, tmp_event
.xexpose
.y
,
512 tmp_event
.xexpose
.width
, tmp_event
.xexpose
.height
);
516 // This simplifies the expose and clear areas to simple
518 win
->GetUpdateRegion() = win
->GetUpdateRegion().GetBox();
519 win
->GetClearRegion() = win
->GetClearRegion().GetBox();
521 // If we only have one X11 window, always indicate
522 // that borders might have to be redrawn.
523 if (win
->GetMainWindow() == win
->GetClientAreaWindow())
524 win
->NeedUpdateNcAreaInIdle();
526 // Only erase background, paint in idle time.
527 win
->SendEraseEvents();
539 printf( "GraphicExpose event\n" );
541 wxLogTrace( _T("expose"), _T("GraphicsExpose from %s"), win
->GetName().c_str());
543 win
->GetUpdateRegion().Union( event
->xgraphicsexpose
.x
, event
->xgraphicsexpose
.y
,
544 event
->xgraphicsexpose
.width
, event
->xgraphicsexpose
.height
);
546 win
->GetClearRegion().Union( event
->xgraphicsexpose
.x
, event
->xgraphicsexpose
.y
,
547 event
->xgraphicsexpose
.width
, event
->xgraphicsexpose
.height
);
549 if (event
->xgraphicsexpose
.count
== 0)
551 // Only erase background, paint in idle time.
552 win
->SendEraseEvents();
562 if (!win
->IsEnabled())
565 wxKeyEvent
keyEvent(wxEVT_KEY_DOWN
);
566 wxTranslateKeyEvent(keyEvent
, win
, window
, event
);
568 // wxLogDebug( "OnKey from %s", win->GetName().c_str() );
570 // We didn't process wxEVT_KEY_DOWN, so send wxEVT_CHAR
571 if (win
->GetEventHandler()->ProcessEvent( keyEvent
))
574 keyEvent
.SetEventType(wxEVT_CHAR
);
575 // Do the translation again, retaining the ASCII
577 wxTranslateKeyEvent(keyEvent
, win
, window
, event
, TRUE
);
578 if (win
->GetEventHandler()->ProcessEvent( keyEvent
))
581 if ( (keyEvent
.m_keyCode
== WXK_TAB
) &&
582 win
->GetParent() && (win
->GetParent()->HasFlag( wxTAB_TRAVERSAL
)) )
584 wxNavigationKeyEvent new_event
;
585 new_event
.SetEventObject( win
->GetParent() );
586 /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
587 new_event
.SetDirection( (keyEvent
.m_keyCode
== WXK_TAB
) );
588 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
589 new_event
.SetWindowChange( keyEvent
.ControlDown() );
590 new_event
.SetCurrentFocus( win
);
591 return win
->GetParent()->GetEventHandler()->ProcessEvent( new_event
);
598 if (!win
->IsEnabled())
601 wxKeyEvent
keyEvent(wxEVT_KEY_UP
);
602 wxTranslateKeyEvent(keyEvent
, win
, window
, event
);
604 return win
->GetEventHandler()->ProcessEvent( keyEvent
);
606 case ConfigureNotify
:
609 if (event
->update
.utype
== GR_UPDATE_SIZE
)
612 if (win
->IsTopLevel())
614 wxTopLevelWindow
*tlw
= (wxTopLevelWindow
*) win
;
615 tlw
->SetConfigureGeometry( XConfigureEventGetX(event
), XConfigureEventGetY(event
),
616 XConfigureEventGetWidth(event
), XConfigureEventGetHeight(event
) );
619 if (win
->IsTopLevel() && win
->IsShown())
621 wxTopLevelWindowX11
*tlw
= (wxTopLevelWindowX11
*) win
;
622 tlw
->SetNeedResizeInIdle();
626 wxSizeEvent
sizeEvent( wxSize(XConfigureEventGetWidth(event
), XConfigureEventGetHeight(event
)), win
->GetId() );
627 sizeEvent
.SetEventObject( win
);
629 return win
->GetEventHandler()->ProcessEvent( sizeEvent
);
638 //wxLogDebug("PropertyNotify: %s", windowClass.c_str());
639 return HandlePropertyChange(_event
);
643 if (!win
->IsEnabled())
646 Atom wm_delete_window
= XInternAtom(wxGlobalDisplay(), "WM_DELETE_WINDOW", True
);
647 Atom wm_protocols
= XInternAtom(wxGlobalDisplay(), "WM_PROTOCOLS", True
);
649 if (event
->xclient
.message_type
== wm_protocols
)
651 if ((Atom
) (event
->xclient
.data
.l
[0]) == wm_delete_window
)
662 printf( "destroy from %s\n", win
->GetName().c_str() );
667 printf( "create from %s\n", win
->GetName().c_str() );
672 printf( "map request from %s\n", win
->GetName().c_str() );
677 printf( "resize request from %s\n", win
->GetName().c_str() );
679 Display
*disp
= (Display
*) wxGetDisplay();
684 while( XCheckTypedWindowEvent (disp
, actualWindow
, ResizeRequest
, &report
));
686 wxSize sz
= win
->GetSize();
687 wxSizeEvent
sizeEvent(sz
, win
->GetId());
688 sizeEvent
.SetEventObject(win
);
690 return win
->GetEventHandler()->ProcessEvent( sizeEvent
);
695 case GR_EVENT_TYPE_CLOSE_REQ
:
712 if (!win
->IsEnabled())
715 // Here we check if the top level window is
716 // disabled, which is one aspect of modality.
718 while (tlw
&& !tlw
->IsTopLevel())
719 tlw
= tlw
->GetParent();
720 if (tlw
&& !tlw
->IsEnabled())
723 if (event
->type
== ButtonPress
)
725 if ((win
!= wxWindow::FindFocus()) && win
->AcceptsFocus())
727 // This might actually be done in wxWindow::SetFocus()
728 // and not here. TODO.
729 g_prevFocus
= wxWindow::FindFocus();
732 wxLogTrace( _T("focus"), _T("About to call SetFocus on %s of type %s due to button press"), win
->GetName().c_str(), win
->GetClassInfo()->GetClassName() );
734 // Record the fact that this window is
735 // getting the focus, because we'll need to
736 // check if its parent is getting a bogus
737 // focus and duly ignore it.
738 // TODO: may need to have this code in SetFocus, too.
739 extern wxWindow
* g_GettingFocus
;
740 g_GettingFocus
= win
;
746 if (event
->type
== LeaveNotify
|| event
->type
== EnterNotify
)
748 // Throw out NotifyGrab and NotifyUngrab
749 if (event
->xcrossing
.mode
!= NotifyNormal
)
753 wxMouseEvent wxevent
;
754 wxTranslateMouseEvent(wxevent
, win
, window
, event
);
755 return win
->GetEventHandler()->ProcessEvent( wxevent
);
760 if ((event
->xfocus
.detail
!= NotifyPointer
) &&
761 (event
->xfocus
.mode
== NotifyNormal
))
764 wxLogTrace( _T("focus"), _T("FocusIn from %s of type %s"), win
->GetName().c_str(), win
->GetClassInfo()->GetClassName() );
766 extern wxWindow
* g_GettingFocus
;
767 if (g_GettingFocus
&& g_GettingFocus
->GetParent() == win
)
769 // Ignore this, this can be a spurious FocusIn
770 // caused by a child having its focus set.
771 g_GettingFocus
= NULL
;
772 wxLogTrace( _T("focus"), _T("FocusIn from %s of type %s being deliberately ignored"), win
->GetName().c_str(), win
->GetClassInfo()->GetClassName() );
777 wxFocusEvent
focusEvent(wxEVT_SET_FOCUS
, win
->GetId());
778 focusEvent
.SetEventObject(win
);
779 focusEvent
.SetWindow( g_prevFocus
);
782 return win
->GetEventHandler()->ProcessEvent(focusEvent
);
791 if ((event
->xfocus
.detail
!= NotifyPointer
) &&
792 (event
->xfocus
.mode
== NotifyNormal
))
795 wxLogTrace( _T("focus"), _T("FocusOut from %s of type %s"), win
->GetName().c_str(), win
->GetClassInfo()->GetClassName() );
797 wxFocusEvent
focusEvent(wxEVT_KILL_FOCUS
, win
->GetId());
798 focusEvent
.SetEventObject(win
);
799 focusEvent
.SetWindow( g_nextFocus
);
801 return win
->GetEventHandler()->ProcessEvent(focusEvent
);
809 //wxString eventName = wxGetXEventName(XEvent& event);
810 //wxLogDebug(wxT("Event %s not handled"), eventName.c_str());
819 // Returns TRUE if more time is needed.
820 // Note that this duplicates wxEventLoopImpl::SendIdleEvent
821 // but ProcessIdle may be needed by apps, so is kept.
822 bool wxApp::ProcessIdle()
825 event
.SetEventObject(this);
828 return event
.MoreRequested();
831 void wxApp::ExitMainLoop()
837 // Is a message/event pending?
838 bool wxApp::Pending()
840 return wxEventLoop::GetActive()->Pending();
843 // Dispatch a message.
844 void wxApp::Dispatch()
846 wxEventLoop::GetActive()->Dispatch();
849 // This should be redefined in a derived class for
850 // handling property change events for XAtom IPC.
851 bool wxApp::HandlePropertyChange(WXEvent
*event
)
853 // by default do nothing special
854 // TODO: what to do for X11
855 // XtDispatchEvent((XEvent*) event);
859 void wxApp::OnIdle(wxIdleEvent
& event
)
861 static bool s_inOnIdle
= FALSE
;
863 // Avoid recursion (via ProcessEvent default case)
869 // Resend in the main thread events which have been prepared in other
871 ProcessPendingEvents();
873 // 'Garbage' collection of windows deleted with Close()
874 DeletePendingObjects();
876 // Send OnIdle events to all windows
877 bool needMore
= SendIdleEvents();
880 event
.RequestMore(TRUE
);
885 void wxApp::WakeUpIdle()
887 // TODO: use wxMotif implementation?
889 // Wake up the idle handler processor, even if it is in another thread...
893 // Send idle event to all top-level windows
894 bool wxApp::SendIdleEvents()
896 bool needMore
= FALSE
;
898 wxWindowList::Node
* node
= wxTopLevelWindows
.GetFirst();
901 wxWindow
* win
= node
->GetData();
902 if (SendIdleEvents(win
))
904 node
= node
->GetNext();
910 // Send idle event to window and all subwindows
911 bool wxApp::SendIdleEvents(wxWindow
* win
)
913 bool needMore
= FALSE
;
916 event
.SetEventObject(win
);
918 win
->GetEventHandler()->ProcessEvent(event
);
920 if (event
.MoreRequested())
923 wxWindowListNode
* node
= win
->GetChildren().GetFirst();
926 wxWindow
* win
= (wxWindow
*) node
->GetData();
927 if (SendIdleEvents(win
))
930 node
= node
->GetNext();
933 win
->OnInternalIdle();
938 void wxApp::DeletePendingObjects()
940 wxNode
*node
= wxPendingDelete
.GetFirst();
943 wxObject
*obj
= (wxObject
*)node
->GetData();
947 if (wxPendingDelete
.Member(obj
))
950 // Deleting one object may have deleted other pending
951 // objects, so start from beginning of list again.
952 node
= wxPendingDelete
.GetFirst();
956 // Create display, and other initialization
957 bool wxApp::OnInitGui()
959 // Eventually this line will be removed, but for
960 // now we don't want to try popping up a dialog
961 // for error messages.
962 delete wxLog::SetActiveTarget(new wxLogStderr
);
964 if (!wxAppBase::OnInitGui())
967 GetMainColormap( wxApp::GetDisplay() );
969 m_maxRequestSize
= XMaxRequestSize( (Display
*) wxApp::GetDisplay() );
972 m_visualInfo
= new wxXVisualInfo
;
973 wxFillXVisualInfo( m_visualInfo
, (Display
*) wxApp::GetDisplay() );
981 #include <pango/pango.h>
982 #include <pango/pangox.h>
983 #include <pango/pangoxft.h>
985 PangoContext
* wxApp::GetPangoContext()
987 static PangoContext
*ret
= NULL
;
991 Display
*xdisplay
= (Display
*) wxApp::GetDisplay();
994 int xscreen
= DefaultScreen(xdisplay
);
995 static int use_xft
= -1;
998 wxString val
= wxGetenv( L
"GDK_USE_XFT" );
999 use_xft
= (val
== L
"1");
1003 ret
= pango_xft_get_context( xdisplay
, xscreen
);
1006 ret
= pango_x_get_context( xdisplay
);
1008 if (!PANGO_IS_CONTEXT(ret
))
1009 wxLogError( wxT("No pango context.") );
1015 WXColormap
wxApp::GetMainColormap(WXDisplay
* display
)
1017 if (!display
) /* Must be called first with non-NULL display */
1018 return m_mainColormap
;
1020 int defaultScreen
= DefaultScreen((Display
*) display
);
1021 Screen
* screen
= XScreenOfDisplay((Display
*) display
, defaultScreen
);
1023 Colormap c
= DefaultColormapOfScreen(screen
);
1025 if (!m_mainColormap
)
1026 m_mainColormap
= (WXColormap
) c
;
1028 return (WXColormap
) c
;
1031 Window
wxGetWindowParent(Window window
)
1033 wxASSERT_MSG( window
, "invalid window" );
1037 Window parent
, root
= 0;
1041 unsigned int noChildren
= 0;
1043 Window
* children
= NULL
;
1045 // #define XQueryTree(d,w,r,p,c,nc) GrQueryTree(w,p,c,nc)
1050 XQueryTree((Display
*) wxGetDisplay(), window
, & root
, & parent
,
1051 & children
, & noChildren
);
1064 wxAppConsole::Exit();
1067 // Yield to other processes
1069 bool wxApp::Yield(bool onlyIfNeeded
)
1071 // Sometimes only 2 yields seem
1072 // to do the trick, e.g. in the
1075 for (i
= 0; i
< 2; i
++)
1077 bool s_inYield
= FALSE
;
1081 if ( !onlyIfNeeded
)
1083 wxFAIL_MSG( wxT("wxYield called recursively" ) );
1091 // Make sure we have an event loop object,
1092 // or Pending/Dispatch will fail
1093 wxEventLoop
* eventLoop
= wxEventLoop::GetActive();
1094 wxEventLoop
* newEventLoop
= NULL
;
1097 newEventLoop
= new wxEventLoop
;
1098 wxEventLoop::SetActive(newEventLoop
);
1101 // Call dispatch at least once so that sockets
1103 wxTheApp
->Dispatch();
1105 while (wxTheApp
&& wxTheApp
->Pending())
1106 wxTheApp
->Dispatch();
1109 wxTimer::NotifyTimers();
1115 wxEventLoop::SetActive(NULL
);
1116 delete newEventLoop
;
1127 void wxApp::OnAssert(const wxChar
*file
, int line
, const wxChar
* cond
, const wxChar
*msg
)
1129 // While the GUI isn't working that well, just print out the
1132 wxAppBase::OnAssert(file
, line
, cond
, msg
);
1135 msg2
.Printf("At file %s:%d: %s", file
, line
, msg
);
1140 #endif // __WXDEBUG__