]> git.saurik.com Git - wxWidgets.git/blob - src/x11/toplevel.cpp
Do not use argument defaults in actual function argument list.
[wxWidgets.git] / src / x11 / toplevel.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: x11/toplevel.cpp
3 // Purpose: implements wxTopLevelWindow for X11
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 24.09.01
7 // RCS-ID: $Id$
8 // Copyright: (c) 2002 Julian Smart
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "toplevel.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #include "wx/app.h"
33 #include "wx/toplevel.h"
34 #include "wx/string.h"
35 #include "wx/log.h"
36 #include "wx/intl.h"
37 #include "wx/frame.h"
38 #include "wx/menu.h"
39 #include "wx/statusbr.h"
40 #endif //WX_PRECOMP
41
42 #include "wx/settings.h"
43 #include "wx/x11/private.h"
44 #include "X11/Xutil.h"
45
46 bool wxMWMIsRunning(Window w);
47
48 // ----------------------------------------------------------------------------
49 // wxTopLevelWindowX11 creation
50 // ----------------------------------------------------------------------------
51
52 void wxTopLevelWindowX11::Init()
53 {
54 m_iconized =
55 m_maximizeOnShow = FALSE;
56
57 // unlike (almost?) all other windows, frames are created hidden
58 m_isShown = FALSE;
59
60 // Data to save/restore when calling ShowFullScreen
61 m_fsStyle = 0;
62 m_fsIsMaximized = FALSE;
63 m_fsIsShowing = FALSE;
64
65 m_needResizeInIdle = FALSE;
66 }
67
68 bool wxTopLevelWindowX11::Create(wxWindow *parent,
69 wxWindowID id,
70 const wxString& title,
71 const wxPoint& pos,
72 const wxSize& size,
73 long style,
74 const wxString& name)
75 {
76 // init our fields
77 Init();
78
79 m_windowStyle = style;
80 m_parent = parent;
81
82 SetName(name);
83
84 m_windowId = id == -1 ? NewControlId() : id;
85
86 if (parent)
87 parent->AddChild(this);
88
89 wxTopLevelWindows.Append(this);
90
91 Display *xdisplay = wxGlobalDisplay();
92 int xscreen = DefaultScreen( xdisplay );
93 Visual *xvisual = DefaultVisual( xdisplay, xscreen );
94 Window xparent = RootWindow( xdisplay, xscreen );
95 Colormap cm = DefaultColormap( xdisplay, xscreen );
96
97 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)
98 m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
99 else
100 m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
101 m_backgroundColour.CalcPixel( (WXColormap) cm );
102 m_hasBgCol = TRUE;
103
104 wxSize size2(size);
105 if (size2.x == -1)
106 size2.x = 100;
107 if (size2.y == -1)
108 size2.y = 100;
109
110 wxPoint pos2(pos);
111 if (pos2.x == -1)
112 pos2.x = 100;
113 if (pos2.y == -1)
114 pos2.y = 100;
115
116 #if !wxUSE_NANOX
117 XSetWindowAttributes xattributes;
118 XSizeHints size_hints;
119
120 long xattributes_mask =
121 CWOverrideRedirect |
122 CWBorderPixel | CWBackPixel;
123
124 xattributes.background_pixel = m_backgroundColour.GetPixel();
125 xattributes.border_pixel = BlackPixel( xdisplay, xscreen );
126
127 // TODO: if we want no border, caption etc.,
128 // I think we set this to True to remove decorations
129 // No. RR.
130 // Yes :-) JACS (because some WMs don't respect
131 // the hints)
132 xattributes.override_redirect = (style & wxNO_BORDER) ? True : False;
133 #endif
134
135 #if wxUSE_NANOX
136 long backColor, foreColor;
137 backColor = GR_RGB(m_backgroundColour.Red(), m_backgroundColour.Green(), m_backgroundColour.Blue());
138 foreColor = GR_RGB(m_foregroundColour.Red(), m_foregroundColour.Green(), m_foregroundColour.Blue());
139
140 Window xwindow = XCreateWindowWithColor( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y,
141 0, 0, InputOutput, xvisual, backColor, foreColor);
142 #else
143 Window xwindow = XCreateWindow( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y,
144 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes );
145 #endif
146 m_mainWidget = (WXWindow) xwindow;
147
148 int extraFlags = 0;
149 #if wxUSE_NANOX
150 extraFlags |= GR_EVENT_MASK_CLOSE_REQ;
151 #endif
152
153 XSelectInput( xdisplay, xwindow,
154 extraFlags |
155 ExposureMask |
156 KeyPressMask |
157 KeyReleaseMask |
158 ButtonPressMask |
159 ButtonReleaseMask |
160 ButtonMotionMask |
161 EnterWindowMask |
162 LeaveWindowMask |
163 PointerMotionMask |
164 KeymapStateMask |
165 FocusChangeMask |
166 ColormapChangeMask |
167 StructureNotifyMask |
168 PropertyChangeMask
169 );
170
171 wxAddWindowToTable( xwindow, (wxWindow*) this );
172
173 // Set background to None which will prevent X11 from clearing the
174 // background completely.
175 XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
176
177 #if !wxUSE_NANOX
178 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)
179 {
180 if (GetParent() && GetParent()->GetMainWindow())
181 {
182 Window xparentwindow = (Window) GetParent()->GetMainWindow();
183 XSetTransientForHint( xdisplay, xwindow, xparentwindow );
184 }
185 }
186
187 size_hints.flags = PSize | PPosition;
188 size_hints.x = pos2.x;
189 size_hints.y = pos2.y;
190 size_hints.width = size2.x;
191 size_hints.height = size2.y;
192 XSetWMNormalHints( xdisplay, xwindow, &size_hints);
193
194 XWMHints wm_hints;
195 wm_hints.flags = InputHint | StateHint /* | WindowGroupHint */;
196 wm_hints.input = True;
197 wm_hints.initial_state = NormalState;
198 XSetWMHints( xdisplay, xwindow, &wm_hints);
199
200 Atom wm_protocols[2];
201 wm_protocols[0] = XInternAtom( xdisplay, "WM_DELETE_WINDOW", False );
202 wm_protocols[1] = XInternAtom( xdisplay, "WM_TAKE_FOCUS", False );
203 XSetWMProtocols( xdisplay, xwindow, wm_protocols, 2);
204 #endif
205
206 wxSetWMDecorations( xwindow, style);
207
208 SetTitle(title);
209
210 return TRUE;
211 }
212
213 wxTopLevelWindowX11::~wxTopLevelWindowX11()
214 {
215 wxTopLevelWindows.DeleteObject(this);
216
217 // If this is the last top-level window, exit.
218 if ( wxTheApp && (wxTopLevelWindows.Number() == 0) )
219 {
220 wxTheApp->SetTopWindow(NULL);
221
222 if (wxTheApp->GetExitOnFrameDelete())
223 {
224 // Signal to the app that we're going to close
225 wxTheApp->ExitMainLoop();
226 }
227 }
228 }
229
230 void wxTopLevelWindowX11::OnInternalIdle()
231 {
232 wxWindow::OnInternalIdle();
233
234 if (m_needResizeInIdle)
235 {
236 wxSizeEvent event( GetClientSize(), GetId() );
237 event.SetEventObject( this );
238 GetEventHandler()->ProcessEvent( event );
239
240 m_needResizeInIdle = FALSE;
241 }
242 }
243
244 // ----------------------------------------------------------------------------
245 // wxTopLevelWindowX11 showing
246 // ----------------------------------------------------------------------------
247
248 bool wxTopLevelWindowX11::Show(bool show)
249 {
250 // Nano-X has to force a size event,
251 // else there's no initial size.
252 #if wxUSE_NANOX
253 if (show)
254 #else
255 if (show && m_needResizeInIdle)
256 #endif
257 {
258 wxSizeEvent event(GetSize(), GetId());
259 event.SetEventObject(this);
260 GetEventHandler()->ProcessEvent(event);
261
262 m_needResizeInIdle = FALSE;
263 }
264
265 if (show)
266 {
267 // This does the layout _before_ the
268 // window is shown, else the items are
269 // drawn first at the wrong positions,
270 // then at the correct positions.
271 if (GetAutoLayout())
272 {
273 Layout();
274 }
275 }
276
277 return wxWindowX11::Show(show);
278 }
279
280 // ----------------------------------------------------------------------------
281 // wxTopLevelWindowX11 maximize/minimize
282 // ----------------------------------------------------------------------------
283
284 void wxTopLevelWindowX11::Maximize(bool maximize)
285 {
286 // TODO
287 }
288
289 bool wxTopLevelWindowX11::IsMaximized() const
290 {
291 // TODO
292 return TRUE;
293 }
294
295 void wxTopLevelWindowX11::Iconize(bool iconize)
296 {
297 if (!m_iconized && GetMainWindow())
298 {
299 if (XIconifyWindow(wxGlobalDisplay(),
300 (Window) GetMainWindow(), DefaultScreen(wxGlobalDisplay())) != 0)
301 m_iconized = TRUE;
302 }
303 }
304
305 bool wxTopLevelWindowX11::IsIconized() const
306 {
307 return m_iconized;
308 }
309
310 void wxTopLevelWindowX11::Restore()
311 {
312 // This is the way to deiconify the window, according to the X FAQ
313 if (m_iconized && GetMainWindow())
314 {
315 XMapWindow(wxGlobalDisplay(), (Window) GetMainWindow());
316 m_iconized = FALSE;
317 }
318 }
319
320 // ----------------------------------------------------------------------------
321 // wxTopLevelWindowX11 fullscreen
322 // ----------------------------------------------------------------------------
323
324 bool wxTopLevelWindowX11::ShowFullScreen(bool show, long style)
325 {
326 if (show)
327 {
328 if (IsFullScreen())
329 return FALSE;
330
331 m_fsIsShowing = TRUE;
332 m_fsStyle = style;
333
334 // TODO
335
336 return TRUE;
337 }
338 else
339 {
340 if (!IsFullScreen())
341 return FALSE;
342
343 m_fsIsShowing = FALSE;
344
345 // TODO
346 return TRUE;
347 }
348 }
349
350 // ----------------------------------------------------------------------------
351 // wxTopLevelWindowX11 misc
352 // ----------------------------------------------------------------------------
353
354 void wxTopLevelWindowX11::SetIcon(const wxIcon& icon)
355 {
356 // this sets m_icon
357 wxTopLevelWindowBase::SetIcon(icon);
358
359 if (icon.Ok() && GetMainWindow())
360 {
361 #if wxUSE_NANOX
362 #else
363 XWMHints *wmHints = XAllocWMHints();
364 wmHints->icon_pixmap = (Pixmap) icon.GetPixmap();
365
366 wmHints->flags = IconPixmapHint;
367
368 if (icon.GetMask())
369 {
370 wmHints->flags |= IconMaskHint;
371 wmHints->icon_mask = (Pixmap) icon.GetMask()->GetBitmap();
372 }
373
374 XSetWMHints(wxGlobalDisplay(), (Window) GetMainWindow(), wmHints);
375 XFree(wmHints);
376 #endif
377 }
378 }
379
380 void wxTopLevelWindowX11::SetTitle(const wxString& title)
381 {
382 m_title = title;
383 if (GetMainWindow())
384 {
385 XStoreName(wxGlobalDisplay(), (Window) GetMainWindow(),
386 (const char*) title);
387 XSetIconName(wxGlobalDisplay(), (Window) GetMainWindow(),
388 (const char*) title);
389
390 // Use this if the platform doesn't supply the above functions.
391 #if 0
392 XTextProperty textProperty;
393 textProperty.value = (unsigned char*) title;
394 textProperty.encoding = XA_STRING;
395 textProperty.format = 8;
396 textProperty.nitems = 1;
397
398 XSetTextProperty(wxGlobalDisplay(), (Window) GetMainWindow(),
399 & textProperty, WM_NAME);
400 #endif
401 }
402 }
403
404 wxString wxTopLevelWindowX11::GetTitle() const
405 {
406 return m_title;
407 }
408
409 #ifndef MWM_DECOR_BORDER
410 /* bit definitions for MwmHints.flags */
411 #define MWM_HINTS_FUNCTIONS (1L << 0)
412 #define MWM_HINTS_DECORATIONS (1L << 1)
413 #define MWM_HINTS_INPUT_MODE (1L << 2)
414 #define MWM_HINTS_STATUS (1L << 3)
415
416 #define MWM_DECOR_ALL (1L << 0)
417 #define MWM_DECOR_BORDER (1L << 1)
418 #define MWM_DECOR_RESIZEH (1L << 2)
419 #define MWM_DECOR_TITLE (1L << 3)
420 #define MWM_DECOR_MENU (1L << 4)
421 #define MWM_DECOR_MINIMIZE (1L << 5)
422 #define MWM_DECOR_MAXIMIZE (1L << 6)
423 #endif
424
425 struct MwmHints {
426 long flags;
427 long functions;
428 long decorations;
429 long input_mode;
430 };
431
432 #define PROP_MOTIF_WM_HINTS_ELEMENTS 5
433
434 // Set the window manager decorations according to the
435 // given wxWindows style
436 bool wxSetWMDecorations(Window w, long style)
437 {
438 #if wxUSE_NANOX
439 GR_WM_PROPERTIES wmProp;
440
441 wmProp.flags = 0;
442 wmProp.props = 0;
443
444 if (style & wxRESIZE_BORDER)
445 {
446 wmProp.props |= GR_WM_PROPS_APPFRAME ;
447 wmProp.flags |= GR_WM_FLAGS_PROPS ;
448 }
449
450 if (style & wxSYSTEM_MENU)
451 {
452 wmProp.props |= GR_WM_PROPS_CLOSEBOX ;
453 wmProp.flags |= GR_WM_FLAGS_PROPS ;
454 }
455
456 if ((style & wxCAPTION) ||
457 (style & wxTINY_CAPTION_HORIZ) ||
458 (style & wxTINY_CAPTION_VERT))
459 {
460 wmProp.props |= GR_WM_PROPS_CAPTION ;
461 wmProp.flags |= GR_WM_FLAGS_PROPS ;
462
463 // The default dialog style doesn't include any kind
464 // of border, which is a bit odd. Anyway, inclusion
465 // of a caption surely implies a border.
466 style |= wxTHICK_FRAME;
467 }
468
469 if (style & wxTHICK_FRAME)
470 {
471 wmProp.props |= GR_WM_PROPS_APPFRAME ;
472 wmProp.flags |= GR_WM_FLAGS_PROPS ;
473 }
474
475 if (style & wxSIMPLE_BORDER)
476 {
477 wmProp.props |= GR_WM_PROPS_BORDER ;
478 wmProp.flags |= GR_WM_FLAGS_PROPS ;
479 }
480
481 if (style & wxMINIMIZE_BOX)
482 {
483 }
484
485 if (style & wxMAXIMIZE_BOX)
486 {
487 wmProp.props |= GR_WM_PROPS_MAXIMIZE ;
488 wmProp.flags |= GR_WM_FLAGS_PROPS ;
489 }
490
491 if (((style & wxBORDER) != wxBORDER) && ((style & wxTHICK_FRAME) != wxTHICK_FRAME)
492 && ((style & wxRESIZE_BORDER) != wxRESIZE_BORDER))
493 {
494 wmProp.props |= GR_WM_PROPS_NODECORATE ;
495 wmProp.flags |= GR_WM_FLAGS_PROPS ;
496 }
497
498 GrSetWMProperties(w, & wmProp);
499
500 #else
501 if (!wxMWMIsRunning(w))
502 return FALSE;
503
504 Atom mwm_wm_hints = XInternAtom(wxGlobalDisplay(),"_MOTIF_WM_HINTS", False);
505 MwmHints hints;
506 hints.flags = 0;
507 hints.decorations = 0;
508
509 if (style & wxRESIZE_BORDER)
510 {
511 // wxLogDebug("MWM_DECOR_RESIZEH");
512 hints.flags |= MWM_HINTS_DECORATIONS;
513 hints.decorations |= MWM_DECOR_RESIZEH;
514 }
515
516 if (style & wxSYSTEM_MENU)
517 {
518 // wxLogDebug("MWM_DECOR_MENU");
519 hints.flags |= MWM_HINTS_DECORATIONS;
520 hints.decorations |= MWM_DECOR_MENU;
521 }
522
523 if ((style & wxCAPTION) ||
524 (style & wxTINY_CAPTION_HORIZ) ||
525 (style & wxTINY_CAPTION_VERT))
526 {
527 // wxLogDebug("MWM_DECOR_TITLE");
528 hints.flags |= MWM_HINTS_DECORATIONS;
529 hints.decorations |= MWM_DECOR_TITLE;
530 }
531
532 if ((style & wxTHICK_FRAME) || (style & wxCAPTION))
533 {
534 // wxLogDebug("MWM_DECOR_BORDER");
535 hints.flags |= MWM_HINTS_DECORATIONS;
536 hints.decorations |= MWM_DECOR_BORDER;
537 }
538
539 if (style & wxMINIMIZE_BOX)
540 {
541 // wxLogDebug("MWM_DECOR_MINIMIZE");
542 hints.flags |= MWM_HINTS_DECORATIONS;
543 hints.decorations |= MWM_DECOR_MINIMIZE;
544 }
545
546 if (style & wxMAXIMIZE_BOX)
547 {
548 // wxLogDebug("MWM_DECOR_MAXIMIZE");
549 hints.flags |= MWM_HINTS_DECORATIONS;
550 hints.decorations |= MWM_DECOR_MAXIMIZE;
551 }
552
553 XChangeProperty(wxGlobalDisplay(),
554 w,
555 mwm_wm_hints, mwm_wm_hints,
556 32, PropModeReplace,
557 (unsigned char *) &hints, PROP_MOTIF_WM_HINTS_ELEMENTS);
558
559 #endif
560 return TRUE;
561 }
562
563 bool wxMWMIsRunning(Window w)
564 {
565 #if wxUSE_NANOX
566 return FALSE;
567 #else
568 Display *dpy = (Display*)wxGetDisplay();
569 Atom motifWmInfo = XInternAtom(dpy, "_MOTIF_WM_INFO", False);
570
571 unsigned long length, bytesafter;
572 unsigned char value[20];
573 unsigned char *ptr = &value[0];
574 int ret, format;
575 Atom type;
576
577 type = format = length = 0;
578 value[0] = 0;
579
580 ret = XGetWindowProperty(wxGlobalDisplay(), w, motifWmInfo,
581 0L, 2, False, motifWmInfo,
582 &type, &format, &length, &bytesafter, &ptr);
583
584 return (ret == Success);
585 #endif
586 }
587
588 // For implementation purposes - sometimes decorations make the client area
589 // smaller
590 wxPoint wxTopLevelWindowX11::GetClientAreaOrigin() const
591 {
592 // wxFrame::GetClientAreaOrigin
593 // does the required calculation already.
594 return wxPoint(0, 0);
595 }
596
597 void wxTopLevelWindowX11::DoGetClientSize( int *width, int *height ) const
598 {
599 XSync(wxGlobalDisplay(), False);
600 wxWindowX11::DoGetClientSize(width, height);
601 }
602
603 void wxTopLevelWindowX11::DoSetClientSize(int width, int height)
604 {
605 wxWindowX11::DoSetClientSize(width, height);
606
607 #if !wxUSE_NANOX
608 // Set the top-level window size
609 XSizeHints size_hints;
610 wxSize oldSize = GetSize();
611 wxSize oldClientSize = GetClientSize();
612
613 size_hints.flags = PSize;
614 size_hints.width = width + (oldSize.x - oldClientSize.x);
615 size_hints.height = height + (oldSize.y - oldClientSize.y);
616 XSetWMNormalHints( (Display*) GetXDisplay(), (Window) GetMainWindow(),
617 &size_hints);
618
619 // This seems to be necessary or resizes don't get performed
620 XSync(wxGlobalDisplay(), False);
621 XSync(wxGlobalDisplay(), False);
622
623 #if 0
624 wxLogDebug("DoSetClientSize: Tried to set size to %d, %d", (int) size_hints.width, (int) size_hints.height);
625
626 XSync(wxGlobalDisplay(), False);
627 wxSize newSize = GetSize();
628 wxLogDebug("New size is %d, %d", (int) newSize.x, (int) newSize.y);
629 #endif
630 #endif
631 }
632
633 void wxTopLevelWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags)
634 {
635 #if 0
636 // wxLogDebug( "Setting pos: %d, %d", x, y );
637 wxWindowX11::DoSetSize(x, y, width, height, sizeFlags);
638 #endif
639 XSync(wxGlobalDisplay(), False);
640 Window window = (Window) m_mainWidget;
641 if (!window)
642 return ;
643
644 Display *display = (Display*) GetXDisplay();
645 Window root = RootWindowOfScreen(DefaultScreenOfDisplay(display));
646 Window parent_window = window,
647 next_parent = window;
648
649 // search for the parent that is child of ROOT, because the WM may
650 // reparent twice and notify only the next parent (like FVWM)
651 while (next_parent != root) {
652 Window *theChildren;
653 #if wxUSE_NANOX
654 GR_COUNT n;
655 #else
656 unsigned int n;
657 #endif
658 parent_window = next_parent;
659 XQueryTree(display, parent_window, &root,
660 &next_parent, &theChildren, &n);
661 XFree(theChildren); // not needed
662 }
663
664 XWindowChanges windowChanges;
665 windowChanges.x = x;
666 windowChanges.y = y;
667 windowChanges.width = width;
668 windowChanges.height = height;
669 windowChanges.stack_mode = 0;
670 int valueMask = CWX | CWY | CWWidth | CWHeight;
671
672 if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
673 {
674 valueMask |= CWX;
675 }
676 if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
677 {
678 valueMask |= CWY;
679 }
680 if (width != -1)
681 {
682 windowChanges.width = wxMax(1, width);
683 valueMask |= CWWidth;
684 }
685 if (height != -1)
686 {
687 windowChanges.height = wxMax(1, height);
688 valueMask |= CWHeight;
689 }
690
691 XConfigureWindow( display, parent_window, valueMask, &windowChanges );
692
693 #if !wxUSE_NANOX
694 XSizeHints size_hints;
695 size_hints.flags = 0;
696 if (x > -1 && y > -1)
697 size_hints.flags |= PPosition;
698 if (width > -1 && height > -1)
699 size_hints.flags |= PSize;
700 size_hints.width = width;
701 size_hints.height = height;
702 size_hints.x = x;
703 size_hints.y = y;
704 XSetWMNormalHints( (Display*) GetXDisplay(), (Window) GetMainWindow(),
705 &size_hints);
706
707 // This seems to be necessary or resizes don't get performed.
708 // Take them out (or even just one of them), and the About
709 // box of the minimal sample probably won't be resized right.
710 XSync(wxGlobalDisplay(), False);
711 XSync(wxGlobalDisplay(), False);
712 #endif
713 }
714
715 void wxTopLevelWindowX11::DoGetPosition(int *x, int *y) const
716 {
717 XSync(wxGlobalDisplay(), False);
718 Window window = (Window) m_mainWidget;
719 if (!window)
720 return ;
721
722 Display *display = (Display*) GetXDisplay();
723 Window root = RootWindowOfScreen(DefaultScreenOfDisplay(display));
724 Window parent_window = window,
725 next_parent = window;
726
727 // search for the parent that is child of ROOT, because the WM may
728 // reparent twice and notify only the next parent (like FVWM)
729 while (next_parent != root) {
730 Window *theChildren;
731 #if wxUSE_NANOX
732 GR_COUNT n;
733 #else
734 unsigned int n;
735 #endif
736 parent_window = next_parent;
737 XQueryTree(display, parent_window, &root,
738 &next_parent, &theChildren, &n);
739 XFree(theChildren); // not needed
740 }
741 #if 0
742 int xx, yy; unsigned int dummy;
743 XGetGeometry(display, parent_window, &root,
744 &xx, &yy, &dummy, &dummy, &dummy, &dummy);
745 if (x) *x = xx;
746 if (y) *y = yy;
747 #else
748 XWindowAttributes attr;
749 Status status = XGetWindowAttributes((Display*) GetXDisplay(), parent_window, & attr);
750 if (status)
751 {
752 if (x) *x = attr.x;
753 if (y) *y = attr.y;
754 }
755 else
756 {
757 if (x) *x = 0;
758 if (y) *y = 0;
759 }
760 #endif
761 }