From d9b5d2cb3d40aedab449b1e7aa7a6f44fc40f4b4 Mon Sep 17 00:00:00 2001 From: Christopher John Purnell Date: Tue, 5 Aug 2003 19:22:21 +0000 Subject: [PATCH] Using override_redirect instead of motif wm hints. It now rasies the menu windows before showing them. Move the show to after the reshape and position so we don't get a flash of the menu window at it's old size and position. git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@162 7f0cb862-5218-0410-a997-914c9d46530a --- src/Makefile.am | 3 +- src/freeglut_menu.c | 6 ++-- src/freeglut_window.c | 18 +++++----- src/mwmborder.c | 89 ------------------------------------------------- 4 files changed, 14 insertions(+), 102 deletions(-) delete mode 100644 src/mwmborder.c diff --git a/src/Makefile.am b/src/Makefile.am index 81cdc98..473ccac 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,8 +30,7 @@ libglut_la_SOURCES = freeglut_callbacks.c \ freeglut_structure.c \ freeglut_teapot.c \ freeglut_videoresize.c \ - freeglut_window.c \ - mwmborder.c + freeglut_window.c # # Additional linker flags diff --git a/src/freeglut_menu.c b/src/freeglut_menu.c index 00e415d..5aeeeef 100644 --- a/src/freeglut_menu.c +++ b/src/freeglut_menu.c @@ -193,9 +193,10 @@ static GLboolean fghCheckMenuStatus( SFG_Window* window, SFG_Menu* menu ) menuEntry->SubMenu->Y = menu->Y + menuEntry->Ordinal * FREEGLUT_MENU_HEIGHT ; fgSetWindow ( menuEntry->SubMenu->Window ) ; - glutShowWindow () ; glutPositionWindow ( menuEntry->SubMenu->X, menuEntry->SubMenu->Y ) ; glutReshapeWindow ( menuEntry->SubMenu->Width, menuEntry->SubMenu->Height ) ; + glutPopWindow () ; + glutShowWindow () ; menuEntry->SubMenu->Window->ActiveMenu = menuEntry->SubMenu ; fgSetWindow ( current_window ) ; } @@ -474,9 +475,10 @@ void fgActivateMenu( SFG_Window* window, int button ) menu->Y = window->State.MouseY + glutGet ( GLUT_WINDOW_Y ) ; fgSetWindow ( menu->Window ) ; - glutShowWindow () ; glutPositionWindow ( menu->X, menu->Y ) ; glutReshapeWindow ( menu->Width, menu->Height ) ; + glutPopWindow () ; + glutShowWindow () ; menu->Window->ActiveMenu = menu ; /* if( x > ( glutGet( GLUT_WINDOW_WIDTH ) - menu->Width ) ) diff --git a/src/freeglut_window.c b/src/freeglut_window.c index 0f394e5..4cc38aa 100644 --- a/src/freeglut_window.c +++ b/src/freeglut_window.c @@ -433,6 +433,15 @@ void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, i mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask; /* + * If this is a menu window we want the window manager to ignore it. + */ + if ( fgState.BuildingAMenu ) + { + winAttr.override_redirect = True; + mask |= CWOverrideRedirect; + } + + /* * Have the window created now */ window->Window.Handle = XCreateWindow( @@ -557,15 +566,6 @@ 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/src/mwmborder.c b/src/mwmborder.c deleted file mode 100644 index d7dfac0..0000000 --- a/src/mwmborder.c +++ /dev/null @@ -1,89 +0,0 @@ -/* 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 - -#undef 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 */ - ); -} - -- 1.7.10.4