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