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: https://svn.code.sf.net/p/freeglut/code/trunk@162 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
cjp 2003-08-05 19:22:21 +00:00
parent 099ef00133
commit 53988cfb1a
5 changed files with 14 additions and 103 deletions

1
.gitattributes vendored
View File

@ -104,7 +104,6 @@ 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

View File

@ -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

View File

@ -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 ) )

View File

@ -432,6 +432,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
*/
@ -556,15 +565,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.

View File

@ -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 <X11/Xlib.h>
#include <X11/Xatom.h>
#undef HAVE_MOTIF
#ifdef HAVE_MOTIF
#include <Xm/MwmUtil.h>
#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 */
);
}