part of dealing with work is platform independent, so moved it to platform independent part of code
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1615 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
5658b01337
commit
8d979f3c7e
@ -488,20 +488,8 @@ void fgPlatformMainLoopPreliminaryWork ( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Step through the work list */
|
/* deal with work list items */
|
||||||
void fgPlatformProcessWork(SFG_Window *window)
|
void fgPlatformInitWork(SFG_Window* window)
|
||||||
{
|
|
||||||
unsigned int workMask = window->State.WorkMask;
|
|
||||||
/* Now clear it so that any callback generated by the actions below can set work again */
|
|
||||||
window->State.WorkMask = 0;
|
|
||||||
|
|
||||||
if (workMask&~GLUT_DISPLAY_WORK) /* Display work is the common case, skip all the below at once */
|
|
||||||
{
|
|
||||||
/* This is before the first display callback: call a few callbacks to inform user of window size, position, etc
|
|
||||||
* we know this is before the first display callback of a window as for all windows GLUT_INIT_WORK is set when
|
|
||||||
* they are opened, and work is done before displaying in the mainloop.
|
|
||||||
*/
|
|
||||||
if (workMask & GLUT_INIT_WORK)
|
|
||||||
{
|
{
|
||||||
/* notify windowStatus/visibility */
|
/* notify windowStatus/visibility */
|
||||||
INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_RETAINED ) );
|
INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_RETAINED ) );
|
||||||
@ -514,19 +502,10 @@ void fgPlatformProcessWork(SFG_Window *window)
|
|||||||
* so client code cannot have registered a callback yet and the message
|
* so client code cannot have registered a callback yet and the message
|
||||||
* is thus never received by client?
|
* is thus never received by client?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Call init context callback */
|
|
||||||
INVOKE_WCB( *window, InitContext, ());
|
|
||||||
|
|
||||||
/* Lastly, check if we have a display callback, error out if not
|
|
||||||
* This is the right place to do it, as the redisplay will be
|
|
||||||
* next right after we exit this function, so there is no more
|
|
||||||
* opportunity for the user to register a callback for this window.
|
|
||||||
*/
|
|
||||||
if (!FETCH_WCB(*window, Display))
|
|
||||||
fgError ( "ERROR: No display callback registered for window %d\n", window->ID );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fgPlatformPosResZordWork(SFG_Window* window, unsigned int workMask)
|
||||||
|
{
|
||||||
if (workMask & GLUT_FULL_SCREEN_WORK)
|
if (workMask & GLUT_FULL_SCREEN_WORK)
|
||||||
fgPlatformFullScreenToggle( window );
|
fgPlatformFullScreenToggle( window );
|
||||||
if (workMask & GLUT_POSITION_WORK)
|
if (workMask & GLUT_POSITION_WORK)
|
||||||
@ -540,8 +519,9 @@ void fgPlatformProcessWork(SFG_Window *window)
|
|||||||
else
|
else
|
||||||
fgPlatformPopWindow( window );
|
fgPlatformPopWindow( window );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (workMask & GLUT_VISIBILITY_WORK)
|
void fgPlatformVisibilityWork(SFG_Window* window)
|
||||||
{
|
{
|
||||||
/* Visibility status of window should get updated in the window message handlers
|
/* Visibility status of window should get updated in the window message handlers
|
||||||
* For now, none of these functions called below do anything, so don't worry
|
* For now, none of these functions called below do anything, so don't worry
|
||||||
@ -564,15 +544,4 @@ void fgPlatformProcessWork(SFG_Window *window)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (workMask & GLUT_DISPLAY_WORK)
|
|
||||||
{
|
|
||||||
if( window->State.Visible )
|
|
||||||
fghRedrawWindow ( window );
|
|
||||||
|
|
||||||
/* Strip out display work that might have ended up on work list now as some of the above genereates callbacks */
|
|
||||||
window->State.WorkMask &= ~GLUT_DISPLAY_WORK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -60,7 +60,9 @@ extern void fgPlatformSleepForEvents( fg_time_t msec );
|
|||||||
extern void fgPlatformProcessSingleEvent ( void );
|
extern void fgPlatformProcessSingleEvent ( void );
|
||||||
extern void fgPlatformMainLoopPreliminaryWork ( void );
|
extern void fgPlatformMainLoopPreliminaryWork ( void );
|
||||||
|
|
||||||
|
extern void fgPlatformInitWork(SFG_Window* window);
|
||||||
|
extern void fgPlatformPosResZordWork(SFG_Window* window, unsigned int workMask);
|
||||||
|
extern void fgPlatformVisibilityWork(SFG_Window* window);
|
||||||
|
|
||||||
|
|
||||||
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
||||||
@ -390,6 +392,57 @@ static void fghSleepForEvents( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Step through the work list */
|
||||||
|
void fgPlatformProcessWork(SFG_Window *window)
|
||||||
|
{
|
||||||
|
unsigned int workMask = window->State.WorkMask;
|
||||||
|
/* Now clear it so that any callback generated by the actions below can set work again */
|
||||||
|
window->State.WorkMask = 0;
|
||||||
|
|
||||||
|
if (workMask&~GLUT_DISPLAY_WORK) /* Display work is the common case, skip all the below at once */
|
||||||
|
{
|
||||||
|
if (workMask & GLUT_INIT_WORK)
|
||||||
|
{
|
||||||
|
/* This is before the first display callback: if needed for the platform,
|
||||||
|
* call a few callbacks to inform user of window size, position, etc
|
||||||
|
*/
|
||||||
|
fgPlatformInitWork(window);
|
||||||
|
|
||||||
|
/* Call init context callback */
|
||||||
|
INVOKE_WCB( *window, InitContext, ());
|
||||||
|
|
||||||
|
/* Lastly, check if we have a display callback, error out if not
|
||||||
|
* This is the right place to do it, as the redisplay will be
|
||||||
|
* next right after we exit this function, so there is no more
|
||||||
|
* opportunity for the user to register a callback for this window.
|
||||||
|
*/
|
||||||
|
if (!FETCH_WCB(*window, Display))
|
||||||
|
fgError ( "ERROR: No display callback registered for window %d\n", window->ID );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* On windows we can position, resize and change z order at the same time */
|
||||||
|
if (workMask & (GLUT_POSITION_WORK|GLUT_SIZE_WORK|GLUT_ZORDER_WORK|GLUT_FULL_SCREEN_WORK))
|
||||||
|
{
|
||||||
|
fgPlatformPosResZordWork(window,workMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (workMask & GLUT_VISIBILITY_WORK)
|
||||||
|
{
|
||||||
|
fgPlatformVisibilityWork(window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (workMask & GLUT_DISPLAY_WORK)
|
||||||
|
{
|
||||||
|
if( window->State.Visible )
|
||||||
|
fghRedrawWindow ( window );
|
||||||
|
|
||||||
|
/* Strip out display work that might have ended up on work list now as some of the above genereates callbacks */
|
||||||
|
window->State.WorkMask &= ~GLUT_DISPLAY_WORK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1541,20 +1541,8 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Step through the work list */
|
/* deal with work list items */
|
||||||
void fgPlatformProcessWork(SFG_Window *window)
|
void fgPlatformInitWork(SFG_Window* window)
|
||||||
{
|
|
||||||
unsigned int workMask = window->State.WorkMask;
|
|
||||||
/* Now clear it so that any callback generated by the actions below can set work again */
|
|
||||||
window->State.WorkMask = 0;
|
|
||||||
|
|
||||||
if (workMask&~GLUT_DISPLAY_WORK) /* Display work is the common case, skip all the below at once */
|
|
||||||
{
|
|
||||||
/* This is before the first display callback: call a few callbacks to inform user of window size, position, etc
|
|
||||||
* we know this is before the first display callback of a window as for all windows GLUT_INIT_WORK is set when
|
|
||||||
* they are opened, and work is done before displaying in the mainloop.
|
|
||||||
*/
|
|
||||||
if (workMask & GLUT_INIT_WORK)
|
|
||||||
{
|
{
|
||||||
RECT windowRect;
|
RECT windowRect;
|
||||||
|
|
||||||
@ -1568,21 +1556,10 @@ void fgPlatformProcessWork(SFG_Window *window)
|
|||||||
/* get and notify window's size */
|
/* get and notify window's size */
|
||||||
GetClientRect(window->Window.Handle,&windowRect);
|
GetClientRect(window->Window.Handle,&windowRect);
|
||||||
fghOnReshapeNotify(window, windowRect.right-windowRect.left, windowRect.bottom-windowRect.top, GL_TRUE);
|
fghOnReshapeNotify(window, windowRect.right-windowRect.left, windowRect.bottom-windowRect.top, GL_TRUE);
|
||||||
|
|
||||||
/* Call init context callback */
|
|
||||||
INVOKE_WCB( *window, InitContext, ());
|
|
||||||
|
|
||||||
/* Lastly, check if we have a display callback, error out if not
|
|
||||||
* This is the right place to do it, as the redisplay will be
|
|
||||||
* next right after we exit this function, so there is no more
|
|
||||||
* opportunity for the user to register a callback for this window.
|
|
||||||
*/
|
|
||||||
if (!FETCH_WCB(*window, Display))
|
|
||||||
fgError ( "ERROR: No display callback registered for window %d\n", window->ID );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* On windows we can position, resize and change z order at the same time */
|
/* On windows we can position, resize and change z order at the same time */
|
||||||
if (workMask & (GLUT_POSITION_WORK|GLUT_SIZE_WORK|GLUT_ZORDER_WORK|GLUT_FULL_SCREEN_WORK))
|
void fgPlatformPosResZordWork(SFG_Window* window, unsigned int workMask)
|
||||||
{
|
{
|
||||||
UINT flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOSIZE | SWP_NOZORDER;
|
UINT flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOSIZE | SWP_NOZORDER;
|
||||||
HWND insertAfter = HWND_TOP;
|
HWND insertAfter = HWND_TOP;
|
||||||
@ -1752,7 +1729,8 @@ void fgPlatformProcessWork(SFG_Window *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (workMask & GLUT_VISIBILITY_WORK)
|
|
||||||
|
void fgPlatformVisibilityWork(SFG_Window* window)
|
||||||
{
|
{
|
||||||
/* Visibility status of window gets updated in the WM_SHOWWINDOW and WM_SIZE handlers */
|
/* Visibility status of window gets updated in the WM_SHOWWINDOW and WM_SIZE handlers */
|
||||||
int cmdShow = 0;
|
int cmdShow = 0;
|
||||||
@ -1778,14 +1756,3 @@ void fgPlatformProcessWork(SFG_Window *window)
|
|||||||
|
|
||||||
ShowWindow( win->Window.Handle, cmdShow );
|
ShowWindow( win->Window.Handle, cmdShow );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (workMask & GLUT_DISPLAY_WORK)
|
|
||||||
{
|
|
||||||
if( window->State.Visible )
|
|
||||||
fghRedrawWindow ( window );
|
|
||||||
|
|
||||||
/* Strip out display work that might have ended up on work list now as some of the above genereates callbacks */
|
|
||||||
window->State.WorkMask &= ~GLUT_DISPLAY_WORK;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1078,38 +1078,19 @@ void fgPlatformMainLoopPreliminaryWork ( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Step through the work list */
|
/* deal with work list items */
|
||||||
void fgPlatformProcessWork(SFG_Window *window)
|
void fgPlatformInitWork(SFG_Window* window)
|
||||||
{
|
|
||||||
unsigned int workMask = window->State.WorkMask;
|
|
||||||
/* Now clear it so that any callback generated by the actions below can set work again */
|
|
||||||
window->State.WorkMask = 0;
|
|
||||||
|
|
||||||
if (workMask&~GLUT_DISPLAY_WORK) /* Display work is the common case, skip all the below at once */
|
|
||||||
{
|
|
||||||
/* This is before the first display callback: call a few callbacks to inform user of window size, position, etc
|
|
||||||
* we know this is before the first display callback of a window as for all windows GLUT_INIT_WORK is set when
|
|
||||||
* they are opened, and work is done before displaying in the mainloop.
|
|
||||||
*/
|
|
||||||
if (workMask & GLUT_INIT_WORK)
|
|
||||||
{
|
{
|
||||||
/* Notify windowStatus/visibility, position and size get notified on window creation with message handlers above
|
/* Notify windowStatus/visibility, position and size get notified on window creation with message handlers above
|
||||||
* XXX CHECK: do the messages happen too early like on windows, so client code cannot have registered
|
* XXX CHECK: do the messages happen too early like on windows, so client code cannot have registered
|
||||||
* a callback yet and the message is thus never received by client?
|
* a callback yet and the message is thus never received by client?
|
||||||
|
* -> this is a no-op
|
||||||
*/
|
*/
|
||||||
|
return;
|
||||||
/* Call init context callback */
|
|
||||||
INVOKE_WCB( *window, InitContext, ());
|
|
||||||
|
|
||||||
/* Lastly, check if we have a display callback, error out if not
|
|
||||||
* This is the right place to do it, as the redisplay will be
|
|
||||||
* next right after we exit this function, so there is no more
|
|
||||||
* opportunity for the user to register a callback for this window.
|
|
||||||
*/
|
|
||||||
if (!FETCH_WCB(*window, Display))
|
|
||||||
fgError ( "ERROR: No display callback registered for window %d\n", window->ID );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fgPlatformPosResZordWork(SFG_Window* window, unsigned int workMask)
|
||||||
|
{
|
||||||
if (workMask & GLUT_FULL_SCREEN_WORK)
|
if (workMask & GLUT_FULL_SCREEN_WORK)
|
||||||
fgPlatformFullScreenToggle( window );
|
fgPlatformFullScreenToggle( window );
|
||||||
if (workMask & GLUT_POSITION_WORK)
|
if (workMask & GLUT_POSITION_WORK)
|
||||||
@ -1123,8 +1104,9 @@ void fgPlatformProcessWork(SFG_Window *window)
|
|||||||
else
|
else
|
||||||
fgPlatformPopWindow( window );
|
fgPlatformPopWindow( window );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (workMask & GLUT_VISIBILITY_WORK)
|
void fgPlatformVisibilityWork(SFG_Window* window)
|
||||||
{
|
{
|
||||||
/* Visibility status of window gets updated in the window message handlers above
|
/* Visibility status of window gets updated in the window message handlers above
|
||||||
* XXX: is this really the case? check
|
* XXX: is this really the case? check
|
||||||
@ -1146,15 +1128,4 @@ void fgPlatformProcessWork(SFG_Window *window)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (workMask & GLUT_DISPLAY_WORK)
|
|
||||||
{
|
|
||||||
if( window->State.Visible )
|
|
||||||
fghRedrawWindow ( window );
|
|
||||||
|
|
||||||
/* Strip out display work that might have ended up on work list now as some of the above genereates callbacks */
|
|
||||||
window->State.WorkMask &= ~GLUT_DISPLAY_WORK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user