+
+struct MwmHints {
+ long flags;
+ long functions;
+ long decorations;
+ long input_mode;
+};
+
+#define PROP_MOTIF_WM_HINTS_ELEMENTS 5
+
+// Set the window manager decorations according to the
+// given wxWidgets style
+bool wxSetWMDecorations(Window w, long style)
+{
+#if wxUSE_NANOX
+ GR_WM_PROPERTIES wmProp;
+
+ wmProp.flags = 0;
+ wmProp.props = 0;
+
+ if (style & wxRESIZE_BORDER)
+ {
+ wmProp.props |= GR_WM_PROPS_APPFRAME ;
+ wmProp.flags |= GR_WM_FLAGS_PROPS ;
+ }
+
+ if (style & wxCLOSE_BOX)
+ {
+ wmProp.props |= GR_WM_PROPS_CLOSEBOX ;
+ wmProp.flags |= GR_WM_FLAGS_PROPS ;
+ }
+
+ if ((style & wxCAPTION) ||
+ (style & wxTINY_CAPTION))
+ {
+ wmProp.props |= GR_WM_PROPS_CAPTION ;
+ wmProp.flags |= GR_WM_FLAGS_PROPS ;
+
+ // The default dialog style doesn't include any kind
+ // of border, which is a bit odd. Anyway, inclusion
+ // of a caption surely implies a border.
+ style |= wxRESIZE_BORDER;
+ }
+
+ if (style & wxRESIZE_BORDER)
+ {
+ wmProp.props |= GR_WM_PROPS_APPFRAME ;
+ wmProp.flags |= GR_WM_FLAGS_PROPS ;
+ }
+
+ if (style & wxSIMPLE_BORDER)
+ {
+ wmProp.props |= GR_WM_PROPS_BORDER ;
+ wmProp.flags |= GR_WM_FLAGS_PROPS ;
+ }
+
+ if (style & wxMINIMIZE_BOX)
+ {
+ }
+
+ if (style & wxMAXIMIZE_BOX)
+ {
+ wmProp.props |= GR_WM_PROPS_MAXIMIZE ;
+ wmProp.flags |= GR_WM_FLAGS_PROPS ;
+ }
+
+ if (((style & wxBORDER) != wxBORDER) && ((style & wxRESIZE_BORDER) != wxRESIZE_BORDER)
+ && ((style & wxRESIZE_BORDER) != wxRESIZE_BORDER))
+ {
+ wmProp.props |= GR_WM_PROPS_NODECORATE ;
+ wmProp.flags |= GR_WM_FLAGS_PROPS ;
+ }
+
+ GrSetWMProperties(w, & wmProp);
+
+#else
+
+ Atom mwm_wm_hints = XInternAtom(wxGlobalDisplay(),"_MOTIF_WM_HINTS", False);
+ if (mwm_wm_hints == 0)
+ return false;
+
+ MwmHints hints;
+ hints.flags = MWM_HINTS_DECORATIONS | MWM_HINTS_FUNCTIONS;
+ hints.decorations = 0;
+ hints.functions = 0;
+
+ if ((style & wxSIMPLE_BORDER) || (style & wxNO_BORDER))
+ {
+ // leave zeros
+ }
+ else
+ {
+ hints.decorations = MWM_DECOR_BORDER;
+ hints.functions = MWM_FUNC_MOVE;
+
+ if ((style & wxCAPTION) != 0)
+ hints.decorations |= MWM_DECOR_TITLE;
+
+ if ((style & wxSYSTEM_MENU) != 0)
+ hints.decorations |= MWM_DECOR_MENU;
+
+ if ((style & wxCLOSE_BOX) != 0)
+ hints.functions |= MWM_FUNC_CLOSE;
+
+ if ((style & wxMINIMIZE_BOX) != 0)
+ {
+ hints.functions |= MWM_FUNC_MINIMIZE;
+ hints.decorations |= MWM_DECOR_MINIMIZE;
+ }
+
+ if ((style & wxMAXIMIZE_BOX) != 0)