+
+
+#ifndef MWM_DECOR_BORDER
+
+#define MWM_HINTS_FUNCTIONS (1L << 0)
+#define MWM_HINTS_DECORATIONS (1L << 1)
+#define MWM_HINTS_INPUT_MODE (1L << 2)
+#define MWM_HINTS_STATUS (1L << 3)
+
+#define MWM_DECOR_ALL (1L << 0)
+#define MWM_DECOR_BORDER (1L << 1)
+#define MWM_DECOR_RESIZEH (1L << 2)
+#define MWM_DECOR_TITLE (1L << 3)
+#define MWM_DECOR_MENU (1L << 4)
+#define MWM_DECOR_MINIMIZE (1L << 5)
+#define MWM_DECOR_MAXIMIZE (1L << 6)
+
+#define MWM_FUNC_ALL (1L << 0)
+#define MWM_FUNC_RESIZE (1L << 1)
+#define MWM_FUNC_MOVE (1L << 2)
+#define MWM_FUNC_MINIMIZE (1L << 3)
+#define MWM_FUNC_MAXIMIZE (1L << 4)
+#define MWM_FUNC_CLOSE (1L << 5)
+
+#define MWM_INPUT_MODELESS 0
+#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
+#define MWM_INPUT_SYSTEM_MODAL 2
+#define MWM_INPUT_FULL_APPLICATION_MODAL 3
+#define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
+
+#define MWM_TEAROFF_WINDOW (1L<<0)
+
+#endif
+
+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) && !(style & 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)
+ {
+ hints.functions |= MWM_FUNC_MAXIMIZE;
+ hints.decorations |= MWM_DECOR_MAXIMIZE;
+ }
+
+ if ((style & wxRESIZE_BORDER) != 0)
+ {
+ hints.functions |= MWM_FUNC_RESIZE;
+ hints.decorations |= MWM_DECOR_RESIZEH;
+ }
+ }
+
+ XChangeProperty(wxGlobalDisplay(),
+ w,
+ mwm_wm_hints, mwm_wm_hints,
+ 32, PropModeReplace,
+ (unsigned char *) &hints, PROP_MOTIF_WM_HINTS_ELEMENTS);
+
+#endif
+ return true;
+}