From b9f20e5d8784bad56d0084fd7569e4c9c21d0086 Mon Sep 17 00:00:00 2001 From: puggles Date: Mon, 4 Aug 2003 01:29:19 +0000 Subject: [PATCH] Menus' decorations are removed on Linux. Not sure if we want the mwmborder.c a separate file or not; doing it separate for right now. Makefile was not updated, since the .c is just #included. git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@155 7f0cb862-5218-0410-a997-914c9d46530a --- .gitattributes | 1 + freeglut/freeglut/src/freeglut_window.c | 10 +++ freeglut/freeglut/src/mwmborder.c | 89 +++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 freeglut/freeglut/src/mwmborder.c diff --git a/.gitattributes b/.gitattributes index ebb1f80..decc225 100644 --- a/.gitattributes +++ b/.gitattributes @@ -104,6 +104,7 @@ freeglut/freeglut/src/freeglut_teapot.c svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/freeglut_videoresize.c svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/freeglut_window.c svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/freeglutdll.def svn_keywords=Author+Date+Id+Revision +freeglut/freeglut/src/mwmborder.c svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/templates/cpp_template svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/templates/header_template svn_keywords=Author+Date+Id+Revision freeglut/freeglut/stamp-h svn_keywords=Author+Date+Id+Revision diff --git a/freeglut/freeglut/src/freeglut_window.c b/freeglut/freeglut/src/freeglut_window.c index 08cb8d9..377802d 100644 --- a/freeglut/freeglut/src/freeglut_window.c +++ b/freeglut/freeglut/src/freeglut_window.c @@ -33,6 +33,7 @@ #include "../include/GL/freeglut.h" #include "freeglut_internal.h" +#include "mwmborder.c" /* * TODO BEFORE THE STABLE RELEASE: @@ -555,6 +556,15 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i */ XMapWindow( fgDisplay.Display, window->Window.Handle ); + /* + * If we're a menu, then we need to ask the WM to remove decorations. + * This is stolen shamelessly from Brian Paul + * (19 Sep 1995 brianp@ssec.wisc.edu) + */ + if ( window->IsMenu ) { + set_mwm_border(fgDisplay.Display, window->Window.Handle, 0); + } + /* * In game mode, move the viewport a bit to hide the decorations. * This code depends on the XFree86 video mode extensions. diff --git a/freeglut/freeglut/src/mwmborder.c b/freeglut/freeglut/src/mwmborder.c new file mode 100644 index 0000000..0356b61 --- /dev/null +++ b/freeglut/freeglut/src/mwmborder.c @@ -0,0 +1,89 @@ +/* mwmborder.c */ + + +/* + * This function shows how to remove the border, title bar, resize button, + * etc from a Motif window frame from inside an Xlib-based application. + * + * Brian Paul 19 Sep 1995 brianp@ssec.wisc.edu + */ + + +#include +#include + +#define HAVE_MOTIF +#ifdef HAVE_MOTIF + +#include + +#else + +/* bit definitions for MwmHints.flags */ +#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) + +/* bit definitions for MwmHints.decorations */ +#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) + +typedef struct +{ + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long inputMode; + unsigned long status; +} PropMotifWmHints; + +#define PROP_MOTIF_WM_HINTS_ELEMENTS 5 + +#endif + + + +/* + * Specify which Motif window manager border decorations to put on a + * top-level window. For example, you can specify that a window is not + * resizabe, or omit the titlebar, or completely remove all decorations. + * Input: dpy - the X display + * w - the X window + * flags - bitwise-OR of the MWM_DECOR_xxx symbols in X11/Xm/MwmUtil.h + * indicating what decoration elements to enable. Zero would + * be no decoration. + */ +void set_mwm_border( Display *dpy, Window w, unsigned long flags ) +{ + PropMotifWmHints motif_hints; + Atom prop, proptype; + + /* setup the property */ + motif_hints.flags = MWM_HINTS_DECORATIONS; + motif_hints.decorations = flags; + + /* get the atom for the property */ + prop = XInternAtom( dpy, "_MOTIF_WM_HINTS", True ); + if (!prop) { + /* something went wrong! */ + return; + } + + /* not sure this is correct, seems to work, XA_WM_HINTS didn't work */ + proptype = prop; + + XChangeProperty( dpy, w, /* display, window */ + prop, proptype, /* property, type */ + 32, /* format: 32-bit datums */ + PropModeReplace, /* mode */ + (unsigned char *) &motif_hints, /* data */ + PROP_MOTIF_WM_HINTS_ELEMENTS /* nelements */ + ); +} +