}
static void fghHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
{
- if( w->State.Redisplay )
+ if( w->State.Redisplay && w->State.Visible )
{
e->found = GL_TRUE;
e->data = w;
#if TARGET_HOST_UNIX_X11
/*
- * Returns GLUT modifier mask for an XEvent.
+ * Returns GLUT modifier mask for the state field of an X11 event.
*/
-static int fghGetXModifiers( XEvent *event )
+static int fghGetXModifiers( int state )
{
int ret = 0;
- if( event->xkey.state & ( ShiftMask | LockMask ) )
+ if( state & ( ShiftMask | LockMask ) )
ret |= GLUT_ACTIVE_SHIFT;
- if( event->xkey.state & ControlMask )
+ if( state & ControlMask )
ret |= GLUT_ACTIVE_CTRL;
- if( event->xkey.state & Mod1Mask )
+ if( state & Mod1Mask )
ret |= GLUT_ACTIVE_ALT;
return ret;
*
* GLUT presumably does this because it generally tries to treat
* sub-windows the same as windows.
- *
- * XXX Technically, GETWINDOW( xconfigure ) and
- * XXX {event.xconfigure} may not be legit ways to get at
- * XXX data for CreateNotify events. In practice, the data
- * XXX is in a union which is laid out much the same either
- * XXX way. But if you want to split hairs, this isn't legit,
- * XXX and we should instead duplicate some code.
*/
case CreateNotify:
case ConfigureNotify:
- GETWINDOW( xconfigure );
{
- int width = event.xconfigure.width;
- int height = event.xconfigure.height;
+ int width, height;
+ if( event.type == CreateNotify ) {
+ GETWINDOW( xcreatewindow );
+ width = event.xcreatewindow.width;
+ height = event.xcreatewindow.height;
+ } else {
+ GETWINDOW( xconfigure );
+ width = event.xconfigure.width;
+ height = event.xconfigure.height;
+ }
if( ( width != window->State.OldWidth ) ||
( height != window->State.OldHeight ) )
break;
case MapNotify:
+ break;
+
case UnmapNotify:
- /*
- * If we never do anything with this, can we just not ask to
- * get these messages?
- */
+ /* We get this when iconifying a window. */
+ GETWINDOW( xunmap );
+ INVOKE_WCB( *window, WindowStatus, ( GLUT_HIDDEN ) );
+ window->State.Visible = GL_FALSE;
break;
case MappingNotify:
case VisibilityNotify:
{
- GETWINDOW( xvisibility );
- /*
- * XXX INVOKE_WCB() does this check for us.
- */
- if( ! FETCH_WCB( *window, WindowStatus ) )
- break;
- fgSetWindow( window );
-
/*
* Sending this event, the X server can notify us that the window
* has just acquired one of the three possible visibility states:
* VisibilityUnobscured, VisibilityPartiallyObscured or
- * VisibilityFullyObscured
+ * VisibilityFullyObscured. Note that we DO NOT receive a
+ * VisibilityNotify event when iconifying a window, we only get an
+ * UnmapNotify then.
*/
+ GETWINDOW( xvisibility );
switch( event.xvisibility.state )
{
case VisibilityUnobscured:
* XXX track ButtonPress/ButtonRelease events in our own
* XXX bit-mask?
*/
-#define BUTTON_MASK \
- ( Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask )
- if ( event.xmotion.state & BUTTON_MASK )
+ fgState.Modifiers = fghGetXModifiers( event.xmotion.state );
+ if ( event.xmotion.state & ( Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask ) ) {
INVOKE_WCB( *window, Motion, ( event.xmotion.x,
event.xmotion.y ) );
- else
+ } else {
INVOKE_WCB( *window, Passive, ( event.xmotion.x,
event.xmotion.y ) );
+ }
+ fgState.Modifiers = INVALID_MODIFIERS;
}
break;
! FETCH_WCB( *window, MouseWheel ) )
break;
- fgState.Modifiers = fghGetXModifiers( &event );
+ fgState.Modifiers = fghGetXModifiers( event.xbutton.state );
/* Finally execute the mouse or mouse wheel callback */
if( ( button < glutDeviceGet ( GLUT_NUM_MOUSE_BUTTONS ) ) || ( ! FETCH_WCB( *window, MouseWheel ) ) )
event.xbutton.y )
);
}
-
- /* Trash the modifiers state */
- fgState.Modifiers = 0xffffffff;
+ fgState.Modifiers = INVALID_MODIFIERS;
}
break;
if( keyboard_cb )
{
fgSetWindow( window );
- fgState.Modifiers = fghGetXModifiers( &event );
+ fgState.Modifiers = fghGetXModifiers( event.xkey.state );
keyboard_cb( asciiCode[ 0 ],
event.xkey.x, event.xkey.y
);
- fgState.Modifiers = 0xffffffff;
+ fgState.Modifiers = INVALID_MODIFIERS;
}
}
else
if( special_cb && (special != -1) )
{
fgSetWindow( window );
- fgState.Modifiers = fghGetXModifiers( &event );
+ fgState.Modifiers = fghGetXModifiers( event.xkey.state );
special_cb( special, event.xkey.x, event.xkey.y );
- fgState.Modifiers = 0xffffffff;
+ fgState.Modifiers = INVALID_MODIFIERS;
}
}
}
if( fgStructure.MenuContext )
wglMakeCurrent( window->Window.Device,
- fgStructure.MenuContext->Context
+ fgStructure.MenuContext->MContext
);
else
{
fgStructure.MenuContext =
(SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );
- fgStructure.MenuContext->Context =
+ fgStructure.MenuContext->MContext =
wglCreateContext( window->Window.Device );
}
INVOKE_WCB( *window, Passive, ( window->State.MouseX,
window->State.MouseY ) );
- fgState.Modifiers = 0xffffffff;
+ fgState.Modifiers = INVALID_MODIFIERS;
}
break;
)
);
- fgState.Modifiers = 0xffffffff;
+ fgState.Modifiers = INVALID_MODIFIERS;
}
break;
);
}
- fgState.Modifiers = 0xffffffff;
+ fgState.Modifiers = INVALID_MODIFIERS;
}
break ;
window->State.MouseX, window->State.MouseY )
);
- fgState.Modifiers = 0xffffffff;
+ fgState.Modifiers = INVALID_MODIFIERS;
}
break;
window->State.MouseX, window->State.MouseY )
);
- fgState.Modifiers = 0xffffffff;
+ fgState.Modifiers = INVALID_MODIFIERS;
}
break;
( (char)wParam,
window->State.MouseX, window->State.MouseY )
);
- fgState.Modifiers = 0xffffffff;
+ fgState.Modifiers = INVALID_MODIFIERS;
}
break;