1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/x11/app.cpp
3 // Purpose: wxApp
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // for compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13
14 #include "wx/app.h"
15
16 #ifndef WX_PRECOMP
17 #include "wx/hash.h"
18 #include "wx/intl.h"
19 #include "wx/log.h"
20 #include "wx/utils.h"
21 #include "wx/frame.h"
22 #include "wx/icon.h"
23 #include "wx/dialog.h"
24 #include "wx/memory.h"
25 #include "wx/gdicmn.h"
26 #include "wx/module.h"
27 #include "wx/crt.h"
28 #endif
29
30 #include "wx/evtloop.h"
31 #include "wx/filename.h"
32
33 #include "wx/univ/theme.h"
34 #include "wx/univ/renderer.h"
35 #include "wx/generic/private/timer.h"
36
37 #if wxUSE_THREADS
38 #include "wx/thread.h"
39 #endif
40
41 #include "wx/clipbrd.h"
42 #include "wx/x11/private.h"
43
44 #include <string.h>
45
46 //------------------------------------------------------------------------
47 // global data
48 //------------------------------------------------------------------------
49
50 wxWindowHash *wxWidgetHashTable = NULL;
51 wxWindowHash *wxClientWidgetHashTable = NULL;
52
53 static bool g_showIconic = false;
54 static wxSize g_initialSize = wxDefaultSize;
55
56 // This is required for wxFocusEvent::SetWindow(). It will only
57 // work for focus events which we provoke ourselves (by calling
58 // SetFocus()). It will not work for those events, which X11
59 // generates itself.
60 static wxWindow *g_nextFocus = NULL;
61 static wxWindow *g_prevFocus = NULL;
62
63 //------------------------------------------------------------------------
64 // X11 clipboard event handling
65 //------------------------------------------------------------------------
66 extern "C" void wxClipboardHandleSelectionRequest(XEvent event);
67
68 //------------------------------------------------------------------------
69 // X11 error handling
70 //------------------------------------------------------------------------
71
72 typedef int (*XErrorHandlerFunc)(Display *, XErrorEvent *);
73
74 XErrorHandlerFunc gs_pfnXErrorHandler = 0;
75
wxXErrorHandler(Display * dpy,XErrorEvent * xevent)76 static int wxXErrorHandler(Display *dpy, XErrorEvent *xevent)
77 {
78 // just forward to the default handler for now
79 if (gs_pfnXErrorHandler)
80 return gs_pfnXErrorHandler(dpy, xevent);
81 else
82 return 0;
83 }
84
85 //------------------------------------------------------------------------
86 // wxApp
87 //------------------------------------------------------------------------
88
89 long wxApp::sm_lastMessageTime = 0;
90
91 wxIMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler);
92
Initialize(int & argC,wxChar ** argV)93 bool wxApp::Initialize(int& argC, wxChar **argV)
94 {
95 #if !wxUSE_NANOX
96 // install the X error handler
97 gs_pfnXErrorHandler = XSetErrorHandler( wxXErrorHandler );
98 #endif
99
100 wxString displayName;
101 bool syncDisplay = false;
102
103 int argCOrig = argC;
104 for ( int i = 0; i < argCOrig; i++ )
105 {
106 if (wxStrcmp( argV[i], wxT("-display") ) == 0)
107 {
108 if (i < (argCOrig - 1))
109 {
110 argV[i++] = NULL;
111
112 displayName = argV[i];
113
114 argV[i] = NULL;
115 argC -= 2;
116 }
117 }
118 else if (wxStrcmp( argV[i], wxT("-geometry") ) == 0)
119 {
120 if (i < (argCOrig - 1))
121 {
122 argV[i++] = NULL;
123
124 int w, h;
125 if (wxSscanf(argV[i], wxT("%dx%d"), &w, &h) != 2)
126 {
127 wxLogError( _("Invalid geometry specification '%s'"),
128 wxString(argV[i]).c_str() );
129 }
130 else
131 {
132 g_initialSize = wxSize(w, h);
133 }
134
135 argV[i] = NULL;
136 argC -= 2;
137 }
138 }
139 else if (wxStrcmp( argV[i], wxT("-sync") ) == 0)
140 {
141 syncDisplay = true;
142
143 argV[i] = NULL;
144 argC--;
145 }
146 else if (wxStrcmp( argV[i], wxT("-iconic") ) == 0)
147 {
148 g_showIconic = true;
149
150 argV[i] = NULL;
151 argC--;
152 }
153 }
154
155 if ( argC != argCOrig )
156 {
157 // remove the arguments we consumed
158 for ( int i = 0; i < argC; i++ )
159 {
160 while ( !argV[i] )
161 {
162 memmove(argV + i, argV + i + 1, (argCOrig - i)*sizeof(wxChar *));
163 }
164 }
165 }
166
167 // open and set up the X11 display
168 if ( !wxSetDisplay(displayName) )
169 {
170 wxLogError(_("wxWidgets could not open display. Exiting."));
171 return false;
172 }
173
174 Display *dpy = wxGlobalDisplay();
175 if (syncDisplay)
176 XSynchronize(dpy, True);
177
178 XSelectInput(dpy, XDefaultRootWindow(dpy), PropertyChangeMask);
179
180 wxSetDetectableAutoRepeat( true );
181
182
183 if ( !wxAppBase::Initialize(argC, argV) )
184 return false;
185
186 #if wxUSE_UNICODE
187 // Glib's type system required by Pango (deprecated since glib 2.36 but
188 // used to be required, so still call it, it's harmless).
189 wxGCC_WARNING_SUPPRESS(deprecated-declarations)
190 g_type_init();
191 wxGCC_WARNING_RESTORE()
192 #endif
193
194 #if wxUSE_INTL
195 wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
196 #endif
197
198 wxWidgetHashTable = new wxWindowHash;
199 wxClientWidgetHashTable = new wxWindowHash;
200
201 return true;
202 }
203
CleanUp()204 void wxApp::CleanUp()
205 {
206 wxDELETE(wxWidgetHashTable);
207 wxDELETE(wxClientWidgetHashTable);
208
209 wxAppBase::CleanUp();
210 }
211
wxApp()212 wxApp::wxApp()
213 {
214 m_mainColormap = NULL;
215 m_topLevelWidget = NULL;
216 m_maxRequestSize = 0;
217 m_showIconic = false;
218 m_initialSize = wxDefaultSize;
219
220 #if !wxUSE_NANOX
221 m_visualInfo = NULL;
222 #endif
223 }
224
~wxApp()225 wxApp::~wxApp()
226 {
227 #if !wxUSE_NANOX
228 delete m_visualInfo;
229 #endif
230 }
231
232 #if !wxUSE_NANOX
233
234 //-----------------------------------------------------------------------
235 // X11 predicate function for exposure compression
236 //-----------------------------------------------------------------------
237
238 struct wxExposeInfo
239 {
240 Window window;
241 Bool found_non_matching;
242 };
243
244 extern "C"
wxX11ExposePredicate(Display * WXUNUSED (display),XEvent * xevent,XPointer arg)245 Bool wxX11ExposePredicate (Display *WXUNUSED(display), XEvent *xevent, XPointer arg)
246 {
247 wxExposeInfo *info = (wxExposeInfo*) arg;
248
249 if (info->found_non_matching)
250 return FALSE;
251
252 if (xevent->xany.type != Expose)
253 {
254 info->found_non_matching = true;
255 return FALSE;
256 }
257
258 if (xevent->xexpose.window != info->window)
259 {
260 info->found_non_matching = true;
261 return FALSE;
262 }
263
264 return TRUE;
265 }
266
267 #endif // wxUSE_NANOX
268
269 //-----------------------------------------------------------------------
270 // Processes an X event, returning true if the event was processed.
271 //-----------------------------------------------------------------------
272
ProcessXEvent(WXEvent * _event)273 bool wxApp::ProcessXEvent(WXEvent* _event)
274 {
275 XEvent* event = (XEvent*) _event;
276
277 wxWindow* win = NULL;
278 Window window = XEventGetWindow(event);
279 #if 0
280 Window actualWindow = window;
281 #endif
282
283 // Find the first wxWindow that corresponds to this event window
284 // Because we're receiving events after a window
285 // has been destroyed, assume a 1:1 match between
286 // Window and wxWindow, so if it's not in the table,
287 // it must have been destroyed.
288
289 win = wxGetWindowFromTable(window);
290 if (!win)
291 {
292 #if wxUSE_TWO_WINDOWS
293 win = wxGetClientWindowFromTable(window);
294 if (!win)
295 #endif
296 return false;
297 }
298
299
300 switch (event->type)
301 {
302 case Expose:
303 {
304 #if wxUSE_TWO_WINDOWS && !wxUSE_NANOX
305 if (event->xexpose.window != (Window)win->GetClientAreaWindow())
306 {
307 XEvent tmp_event;
308 wxExposeInfo info;
309 info.window = event->xexpose.window;
310 info.found_non_matching = false;
311 while (XCheckIfEvent( wxGlobalDisplay(), &tmp_event, wxX11ExposePredicate, (XPointer) &info ))
312 {
313 // Don't worry about optimizing redrawing the border etc.
314 }
315 win->NeedUpdateNcAreaInIdle();
316 }
317 else
318 #endif
319 {
320 win->GetUpdateRegion().Union( XExposeEventGetX(event), XExposeEventGetY(event),
321 XExposeEventGetWidth(event), XExposeEventGetHeight(event));
322 win->GetClearRegion().Union( XExposeEventGetX(event), XExposeEventGetY(event),
323 XExposeEventGetWidth(event), XExposeEventGetHeight(event));
324
325 #if !wxUSE_NANOX
326 XEvent tmp_event;
327 wxExposeInfo info;
328 info.window = event->xexpose.window;
329 info.found_non_matching = false;
330 while (XCheckIfEvent( wxGlobalDisplay(), &tmp_event, wxX11ExposePredicate, (XPointer) &info ))
331 {
332 win->GetUpdateRegion().Union( tmp_event.xexpose.x, tmp_event.xexpose.y,
333 tmp_event.xexpose.width, tmp_event.xexpose.height );
334
335 win->GetClearRegion().Union( tmp_event.xexpose.x, tmp_event.xexpose.y,
336 tmp_event.xexpose.width, tmp_event.xexpose.height );
337 }
338 #endif
339
340 // This simplifies the expose and clear areas to simple
341 // rectangles.
342 win->GetUpdateRegion() = win->GetUpdateRegion().GetBox();
343 win->GetClearRegion() = win->GetClearRegion().GetBox();
344
345 // If we only have one X11 window, always indicate
346 // that borders might have to be redrawn.
347 if (win->X11GetMainWindow() == win->GetClientAreaWindow())
348 win->NeedUpdateNcAreaInIdle();
349
350 // Only erase background, paint in idle time.
351 win->SendEraseEvents();
352
353 // EXPERIMENT
354 //win->Update();
355 }
356
357 return true;
358 }
359
360 #if !wxUSE_NANOX
361 case GraphicsExpose:
362 {
363 wxLogTrace( wxT("expose"), wxT("GraphicsExpose from %s"), win->GetName().c_str());
364
365 win->GetUpdateRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
366 event->xgraphicsexpose.width, event->xgraphicsexpose.height);
367
368 win->GetClearRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
369 event->xgraphicsexpose.width, event->xgraphicsexpose.height);
370
371 if (event->xgraphicsexpose.count == 0)
372 {
373 // Only erase background, paint in idle time.
374 win->SendEraseEvents();
375 // win->Update();
376 }
377
378 return true;
379 }
380 #endif
381
382 case KeyPress:
383 {
384 if (!win->IsEnabled())
385 return false;
386
387 wxKeyEvent keyEvent(wxEVT_KEY_DOWN);
388 wxTranslateKeyEvent(keyEvent, win, window, event);
389
390 // wxLogDebug( "OnKey from %s", win->GetName().c_str() );
391
392 // We didn't process wxEVT_KEY_DOWN, so send wxEVT_CHAR
393 if (win->HandleWindowEvent( keyEvent ))
394 return true;
395
396 // Do the translation again, retaining the ASCII
397 // code.
398 if ( wxTranslateKeyEvent(keyEvent, win, window, event, true) )
399 {
400 switch ( keyEvent.m_keyCode )
401 {
402 // for modifiers, don't send wxEVT_CHAR event.
403 // the definition of Modifiers, plese see the doc of
404 // wxKeyModifier. we only take care of wxMOD_ALT, wxMOD_CONTROL
405 // wxMOD_SHIFT under X11 platform. Other modifiers is handled
406 // by window manager.
407 case WXK_CONTROL:
408 case WXK_SHIFT:
409 case WXK_ALT:
410 break;
411 default:
412 {
413 // process wxEVT_CHAR here
414 keyEvent.SetEventType(wxEVT_CHAR);
415 if ( win->HandleWindowEvent( keyEvent ) )
416 return true;
417 }
418 }
419 }
420
421 if ( (keyEvent.m_keyCode == WXK_TAB) &&
422 win->GetParent() && (win->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
423 {
424 wxNavigationKeyEvent new_event;
425 new_event.SetEventObject( win->GetParent() );
426 /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
427 new_event.SetDirection( (keyEvent.m_keyCode == WXK_TAB) );
428 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
429 new_event.SetWindowChange( keyEvent.ControlDown() );
430 new_event.SetCurrentFocus( win );
431 return win->GetParent()->HandleWindowEvent( new_event );
432 }
433
434 return false;
435 }
436 case KeyRelease:
437 {
438 if (!win->IsEnabled())
439 return false;
440
441 wxKeyEvent keyEvent(wxEVT_KEY_UP);
442 wxTranslateKeyEvent(keyEvent, win, window, event);
443
444 // if recieve the modifiers key up. set the corresponding
445 // keyboardState to false.
446 switch ( keyEvent.m_keyCode )
447 {
448 case WXK_CONTROL:
449 keyEvent.SetControlDown(false);
450 break;
451 case WXK_SHIFT:
452 keyEvent.SetShiftDown(false);
453 break;
454 case WXK_ALT:
455 keyEvent.SetAltDown(false);
456 break;
457 default:
458 break;
459 }
460
461 return win->HandleWindowEvent( keyEvent );
462 }
463 case ConfigureNotify:
464 {
465 #if wxUSE_NANOX
466 if (event->update.utype == GR_UPDATE_SIZE)
467 #endif
468 {
469 wxTopLevelWindow *tlw = wxDynamicCast(win, wxTopLevelWindow);
470 if ( tlw )
471 {
472 tlw->SetConfigureGeometry( XConfigureEventGetX(event), XConfigureEventGetY(event),
473 XConfigureEventGetWidth(event), XConfigureEventGetHeight(event) );
474 }
475
476 if ( tlw && tlw->IsShown() )
477 {
478 tlw->SetNeedResizeInIdle();
479 }
480 else
481 {
482 wxSizeEvent sizeEvent( wxSize(XConfigureEventGetWidth(event), XConfigureEventGetHeight(event)), win->GetId() );
483 sizeEvent.SetEventObject( win );
484
485 return win->HandleWindowEvent( sizeEvent );
486 }
487 }
488 return false;
489 }
490 #if !wxUSE_NANOX
491 case PropertyNotify:
492 return HandlePropertyChange(_event);
493
494 case ClientMessage:
495 {
496 if (!win->IsEnabled())
497 return false;
498
499 Atom wm_delete_window = XInternAtom(wxGlobalDisplay(), "WM_DELETE_WINDOW", True);
500 Atom wm_protocols = XInternAtom(wxGlobalDisplay(), "WM_PROTOCOLS", True);
501
502 if (event->xclient.message_type == wm_protocols)
503 {
504 if ((Atom) (event->xclient.data.l[0]) == wm_delete_window)
505 {
506 win->Close(false);
507 return true;
508 }
509 }
510 return false;
511 }
512 case SelectionRequest:
513 {
514 // A request to paste has occurred.
515 wxClipboardHandleSelectionRequest(*event);
516 // The event handle doesn't care the clipboard
517 // how to response requestor, so just return true.
518 return true;
519 }
520 #if 0
521 case DestroyNotify:
522 {
523 printf( "destroy from %s\n", win->GetName().c_str() );
524 break;
525 }
526 case CreateNotify:
527 {
528 printf( "create from %s\n", win->GetName().c_str() );
529 break;
530 }
531 case MapRequest:
532 {
533 printf( "map request from %s\n", win->GetName().c_str() );
534 break;
535 }
536 case ResizeRequest:
537 {
538 printf( "resize request from %s\n", win->GetName().c_str() );
539
540 Display *disp = (Display*) wxGetDisplay();
541 XEvent report;
542
543 // to avoid flicker
544 report = * event;
545 while( XCheckTypedWindowEvent (disp, actualWindow, ResizeRequest, &report));
546
547 wxSize sz = win->GetSize();
548 wxSizeEvent sizeEvent(sz, win->GetId());
549 sizeEvent.SetEventObject(win);
550
551 return win->HandleWindowEvent( sizeEvent );
552 }
553 #endif
554 #endif
555 #if wxUSE_NANOX
556 case GR_EVENT_TYPE_CLOSE_REQ:
557 {
558 if (win)
559 {
560 win->Close(false);
561 return true;
562 }
563 return false;
564 break;
565 }
566 #endif
567 case EnterNotify:
568 case LeaveNotify:
569 case ButtonPress:
570 case ButtonRelease:
571 case MotionNotify:
572 {
573 if (!win->IsEnabled())
574 return false;
575
576 // Here we check if the top level window is
577 // disabled, which is one aspect of modality.
578 wxWindow *tlw = win;
579 while (tlw && !tlw->IsTopLevel())
580 tlw = tlw->GetParent();
581 if (tlw && !tlw->IsEnabled())
582 return false;
583
584 if (event->type == ButtonPress)
585 {
586 if ((win != wxWindow::FindFocus()) && win->CanAcceptFocus())
587 {
588 // This might actually be done in wxWindow::SetFocus()
589 // and not here. TODO.
590 g_prevFocus = wxWindow::FindFocus();
591 g_nextFocus = win;
592
593 wxLogTrace( wxT("focus"), wxT("About to call SetFocus on %s of type %s due to button press"), win->GetName().c_str(), win->GetClassInfo()->GetClassName() );
594
595 // Record the fact that this window is
596 // getting the focus, because we'll need to
597 // check if its parent is getting a bogus
598 // focus and duly ignore it.
599 // TODO: may need to have this code in SetFocus, too.
600 extern wxWindow* g_GettingFocus;
601 g_GettingFocus = win;
602 win->SetFocus();
603 }
604 }
605
606 #if !wxUSE_NANOX
607 if (event->type == LeaveNotify || event->type == EnterNotify)
608 {
609 // Throw out NotifyGrab and NotifyUngrab
610 if (event->xcrossing.mode != NotifyNormal)
611 return false;
612 }
613 #endif
614 wxMouseEvent wxevent;
615 wxTranslateMouseEvent(wxevent, win, window, event);
616 return win->HandleWindowEvent( wxevent );
617 }
618 case FocusIn:
619 #if !wxUSE_NANOX
620 if ((event->xfocus.detail != NotifyPointer) &&
621 (event->xfocus.mode == NotifyNormal))
622 #endif
623 {
624 wxLogTrace( wxT("focus"), wxT("FocusIn from %s of type %s"), win->GetName().c_str(), win->GetClassInfo()->GetClassName() );
625
626 extern wxWindow* g_GettingFocus;
627 if (g_GettingFocus && g_GettingFocus->GetParent() == win)
628 {
629 // Ignore this, this can be a spurious FocusIn
630 // caused by a child having its focus set.
631 g_GettingFocus = NULL;
632 wxLogTrace( wxT("focus"), wxT("FocusIn from %s of type %s being deliberately ignored"), win->GetName().c_str(), win->GetClassInfo()->GetClassName() );
633 return true;
634 }
635 else
636 {
637 wxFocusEvent focusEvent(wxEVT_SET_FOCUS, win->GetId());
638 focusEvent.SetEventObject(win);
639 focusEvent.SetWindow( g_prevFocus );
640 g_prevFocus = NULL;
641
642 return win->HandleWindowEvent(focusEvent);
643 }
644 }
645 return false;
646
647 case FocusOut:
648 #if !wxUSE_NANOX
649 if ((event->xfocus.detail != NotifyPointer) &&
650 (event->xfocus.mode == NotifyNormal))
651 #endif
652 {
653 wxLogTrace( wxT("focus"), wxT("FocusOut from %s of type %s"), win->GetName().c_str(), win->GetClassInfo()->GetClassName() );
654
655 wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId());
656 focusEvent.SetEventObject(win);
657 focusEvent.SetWindow( g_nextFocus );
658 g_nextFocus = NULL;
659 return win->HandleWindowEvent(focusEvent);
660 }
661 return false;
662 }
663
664 return false;
665 }
666
667 // This should be redefined in a derived class for
668 // handling property change events for XAtom IPC.
HandlePropertyChange(WXEvent * WXUNUSED (event))669 bool wxApp::HandlePropertyChange(WXEvent *WXUNUSED(event))
670 {
671 // by default do nothing special
672 // TODO: what to do for X11
673 // XtDispatchEvent((XEvent*) event);
674 return false;
675 }
676
WakeUpIdle()677 void wxApp::WakeUpIdle()
678 {
679 // TODO: use wxMotif implementation?
680
681 // Wake up the idle handler processor, even if it is in another thread...
682 }
683
684
685 // Create display, and other initialization
OnInitGui()686 bool wxApp::OnInitGui()
687 {
688 #if wxUSE_LOG
689 // Eventually this line will be removed, but for
690 // now we don't want to try popping up a dialog
691 // for error messages.
692 delete wxLog::SetActiveTarget(new wxLogStderr);
693 #endif
694
695 if (!wxAppBase::OnInitGui())
696 return false;
697
698 Display *dpy = wxGlobalDisplay();
699 GetMainColormap(dpy);
700
701 m_maxRequestSize = XMaxRequestSize(dpy);
702
703 #if !wxUSE_NANOX
704 m_visualInfo = new wxXVisualInfo;
705 wxFillXVisualInfo(m_visualInfo, dpy);
706 #endif
707
708 return true;
709 }
710
711 #if wxUSE_UNICODE
712
713 #include <pango/pango.h>
714 #include <pango/pangoxft.h>
715
GetPangoContext()716 PangoContext* wxApp::GetPangoContext()
717 {
718 static PangoContext *s_pangoContext = NULL;
719 if ( !s_pangoContext )
720 {
721 Display *dpy = wxGlobalDisplay();
722 int xscreen = DefaultScreen(dpy);
723
724 // Calling pango_xft_get_context() is exactly the same as doing
725 // pango_font_map_create_context(pango_xft_get_font_map(dpy, xscreen))
726 // so continue to use it even if it's deprecated to not bother with
727 // checking for Pango 1.2 in configure and just disable the warning.
728 wxGCC_WARNING_SUPPRESS(deprecated-declarations)
729
730 s_pangoContext = pango_xft_get_context(dpy, xscreen);
731
732 wxGCC_WARNING_RESTORE(deprecated-declarations)
733
734 if (!PANGO_IS_CONTEXT(s_pangoContext))
735 {
736 wxLogError( wxT("No pango context.") );
737 }
738 }
739
740 return s_pangoContext;
741 }
742
wxGetPangoContext()743 PangoContext* wxGetPangoContext()
744 {
745 PangoContext* context = wxTheApp->GetPangoContext();
746 g_object_ref(context);
747 return context;
748 }
749 #endif // wxUSE_UNICODE
750
GetMainColormap(WXDisplay * display)751 WXColormap wxApp::GetMainColormap(WXDisplay* display)
752 {
753 if (!display) /* Must be called first with non-NULL display */
754 return m_mainColormap;
755
756 int defaultScreen = DefaultScreen((Display*) display);
757 Screen* screen = XScreenOfDisplay((Display*) display, defaultScreen);
758
759 Colormap c = DefaultColormapOfScreen(screen);
760
761 if (!m_mainColormap)
762 m_mainColormap = (WXColormap) c;
763
764 return (WXColormap) c;
765 }
766
wxGetWindowParent(Window window)767 Window wxGetWindowParent(Window window)
768 {
769 wxASSERT_MSG( window, wxT("invalid window") );
770
771 return (Window) 0;
772
773 #ifndef __VMS
774 // VMS chokes on unreacheable code
775 Window parent, root = 0;
776 #if wxUSE_NANOX
777 int noChildren = 0;
778 #else
779 unsigned int noChildren = 0;
780 #endif
781 Window* children = NULL;
782
783 // #define XQueryTree(d,w,r,p,c,nc) GrQueryTree(w,p,c,nc)
784 int res = 1;
785 #if !wxUSE_NANOX
786 res =
787 #endif
788 XQueryTree((Display*) wxGetDisplay(), window, & root, & parent,
789 & children, & noChildren);
790 if (children)
791 XFree(children);
792 if (res)
793 return parent;
794 else
795 return (Window) 0;
796 #endif
797 }
798
Exit()799 void wxApp::Exit()
800 {
801 wxApp::CleanUp();
802
803 wxAppConsole::Exit();
804 }
805
806