I suspect a lot of people will not have motif installed.
[freeglut] / src / mwmborder.c
1 /* mwmborder.c */
2
3
4 /*
5  * This function shows how to remove the border, title bar, resize button,
6  * etc from a Motif window frame from inside an Xlib-based application.
7  *
8  * Brian Paul  19 Sep 1995   brianp@ssec.wisc.edu
9  */
10
11
12 #include <X11/Xlib.h>
13 #include <X11/Xatom.h>
14
15 #undef HAVE_MOTIF
16 #ifdef HAVE_MOTIF
17
18 #include <Xm/MwmUtil.h>
19
20 #else
21
22 /* bit definitions for MwmHints.flags */
23 #define MWM_HINTS_FUNCTIONS     (1L << 0)
24 #define MWM_HINTS_DECORATIONS   (1L << 1)
25 #define MWM_HINTS_INPUT_MODE    (1L << 2)
26 #define MWM_HINTS_STATUS        (1L << 3)
27
28 /* bit definitions for MwmHints.decorations */
29 #define MWM_DECOR_ALL           (1L << 0)
30 #define MWM_DECOR_BORDER        (1L << 1)
31 #define MWM_DECOR_RESIZEH       (1L << 2)
32 #define MWM_DECOR_TITLE         (1L << 3)
33 #define MWM_DECOR_MENU          (1L << 4)
34 #define MWM_DECOR_MINIMIZE      (1L << 5)
35 #define MWM_DECOR_MAXIMIZE      (1L << 6)
36
37 typedef struct
38 {
39     unsigned long       flags;
40     unsigned long       functions;
41     unsigned long       decorations;
42     long                inputMode;
43     unsigned long       status;
44 } PropMotifWmHints;
45
46 #define PROP_MOTIF_WM_HINTS_ELEMENTS    5
47
48 #endif
49
50
51
52 /*
53  * Specify which Motif window manager border decorations to put on a
54  * top-level window.  For example, you can specify that a window is not
55  * resizabe, or omit the titlebar, or completely remove all decorations.
56  * Input:  dpy - the X display
57  *         w - the X window
58  *         flags - bitwise-OR of the MWM_DECOR_xxx symbols in X11/Xm/MwmUtil.h
59  *                 indicating what decoration elements to enable.  Zero would
60  *                 be no decoration.
61  */
62 void set_mwm_border( Display *dpy, Window w, unsigned long flags )
63 {
64    PropMotifWmHints motif_hints;
65    Atom prop, proptype;
66
67    /* setup the property */
68    motif_hints.flags = MWM_HINTS_DECORATIONS;
69    motif_hints.decorations = flags;
70
71    /* get the atom for the property */
72    prop = XInternAtom( dpy, "_MOTIF_WM_HINTS", True );
73    if (!prop) {
74       /* something went wrong! */
75       return;
76    }
77
78    /* not sure this is correct, seems to work, XA_WM_HINTS didn't work */
79    proptype = prop;
80
81    XChangeProperty( dpy, w,                         /* display, window */
82                     prop, proptype,                 /* property, type */
83                     32,                             /* format: 32-bit datums */
84                     PropModeReplace,                /* mode */
85                     (unsigned char *) &motif_hints, /* data */
86                     PROP_MOTIF_WM_HINTS_ELEMENTS    /* nelements */
87                   );
88 }
89