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