Compiles for Nano-X again
[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 xattributes.override_redirect = False;
131 #endif
132
133 #if wxUSE_NANOX
134 long backColor, foreColor;
135 backColor = GR_RGB(m_backgroundColour.Red(), m_backgroundColour.Green(), m_backgroundColour.Blue());
136 foreColor = GR_RGB(m_foregroundColour.Red(), m_foregroundColour.Green(), m_foregroundColour.Blue());
137
138 Window xwindow = XCreateWindowWithColor( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y,
139 0, 0, InputOutput, xvisual, backColor, foreColor);
140 #else
141 Window xwindow = XCreateWindow( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y,
142 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes );
143 #endif
144 m_mainWidget = (WXWindow) xwindow;
145
146 int extraFlags = 0;
147 #if wxUSE_NANOX
148 extraFlags |= GR_EVENT_MASK_CLOSE_REQ;
149 #endif
150
151 XSelectInput( xdisplay, xwindow,
152 extraFlags |
153 ExposureMask |
154 KeyPressMask |
155 KeyReleaseMask |
156 ButtonPressMask |
157 ButtonReleaseMask |
158 ButtonMotionMask |
159 EnterWindowMask |
160 LeaveWindowMask |
161 PointerMotionMask |
162 KeymapStateMask |
163 FocusChangeMask |
164 ColormapChangeMask |
165 StructureNotifyMask |
166 PropertyChangeMask
167 );
168
169 wxAddWindowToTable( xwindow, (wxWindow*) this );
170
171 // Set background to None which will prevent X11 from clearing the
172 // background completely.
173 XSetWindowBackgroundPixmap( xdisplay, xwindow, None );
174
175 #if !wxUSE_NANOX
176 if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)
177 {
178 if (GetParent() && GetParent()->GetMainWindow())
179 {
180 Window xparentwindow = (Window) GetParent()->GetMainWindow();
181 XSetTransientForHint( xdisplay, xwindow, xparentwindow );
182 }
183 }
184
185 size_hints.flags = PSize | PPosition;
186 size_hints.x = pos2.x;
187 size_hints.y = pos2.y;
188 size_hints.width = size2.x;
189 size_hints.height = size2.y;
190 XSetWMNormalHints( xdisplay, xwindow, &size_hints);
191
192 XWMHints wm_hints;
193 wm_hints.flags = InputHint | StateHint /* | WindowGroupHint */;
194 wm_hints.input = True;
195 wm_hints.initial_state = NormalState;
196 XSetWMHints( xdisplay, xwindow, &wm_hints);
197
198 Atom wm_protocols[2];
199 wm_protocols[0] = XInternAtom( xdisplay, "WM_DELETE_WINDOW", False );
200 wm_protocols[1] = XInternAtom( xdisplay, "WM_TAKE_FOCUS", False );
201 XSetWMProtocols( xdisplay, xwindow, wm_protocols, 2);
202 #endif
203
204 wxSetWMDecorations( xwindow, style);
205
206 SetTitle(title);
207
208 return TRUE;
209 }
210
211 wxTopLevelWindowX11::~wxTopLevelWindowX11()
212 {
213 wxTopLevelWindows.DeleteObject(this);
214
215 // If this is the last top-level window, exit.
216 if ( wxTheApp && (wxTopLevelWindows.Number() == 0) )
217 {
218 wxTheApp->SetTopWindow(NULL);
219
220 if (wxTheApp->GetExitOnFrameDelete())
221 {
222 // Signal to the app that we're going to close
223 wxTheApp->ExitMainLoop();
224 }
225 }
226 }
227
228 void wxTopLevelWindowX11::OnInternalIdle()
229 {
230 wxWindow::OnInternalIdle();
231
232 if (m_needResizeInIdle)
233 {
234 wxSizeEvent event( GetClientSize(), GetId() );
235 event.SetEventObject( this );
236 GetEventHandler()->ProcessEvent( event );
237 }
238 }
239
240 // ----------------------------------------------------------------------------
241 // wxTopLevelWindowX11 showing
242 // ----------------------------------------------------------------------------
243
244 bool wxTopLevelWindowX11::Show(bool show)
245 {
246 // Nano-X has to force a size event,
247 // else there's no initial size.
248 #if wxUSE_NANOX
249 if (show)
250 #else
251 if (show && m_needResizeInIdle)
252 #endif
253 {
254 wxSizeEvent event(GetSize(), GetId());
255 event.SetEventObject(this);
256 GetEventHandler()->ProcessEvent(event);
257 }
258
259 return wxWindowX11::Show(show);
260 }
261
262 // ----------------------------------------------------------------------------
263 // wxTopLevelWindowX11 maximize/minimize
264 // ----------------------------------------------------------------------------
265
266 void wxTopLevelWindowX11::Maximize(bool maximize)
267 {
268 // TODO
269 }
270
271 bool wxTopLevelWindowX11::IsMaximized() const
272 {
273 // TODO
274 return TRUE;
275 }
276
277 void wxTopLevelWindowX11::Iconize(bool iconize)
278 {
279 if (!m_iconized && GetMainWindow())
280 {
281 if (XIconifyWindow(wxGlobalDisplay(),
282 (Window) GetMainWindow(), DefaultScreen(wxGlobalDisplay())) != 0)
283 m_iconized = TRUE;
284 }
285 }
286
287 bool wxTopLevelWindowX11::IsIconized() const
288 {
289 return m_iconized;
290 }
291
292 void wxTopLevelWindowX11::Restore()
293 {
294 // This is the way to deiconify the window, according to the X FAQ
295 if (m_iconized && GetMainWindow())
296 {
297 XMapWindow(wxGlobalDisplay(), (Window) GetMainWindow());
298 m_iconized = FALSE;
299 }
300 }
301
302 // ----------------------------------------------------------------------------
303 // wxTopLevelWindowX11 fullscreen
304 // ----------------------------------------------------------------------------
305
306 bool wxTopLevelWindowX11::ShowFullScreen(bool show, long style)
307 {
308 if (show)
309 {
310 if (IsFullScreen())
311 return FALSE;
312
313 m_fsIsShowing = TRUE;
314 m_fsStyle = style;
315
316 // TODO
317
318 return TRUE;
319 }
320 else
321 {
322 if (!IsFullScreen())
323 return FALSE;
324
325 m_fsIsShowing = FALSE;
326
327 // TODO
328 return TRUE;
329 }
330 }
331
332 // ----------------------------------------------------------------------------
333 // wxTopLevelWindowX11 misc
334 // ----------------------------------------------------------------------------
335
336 void wxTopLevelWindowX11::SetIcon(const wxIcon& icon)
337 {
338 // this sets m_icon
339 wxTopLevelWindowBase::SetIcon(icon);
340
341 if (icon.Ok() && GetMainWindow())
342 {
343 #if wxUSE_NANOX
344 #else
345 XWMHints *wmHints = XAllocWMHints();
346 wmHints->icon_pixmap = (Pixmap) icon.GetPixmap();
347
348 wmHints->flags = IconPixmapHint;
349
350 if (icon.GetMask())
351 {
352 wmHints->flags |= IconMaskHint;
353 wmHints->icon_mask = (Pixmap) icon.GetMask()->GetBitmap();
354 }
355
356 XSetWMHints(wxGlobalDisplay(), (Window) GetMainWindow(), wmHints);
357 XFree(wmHints);
358 #endif
359 }
360 }
361
362 void wxTopLevelWindowX11::SetTitle(const wxString& title)
363 {
364 m_title = title;
365 if (GetMainWindow())
366 {
367 XStoreName(wxGlobalDisplay(), (Window) GetMainWindow(),
368 (const char*) title);
369 XSetIconName(wxGlobalDisplay(), (Window) GetMainWindow(),
370 (const char*) title);
371
372 // Use this if the platform doesn't supply the above functions.
373 #if 0
374 XTextProperty textProperty;
375 textProperty.value = (unsigned char*) title;
376 textProperty.encoding = XA_STRING;
377 textProperty.format = 8;
378 textProperty.nitems = 1;
379
380 XSetTextProperty(wxGlobalDisplay(), (Window) GetMainWindow(),
381 & textProperty, WM_NAME);
382 #endif
383 }
384 }
385
386 wxString wxTopLevelWindowX11::GetTitle() const
387 {
388 return m_title;
389 }
390
391 #ifndef MWM_DECOR_BORDER
392 /* bit definitions for MwmHints.flags */
393 #define MWM_HINTS_FUNCTIONS (1L << 0)
394 #define MWM_HINTS_DECORATIONS (1L << 1)
395 #define MWM_HINTS_INPUT_MODE (1L << 2)
396 #define MWM_HINTS_STATUS (1L << 3)
397
398 #define MWM_DECOR_ALL (1L << 0)
399 #define MWM_DECOR_BORDER (1L << 1)
400 #define MWM_DECOR_RESIZEH (1L << 2)
401 #define MWM_DECOR_TITLE (1L << 3)
402 #define MWM_DECOR_MENU (1L << 4)
403 #define MWM_DECOR_MINIMIZE (1L << 5)
404 #define MWM_DECOR_MAXIMIZE (1L << 6)
405 #endif
406
407 struct MwmHints {
408 long flags;
409 long functions;
410 long decorations;
411 long input_mode;
412 };
413
414 #define PROP_MOTIF_WM_HINTS_ELEMENTS 5
415
416 // Set the window manager decorations according to the
417 // given wxWindows style
418 bool wxSetWMDecorations(Window w, long style)
419 {
420 #if wxUSE_NANOX
421 GR_WM_PROPERTIES wmProp;
422
423 wmProp.flags = 0;
424 wmProp.props = 0;
425
426 if (style & wxRESIZE_BORDER)
427 {
428 wmProp.props |= GR_WM_PROPS_APPFRAME ;
429 wmProp.flags |= GR_WM_FLAGS_PROPS ;
430 }
431
432 if (style & wxSYSTEM_MENU)
433 {
434 wmProp.props |= GR_WM_PROPS_CLOSEBOX ;
435 wmProp.flags |= GR_WM_FLAGS_PROPS ;
436 }
437
438 if ((style & wxCAPTION) ||
439 (style & wxTINY_CAPTION_HORIZ) ||
440 (style & wxTINY_CAPTION_VERT))
441 {
442 wmProp.props |= GR_WM_PROPS_CAPTION ;
443 wmProp.flags |= GR_WM_FLAGS_PROPS ;
444
445 // The default dialog style doesn't include any kind
446 // of border, which is a bit odd. Anyway, inclusion
447 // of a caption surely implies a border.
448 style |= wxTHICK_FRAME;
449 }
450
451 if (style & wxTHICK_FRAME)
452 {
453 wmProp.props |= GR_WM_PROPS_APPFRAME ;
454 wmProp.flags |= GR_WM_FLAGS_PROPS ;
455 }
456
457 if (style & wxSIMPLE_BORDER)
458 {
459 wmProp.props |= GR_WM_PROPS_BORDER ;
460 wmProp.flags |= GR_WM_FLAGS_PROPS ;
461 }
462
463 if (style & wxMINIMIZE_BOX)
464 {
465 }
466
467 if (style & wxMAXIMIZE_BOX)
468 {
469 wmProp.props |= GR_WM_PROPS_MAXIMIZE ;
470 wmProp.flags |= GR_WM_FLAGS_PROPS ;
471 }
472
473 if (((style & wxBORDER) != wxBORDER) && ((style & wxTHICK_FRAME) != wxTHICK_FRAME)
474 && ((style & wxRESIZE_BORDER) != wxRESIZE_BORDER))
475 {
476 wmProp.props |= GR_WM_PROPS_NODECORATE ;
477 wmProp.flags |= GR_WM_FLAGS_PROPS ;
478 }
479
480 GrSetWMProperties(w, & wmProp);
481
482 #else
483 if (!wxMWMIsRunning(w))
484 return FALSE;
485
486 Atom mwm_wm_hints = XInternAtom(wxGlobalDisplay(),"_MOTIF_WM_HINTS", False);
487 MwmHints hints;
488 hints.flags = 0;
489 hints.decorations = 0;
490
491 if (style & wxRESIZE_BORDER)
492 {
493 // wxLogDebug("MWM_DECOR_RESIZEH");
494 hints.flags |= MWM_HINTS_DECORATIONS;
495 hints.decorations |= MWM_DECOR_RESIZEH;
496 }
497
498 if (style & wxSYSTEM_MENU)
499 {
500 // wxLogDebug("MWM_DECOR_MENU");
501 hints.flags |= MWM_HINTS_DECORATIONS;
502 hints.decorations |= MWM_DECOR_MENU;
503 }
504
505 if ((style & wxCAPTION) ||
506 (style & wxTINY_CAPTION_HORIZ) ||
507 (style & wxTINY_CAPTION_VERT))
508 {
509 // wxLogDebug("MWM_DECOR_TITLE");
510 hints.flags |= MWM_HINTS_DECORATIONS;
511 hints.decorations |= MWM_DECOR_TITLE;
512 }
513
514 if ((style & wxTHICK_FRAME) || (style & wxCAPTION))
515 {
516 // wxLogDebug("MWM_DECOR_BORDER");
517 hints.flags |= MWM_HINTS_DECORATIONS;
518 hints.decorations |= MWM_DECOR_BORDER;
519 }
520
521 if (style & wxMINIMIZE_BOX)
522 {
523 // wxLogDebug("MWM_DECOR_MINIMIZE");
524 hints.flags |= MWM_HINTS_DECORATIONS;
525 hints.decorations |= MWM_DECOR_MINIMIZE;
526 }
527
528 if (style & wxMAXIMIZE_BOX)
529 {
530 // wxLogDebug("MWM_DECOR_MAXIMIZE");
531 hints.flags |= MWM_HINTS_DECORATIONS;
532 hints.decorations |= MWM_DECOR_MAXIMIZE;
533 }
534
535 XChangeProperty(wxGlobalDisplay(),
536 w,
537 mwm_wm_hints, mwm_wm_hints,
538 32, PropModeReplace,
539 (unsigned char *) &hints, PROP_MOTIF_WM_HINTS_ELEMENTS);
540
541 #endif
542 return TRUE;
543 }
544
545 bool wxMWMIsRunning(Window w)
546 {
547 #if wxUSE_NANOX
548 return FALSE;
549 #else
550 Display *dpy = (Display*)wxGetDisplay();
551 Atom motifWmInfo = XInternAtom(dpy, "_MOTIF_WM_INFO", False);
552
553 unsigned long length, bytesafter;
554 unsigned char value[20];
555 unsigned char *ptr = &value[0];
556 int ret, format;
557 Atom type;
558
559 type = format = length = 0;
560 value[0] = 0;
561
562 ret = XGetWindowProperty(wxGlobalDisplay(), w, motifWmInfo,
563 0L, 2, False, motifWmInfo,
564 &type, &format, &length, &bytesafter, &ptr);
565
566 return (ret == Success);
567 #endif
568 }
569
570 // For implementation purposes - sometimes decorations make the client area
571 // smaller
572 wxPoint wxTopLevelWindowX11::GetClientAreaOrigin() const
573 {
574 // wxFrame::GetClientAreaOrigin
575 // does the required calculation already.
576 return wxPoint(0, 0);
577 }
578
579 void wxTopLevelWindowX11::DoGetClientSize( int *width, int *height ) const
580 {
581 XSync(wxGlobalDisplay(), False);
582 wxWindowX11::DoGetClientSize(width, height);
583 }
584
585 void wxTopLevelWindowX11::DoSetClientSize(int width, int height)
586 {
587 wxWindowX11::DoSetClientSize(width, height);
588
589 #if !wxUSE_NANOX
590 // Set the top-level window size
591 XSizeHints size_hints;
592 wxSize oldSize = GetSize();
593 wxSize oldClientSize = GetClientSize();
594
595 size_hints.flags = PSize;
596 size_hints.width = width + (oldSize.x - oldClientSize.x);
597 size_hints.height = height + (oldSize.y - oldClientSize.y);
598 XSetWMNormalHints( (Display*) GetXDisplay(), (Window) GetMainWindow(),
599 &size_hints);
600
601 // This seems to be necessary or resizes don't get performed
602 XSync(wxGlobalDisplay(), False);
603 XSync(wxGlobalDisplay(), False);
604
605 #if 0
606 wxLogDebug("DoSetClientSize: Tried to set size to %d, %d", (int) size_hints.width, (int) size_hints.height);
607
608 XSync(wxGlobalDisplay(), False);
609 wxSize newSize = GetSize();
610 wxLogDebug("New size is %d, %d", (int) newSize.x, (int) newSize.y);
611 #endif
612 #endif
613 }
614
615 void wxTopLevelWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags)
616 {
617 #if 0
618 // wxLogDebug( "Setting pos: %d, %d", x, y );
619 wxWindowX11::DoSetSize(x, y, width, height, sizeFlags);
620 #endif
621 XSync(wxGlobalDisplay(), False);
622 Window window = (Window) m_mainWidget;
623 if (!window)
624 return ;
625
626 Display *display = (Display*) GetXDisplay();
627 Window root = RootWindowOfScreen(DefaultScreenOfDisplay(display));
628 Window parent_window = window,
629 next_parent = window;
630
631 // search for the parent that is child of ROOT, because the WM may
632 // reparent twice and notify only the next parent (like FVWM)
633 while (next_parent != root) {
634 Window *theChildren;
635 #if wxUSE_NANOX
636 GR_COUNT n;
637 #else
638 unsigned int n;
639 #endif
640 parent_window = next_parent;
641 XQueryTree(display, parent_window, &root,
642 &next_parent, &theChildren, &n);
643 XFree(theChildren); // not needed
644 }
645
646 XWindowChanges windowChanges;
647 windowChanges.x = x;
648 windowChanges.y = y;
649 windowChanges.width = width;
650 windowChanges.height = height;
651 windowChanges.stack_mode = 0;
652 int valueMask = CWX | CWY | CWWidth | CWHeight;
653
654 if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
655 {
656 valueMask |= CWX;
657 }
658 if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
659 {
660 valueMask |= CWY;
661 }
662 if (width != -1)
663 {
664 windowChanges.width = wxMax(1, width);
665 valueMask |= CWWidth;
666 }
667 if (height != -1)
668 {
669 windowChanges.height = wxMax(1, height);
670 valueMask |= CWHeight;
671 }
672
673 XConfigureWindow( display, parent_window, valueMask, &windowChanges );
674
675 #if !wxUSE_NANOX
676 XSizeHints size_hints;
677 size_hints.flags = 0;
678 if (x > -1 && y > -1)
679 size_hints.flags |= PPosition;
680 if (width > -1 && height > -1)
681 size_hints.flags |= PSize;
682 size_hints.width = width;
683 size_hints.height = height;
684 size_hints.x = x;
685 size_hints.y = y;
686 XSetWMNormalHints( (Display*) GetXDisplay(), (Window) GetMainWindow(),
687 &size_hints);
688
689 // This seems to be necessary or resizes don't get performed.
690 // Take them out (or even just one of them), and the About
691 // box of the minimal sample probably won't be resized right.
692 XSync(wxGlobalDisplay(), False);
693 XSync(wxGlobalDisplay(), False);
694 #endif
695 }
696
697 void wxTopLevelWindowX11::DoGetPosition(int *x, int *y) const
698 {
699 XSync(wxGlobalDisplay(), False);
700 Window window = (Window) m_mainWidget;
701 if (!window)
702 return ;
703
704 Display *display = (Display*) GetXDisplay();
705 Window root = RootWindowOfScreen(DefaultScreenOfDisplay(display));
706 Window parent_window = window,
707 next_parent = window;
708
709 // search for the parent that is child of ROOT, because the WM may
710 // reparent twice and notify only the next parent (like FVWM)
711 while (next_parent != root) {
712 Window *theChildren;
713 #if wxUSE_NANOX
714 GR_COUNT n;
715 #else
716 unsigned int n;
717 #endif
718 parent_window = next_parent;
719 XQueryTree(display, parent_window, &root,
720 &next_parent, &theChildren, &n);
721 XFree(theChildren); // not needed
722 }
723 #if 0
724 int xx, yy; unsigned int dummy;
725 XGetGeometry(display, parent_window, &root,
726 &xx, &yy, &dummy, &dummy, &dummy, &dummy);
727 if (x) *x = xx;
728 if (y) *y = yy;
729 #else
730 XWindowAttributes attr;
731 Status status = XGetWindowAttributes((Display*) GetXDisplay(), parent_window, & attr);
732 if (status)
733 {
734 if (x) *x = attr.x;
735 if (y) *y = attr.y;
736 }
737 else
738 {
739 if (x) *x = 0;
740 if (y) *y = 0;
741 }
742 #endif
743 }