Moving platform-specific fields in "SFG_Display" into a substructure

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1011 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
fayjf 2012-01-29 02:45:04 +00:00
parent 488cd6ed75
commit ab2e6057aa
11 changed files with 191 additions and 186 deletions

View File

@ -57,14 +57,14 @@ static Cursor getEmptyCursor( void )
Pixmap cursorNonePixmap;
memset( cursorNoneBits, 0, sizeof( cursorNoneBits ) );
memset( &dontCare, 0, sizeof( dontCare ) );
cursorNonePixmap = XCreateBitmapFromData ( fgDisplay.Display,
fgDisplay.RootWindow,
cursorNonePixmap = XCreateBitmapFromData ( fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.RootWindow,
cursorNoneBits, 16, 16 );
if( cursorNonePixmap != None ) {
cursorNone = XCreatePixmapCursor( fgDisplay.Display,
cursorNone = XCreatePixmapCursor( fgDisplay.pDisplay.Display,
cursorNonePixmap, cursorNonePixmap,
&dontCare, &dontCare, 0, 0 );
XFreePixmap( fgDisplay.Display, cursorNonePixmap );
XFreePixmap( fgDisplay.pDisplay.Display, cursorNonePixmap );
}
}
return cursorNone;
@ -120,7 +120,7 @@ void fgPlatformSetCursor ( SFG_Window *window, int cursorID )
cursorCacheEntry *entry = &cursorCache[ cursorIDToUse ];
if( entry->cachedCursor == None ) {
entry->cachedCursor =
XCreateFontCursor( fgDisplay.Display, entry->cursorShape );
XCreateFontCursor( fgDisplay.pDisplay.Display, entry->cursorShape );
}
cursor = entry->cachedCursor;
} else {
@ -141,9 +141,9 @@ void fgPlatformSetCursor ( SFG_Window *window, int cursorID )
}
if ( cursorIDToUse == GLUT_CURSOR_INHERIT ) {
XUndefineCursor( fgDisplay.Display, window->Window.Handle );
XUndefineCursor( fgDisplay.pDisplay.Display, window->Window.Handle );
} else if ( cursor != None ) {
XDefineCursor( fgDisplay.Display, window->Window.Handle, cursor );
XDefineCursor( fgDisplay.pDisplay.Display, window->Window.Handle, cursor );
} else if ( cursorIDToUse != GLUT_CURSOR_NONE ) {
fgError( "Failed to create cursor" );
}
@ -153,14 +153,14 @@ void fgPlatformSetCursor ( SFG_Window *window, int cursorID )
void fgPlatformWarpPointer ( int x, int y )
{
XWarpPointer(
fgDisplay.Display,
fgDisplay.pDisplay.Display,
None,
fgStructure.CurrentWindow->Window.Handle,
0, 0, 0, 0,
x, y
);
/* Make the warp visible immediately. */
XFlush( fgDisplay.Display );
XFlush( fgDisplay.pDisplay.Display );
}
#endif

View File

@ -62,7 +62,7 @@ void FGAPIENTRY glutSwapBuffers( void )
return;
#if TARGET_HOST_POSIX_X11
glXSwapBuffers( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle );
glXSwapBuffers( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle );
#elif TARGET_HOST_MS_WINDOWS
SwapBuffers( fgStructure.CurrentWindow->Window.Device );
#endif

View File

@ -53,11 +53,11 @@ static int xrandr_resize(int xsz, int ysz, int rate, int just_checking)
Status result = -1;
/* must check at runtime for the availability of the extension */
if(!XRRQueryExtension(fgDisplay.Display, &event_base, &error_base)) {
if(!XRRQueryExtension(fgDisplay.pDisplay.Display, &event_base, &error_base)) {
return -1;
}
XRRQueryVersion(fgDisplay.Display, &ver_major, &ver_minor);
XRRQueryVersion(fgDisplay.pDisplay.Display, &ver_major, &ver_minor);
/* we only heed the rate if we CAN actually use it (Xrandr >= 1.1) and
* the user actually cares about it (rate > 0)
@ -80,7 +80,7 @@ static int xrandr_resize(int xsz, int ysz, int rate, int just_checking)
XRRFreeScreenConfigInfo(xrr_config);
}
if(!(xrr_config = XRRGetScreenInfo(fgDisplay.Display, fgDisplay.RootWindow))) {
if(!(xrr_config = XRRGetScreenInfo(fgDisplay.pDisplay.Display, fgDisplay.RootWindow))) {
fgWarning("XRRGetScreenInfo failed");
break;
}
@ -136,12 +136,12 @@ static int xrandr_resize(int xsz, int ysz, int rate, int just_checking)
#if ( RANDR_MAJOR >= 1 ) || ( ( RANDR_MAJOR == 1 ) && ( RANDR_MINOR >= 1 ) )
if(use_rate)
result = XRRSetScreenConfigAndRate(fgDisplay.Display, xrr_config,
fgDisplay.RootWindow, res_idx, rot, rate, timestamp);
result = XRRSetScreenConfigAndRate(fgDisplay.pDisplay.Display, xrr_config,
fgDisplay.pDisplay.RootWindow, res_idx, rot, rate, timestamp);
else
#endif
result = XRRSetScreenConfig(fgDisplay.Display, xrr_config,
fgDisplay.RootWindow, res_idx, rot, timestamp);
result = XRRSetScreenConfig(fgDisplay.pDisplay.Display, xrr_config,
fgDisplay.pDisplay.RootWindow, res_idx, rot, timestamp);
} while(result == RRSetConfigInvalidTime);
@ -174,33 +174,33 @@ void fgPlatformRememberState( void )
Window junk_window;
unsigned int junk_mask;
XQueryPointer(fgDisplay.Display, fgDisplay.RootWindow,
XQueryPointer(fgDisplay.pDisplay.Display, fgDisplay.pDisplay.RootWindow,
&junk_window, &junk_window,
&fgDisplay.DisplayPointerX, &fgDisplay.DisplayPointerY,
&fgDisplay.DisplayPointerX, &fgDisplay.DisplayPointerY, &junk_mask);
&fgDisplay.pDisplay.DisplayPointerX, &fgDisplay.pDisplay.DisplayPointerY,
&fgDisplay.pDisplay.DisplayPointerX, &fgDisplay.pDisplay.DisplayPointerY, &junk_mask);
# ifdef HAVE_X11_EXTENSIONS_XRANDR_H
if(XRRQueryExtension(fgDisplay.Display, &event_base, &error_base)) {
if(XRRQueryExtension(fgDisplay.pDisplay.Display, &event_base, &error_base)) {
XRRScreenConfiguration *xrr_config;
XRRScreenSize *ssizes;
Rotation rot;
int ssize_count, curr;
if((xrr_config = XRRGetScreenInfo(fgDisplay.Display, fgDisplay.RootWindow))) {
if((xrr_config = XRRGetScreenInfo(fgDisplay.pDisplay.Display, fgDisplay.pDisplay.RootWindow))) {
ssizes = XRRConfigSizes(xrr_config, &ssize_count);
curr = XRRConfigCurrentConfiguration(xrr_config, &rot);
fgDisplay.prev_xsz = ssizes[curr].width;
fgDisplay.prev_ysz = ssizes[curr].height;
fgDisplay.prev_refresh = -1;
fgDisplay.pDisplay.prev_xsz = ssizes[curr].width;
fgDisplay.pDisplay.prev_ysz = ssizes[curr].height;
fgDisplay.pDisplay.prev_refresh = -1;
# if ( RANDR_MAJOR >= 1 ) || ( ( RANDR_MAJOR == 1 ) && ( RANDR_MINOR >= 1 ) )
if(fgState.GameModeRefresh != -1) {
fgDisplay.prev_refresh = XRRConfigCurrentRate(xrr_config);
fgDisplay.pDisplay.prev_refresh = XRRConfigCurrentRate(xrr_config);
}
# endif
fgDisplay.prev_size_valid = 1;
fgDisplay.pDisplay.prev_size_valid = 1;
XRRFreeScreenConfigInfo(xrr_config);
}
@ -212,7 +212,7 @@ void fgPlatformRememberState( void )
* not approved as X Consortium standards
*/
# ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
if(!XF86VidModeQueryExtension(fgDisplay.Display, &event_base, &error_base)) {
if(!XF86VidModeQueryExtension(fgDisplay.pDisplay.Display, &event_base, &error_base)) {
return;
}
@ -221,23 +221,23 @@ void fgPlatformRememberState( void )
* restore the ViewPort on LeaveGameMode():
*/
if( !XF86VidModeGetViewPort(
fgDisplay.Display,
fgDisplay.Screen,
&fgDisplay.DisplayViewPortX,
&fgDisplay.DisplayViewPortY ) )
fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen,
&fgDisplay.pDisplay.DisplayViewPortX,
&fgDisplay.pDisplay.DisplayViewPortY ) )
fgWarning( "XF86VidModeGetViewPort failed" );
/* Query the current display settings: */
fgDisplay.DisplayModeValid =
fgDisplay.pDisplay.DisplayModeValid =
XF86VidModeGetModeLine(
fgDisplay.Display,
fgDisplay.Screen,
&fgDisplay.DisplayModeClock,
&fgDisplay.DisplayMode
fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen,
&fgDisplay.pDisplay.DisplayModeClock,
&fgDisplay.pDisplay.DisplayMode
);
if( !fgDisplay.DisplayModeValid )
if( !fgDisplay.pDisplay.DisplayModeValid )
fgWarning( "XF86VidModeGetModeLine failed" );
# endif
@ -252,17 +252,17 @@ void fgPlatformRestoreState( void )
{
/* Restore the remembered pointer position: */
XWarpPointer(
fgDisplay.Display, None, fgDisplay.RootWindow, 0, 0, 0, 0,
fgDisplay.DisplayPointerX, fgDisplay.DisplayPointerY
fgDisplay.pDisplay.Display, None, fgDisplay.pDisplay.RootWindow, 0, 0, 0, 0,
fgDisplay.pDisplay.DisplayPointerX, fgDisplay.pDisplay.DisplayPointerY
);
# ifdef HAVE_X11_EXTENSIONS_XRANDR_H
if(fgDisplay.prev_size_valid) {
if(xrandr_resize(fgDisplay.prev_xsz, fgDisplay.prev_ysz, fgDisplay.prev_refresh, 0) != -1) {
fgDisplay.prev_size_valid = 0;
if(fgDisplay.pDisplay.prev_size_valid) {
if(xrandr_resize(fgDisplay.pDisplay.prev_xsz, fgDisplay.pDisplay.prev_ysz, fgDisplay.pDisplay.prev_refresh, 0) != -1) {
fgDisplay.pDisplay.prev_size_valid = 0;
# ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
fgDisplay.DisplayModeValid = 0;
fgDisplay.pDisplay.DisplayModeValid = 0;
# endif
return;
}
@ -277,14 +277,14 @@ void fgPlatformRestoreState( void )
* not approved as X Consortium standards
*/
if( fgDisplay.DisplayModeValid )
if( fgDisplay.pDisplay.DisplayModeValid )
{
XF86VidModeModeInfo** displayModes;
int i, displayModesCount;
if( !XF86VidModeGetAllModeLines(
fgDisplay.Display,
fgDisplay.Screen,
fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen,
&displayModesCount,
&displayModes ) )
{
@ -299,13 +299,13 @@ void fgPlatformRestoreState( void )
*/
for( i = 0; i < displayModesCount; i++ )
{
if(displayModes[ i ]->hdisplay == fgDisplay.DisplayMode.hdisplay &&
displayModes[ i ]->vdisplay == fgDisplay.DisplayMode.vdisplay &&
displayModes[ i ]->dotclock == fgDisplay.DisplayModeClock )
if(displayModes[ i ]->hdisplay == fgDisplay.pDisplay.DisplayMode.hdisplay &&
displayModes[ i ]->vdisplay == fgDisplay.pDisplay.DisplayMode.vdisplay &&
displayModes[ i ]->dotclock == fgDisplay.pDisplay.DisplayModeClock )
{
if( !XF86VidModeSwitchToMode(
fgDisplay.Display,
fgDisplay.Screen,
fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen,
displayModes[ i ] ) )
{
fgWarning( "XF86VidModeSwitchToMode failed" );
@ -313,10 +313,10 @@ void fgPlatformRestoreState( void )
}
if( !XF86VidModeSetViewPort(
fgDisplay.Display,
fgDisplay.Screen,
fgDisplay.DisplayViewPortX,
fgDisplay.DisplayViewPortY ) )
fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen,
fgDisplay.pDisplay.DisplayViewPortX,
fgDisplay.pDisplay.DisplayViewPortY ) )
fgWarning( "XF86VidModeSetViewPort failed" );
@ -325,11 +325,11 @@ void fgPlatformRestoreState( void )
* calls exit() we've to flush the X11 output queue to have the
* commands sent to the X server before the application exits.
*/
XFlush( fgDisplay.Display );
XFlush( fgDisplay.pDisplay.Display );
fgDisplay.DisplayModeValid = 0;
fgDisplay.pDisplay.DisplayModeValid = 0;
# ifdef HAVE_X11_EXTENSIONS_XRANDR_H
fgDisplay.prev_size_valid = 0;
fgDisplay.pDisplay.prev_size_valid = 0;
# endif
break;
@ -420,7 +420,7 @@ GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
* This is also used by applications which check modes by calling
* glutGameModeGet(GLUT_GAME_MODE_POSSIBLE), so allow the check:
*/
if( haveToTest || fgDisplay.DisplayModeValid )
if( haveToTest || fgDisplay.pDisplay.DisplayModeValid )
{
XF86VidModeModeInfo** displayModes;
int i, displayModesCount;
@ -430,20 +430,20 @@ GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
* glutEnterGameMode, then we need to query the current mode, to make
* unspecified settings to default to their current values.
*/
if(!fgDisplay.DisplayModeValid) {
if(!XF86VidModeGetModeLine(fgDisplay.Display, fgDisplay.Screen,
&fgDisplay.DisplayModeClock, &fgDisplay.DisplayMode)) {
if(!fgDisplay.pDisplay.DisplayModeValid) {
if(!XF86VidModeGetModeLine(fgDisplay.pDisplay.Display, fgDisplay.pDisplay.Screen,
&fgDisplay.pDisplay.DisplayModeClock, &fgDisplay.pDisplay.DisplayMode)) {
return success;
}
}
if (fgState.GameModeSize.X == -1)
{
fgState.GameModeSize.X = fgDisplay.DisplayMode.hdisplay;
fgState.GameModeSize.X = fgDisplay.pDisplay.DisplayMode.hdisplay;
}
if (fgState.GameModeSize.Y == -1)
{
fgState.GameModeSize.Y = fgDisplay.DisplayMode.vdisplay;
fgState.GameModeSize.Y = fgDisplay.pDisplay.DisplayMode.vdisplay;
}
if (fgState.GameModeDepth == -1)
{
@ -454,16 +454,16 @@ GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
if (fgState.GameModeRefresh == -1)
{
/* Compute the displays refresh rate, dotclock comes in kHz. */
int refresh = ( fgDisplay.DisplayModeClock * 1000 ) /
( fgDisplay.DisplayMode.htotal * fgDisplay.DisplayMode.vtotal );
int refresh = ( fgDisplay.pDisplay.DisplayModeClock * 1000 ) /
( fgDisplay.pDisplay.DisplayMode.htotal * fgDisplay.pDisplay.DisplayMode.vtotal );
fgState.GameModeRefresh = refresh;
}
/* query all possible display modes */
if( !XF86VidModeGetAllModeLines(
fgDisplay.Display,
fgDisplay.Screen,
fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen,
&displayModesCount,
&displayModes ) )
{
@ -484,8 +484,8 @@ GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
if( !haveToTest && success ) {
if( !XF86VidModeSwitchToMode(
fgDisplay.Display,
fgDisplay.Screen,
fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen,
displayModes[ i ] ) )
fgWarning( "XF86VidModeSwitchToMode failed" );
}
@ -576,7 +576,7 @@ int FGAPIENTRY glutEnterGameMode( void )
* Sync needed to avoid a real race, the Xserver must have really created
* the window before we can grab the pointer into it:
*/
XSync( fgDisplay.Display, False );
XSync( fgDisplay.pDisplay.Display, False );
/*
* Grab the pointer to confine it into the window after the calls to
* XWrapPointer() which ensure that the pointer really enters the window.
@ -587,7 +587,7 @@ int FGAPIENTRY glutEnterGameMode( void )
* the application which we have to aviod, so wait until it's viewable:
*/
while( GrabSuccess != XGrabPointer(
fgDisplay.Display, fgStructure.GameModeWindow->Window.Handle,
fgDisplay.pDisplay.Display, fgStructure.GameModeWindow->Window.Handle,
TRUE,
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask
| PointerMotionMask,
@ -599,7 +599,7 @@ int FGAPIENTRY glutEnterGameMode( void )
* if the new window is not viewable yet, see the XGrabPointer loop above.
*/
XSetInputFocus(
fgDisplay.Display,
fgDisplay.pDisplay.Display,
fgStructure.GameModeWindow->Window.Handle,
RevertToNone,
CurrentTime
@ -607,22 +607,22 @@ int FGAPIENTRY glutEnterGameMode( void )
/* Move the Pointer to the middle of the fullscreen window */
XWarpPointer(
fgDisplay.Display,
fgDisplay.pDisplay.Display,
None,
fgDisplay.RootWindow,
fgDisplay.pDisplay.RootWindow,
0, 0, 0, 0,
fgState.GameModeSize.X/2, fgState.GameModeSize.Y/2
);
# ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
if( fgDisplay.DisplayModeValid )
if( fgDisplay.pDisplay.DisplayModeValid )
{
int x, y;
Window child;
/* Change to viewport to the window topleft edge: */
if( !XF86VidModeSetViewPort( fgDisplay.Display, fgDisplay.Screen, 0, 0 ) )
if( !XF86VidModeSetViewPort( fgDisplay.pDisplay.Display, fgDisplay.Screen, 0, 0 ) )
fgWarning( "XF86VidModeSetViewPort failed" );
/*
@ -633,15 +633,15 @@ int FGAPIENTRY glutEnterGameMode( void )
/* Get the current postion of the drawable area on screen */
XTranslateCoordinates(
fgDisplay.Display,
fgDisplay.pDisplay.Display,
fgStructure.CurrentWindow->Window.Handle,
fgDisplay.RootWindow,
fgDisplay.pDisplay.RootWindow,
0, 0, &x, &y,
&child
);
/* Move the decorataions out of the topleft corner of the display */
XMoveWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle,
XMoveWindow( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle,
-x, -y);
}
@ -649,7 +649,7 @@ int FGAPIENTRY glutEnterGameMode( void )
/* Grab the keyboard, too */
XGrabKeyboard(
fgDisplay.Display,
fgDisplay.pDisplay.Display,
fgStructure.GameModeWindow->Window.Handle,
FALSE,
GrabModeAsync, GrabModeAsync,
@ -675,8 +675,8 @@ void FGAPIENTRY glutLeaveGameMode( void )
#if TARGET_HOST_POSIX_X11
XUngrabPointer( fgDisplay.Display, CurrentTime );
XUngrabKeyboard( fgDisplay.Display, CurrentTime );
XUngrabPointer( fgDisplay.pDisplay.Display, CurrentTime );
XUngrabKeyboard( fgDisplay.pDisplay.Display, CurrentTime );
#endif

View File

@ -109,7 +109,7 @@ extern void fgPlatformCloseDisplay ( void );
/* Return the atom associated with "name". */
static Atom fghGetAtom(const char * name)
{
return XInternAtom(fgDisplay.Display, name, False);
return XInternAtom(fgDisplay.pDisplay.Display, name, False);
}
/*
@ -137,7 +137,7 @@ static int fghGetWindowProperty(Window window,
unsigned long temp_bytes_after; /* Not used. */
status = XGetWindowProperty(fgDisplay.Display,
status = XGetWindowProperty(fgDisplay.pDisplay.Display,
window,
property,
0,
@ -181,7 +181,7 @@ static int fghNetWMSupported(void)
* Check that the window manager has set this property on the root window.
* The property must be the ID of a child window.
*/
number_of_windows = fghGetWindowProperty(fgDisplay.RootWindow,
number_of_windows = fghGetWindowProperty(fgDisplay.pDisplay.RootWindow,
wm_check,
XA_WINDOW,
(unsigned char **) window_ptr_1);
@ -248,47 +248,47 @@ int fgHintPresent(Window window, Atom property, Atom hint)
*/
void fgPlatformInitialize( const char* displayName )
{
fgDisplay.Display = XOpenDisplay( displayName );
fgDisplay.pDisplay.Display = XOpenDisplay( displayName );
if( fgDisplay.Display == NULL )
if( fgDisplay.pDisplay.Display == NULL )
fgError( "failed to open display '%s'", XDisplayName( displayName ) );
if( !glXQueryExtension( fgDisplay.Display, NULL, NULL ) )
if( !glXQueryExtension( fgDisplay.pDisplay.Display, NULL, NULL ) )
fgError( "OpenGL GLX extension not supported by display '%s'",
XDisplayName( displayName ) );
fgDisplay.Screen = DefaultScreen( fgDisplay.Display );
fgDisplay.RootWindow = RootWindow(
fgDisplay.Display,
fgDisplay.Screen
fgDisplay.pDisplay.Screen = DefaultScreen( fgDisplay.pDisplay.Display );
fgDisplay.pDisplay.RootWindow = RootWindow(
fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen
);
fgDisplay.ScreenWidth = DisplayWidth(
fgDisplay.Display,
fgDisplay.Screen
fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen
);
fgDisplay.ScreenHeight = DisplayHeight(
fgDisplay.Display,
fgDisplay.Screen
fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen
);
fgDisplay.ScreenWidthMM = DisplayWidthMM(
fgDisplay.Display,
fgDisplay.Screen
fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen
);
fgDisplay.ScreenHeightMM = DisplayHeightMM(
fgDisplay.Display,
fgDisplay.Screen
fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen
);
fgDisplay.Connection = ConnectionNumber( fgDisplay.Display );
fgDisplay.pDisplay.Connection = ConnectionNumber( fgDisplay.pDisplay.Display );
/* Create the window deletion atom */
fgDisplay.DeleteWindow = fghGetAtom("WM_DELETE_WINDOW");
fgDisplay.pDisplay.DeleteWindow = fghGetAtom("WM_DELETE_WINDOW");
/* Create the state and full screen atoms */
fgDisplay.State = None;
fgDisplay.StateFullScreen = None;
fgDisplay.pDisplay.State = None;
fgDisplay.pDisplay.StateFullScreen = None;
if (fghNetWMSupported())
{
@ -296,17 +296,17 @@ void fgPlatformInitialize( const char* displayName )
const Atom state = fghGetAtom("_NET_WM_STATE");
/* Check if the state hint is supported. */
if (fgHintPresent(fgDisplay.RootWindow, supported, state))
if (fgHintPresent(fgDisplay.pDisplay.RootWindow, supported, state))
{
const Atom full_screen = fghGetAtom("_NET_WM_STATE_FULLSCREEN");
fgDisplay.State = state;
fgDisplay.pDisplay.State = state;
/* Check if the window manager supports full screen. */
/** Check "_NET_WM_ALLOWED_ACTIONS" on our window instead? **/
if (fgHintPresent(fgDisplay.RootWindow, supported, full_screen))
if (fgHintPresent(fgDisplay.pDisplay.RootWindow, supported, full_screen))
{
fgDisplay.StateFullScreen = full_screen;
fgDisplay.pDisplay.StateFullScreen = full_screen;
}
}
}
@ -452,13 +452,13 @@ void fgPlatformCloseDisplay ( void )
* Make sure all X-client data we have created will be destroyed on
* display closing
*/
XSetCloseDownMode( fgDisplay.Display, DestroyAll );
XSetCloseDownMode( fgDisplay.pDisplay.Display, DestroyAll );
/*
* Close the display connection, destroying all windows we have
* created so far
*/
XCloseDisplay( fgDisplay.Display );
XCloseDisplay( fgDisplay.pDisplay.Display );
}
#endif
@ -486,7 +486,7 @@ void fgDeinitialize( void )
{
#if TARGET_HOST_POSIX_X11
/* Note that the MVisualInfo is not owned by the MenuContext! */
glXDestroyContext( fgDisplay.Display, fgStructure.MenuContext->MContext );
glXDestroyContext( fgDisplay.pDisplay.Display, fgStructure.MenuContext->MContext );
#endif
free( fgStructure.MenuContext );
fgStructure.MenuContext = NULL;

View File

@ -214,6 +214,39 @@ LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
/* Platform-specific includes */
#if TARGET_HOST_POSIX_X11
typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
struct tagSFG_PlatformDisplay
{
Display* Display; /* The display we are being run in. */
int Screen; /* The screen we are about to use. */
Window RootWindow; /* The screen's root window. */
int Connection; /* The display's connection number */
Atom DeleteWindow; /* The window deletion atom */
Atom State; /* The state atom */
Atom StateFullScreen; /* The full screen atom */
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
int prev_xsz, prev_ysz;
int prev_refresh;
int prev_size_valid;
#endif /* HAVE_X11_EXTENSIONS_XRANDR_H */
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
/*
* XF86VidMode may be compilable even if it fails at runtime. Therefore,
* the validity of the VidMode has to be tracked
*/
int DisplayModeValid; /* Flag that indicates runtime status*/
XF86VidModeModeLine DisplayMode; /* Current screen's display settings */
int DisplayModeClock; /* The display mode's refresh rate */
int DisplayViewPortX; /* saved X location of the viewport */
int DisplayViewPortY; /* saved Y location of the viewport */
#endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */
int DisplayPointerX; /* saved X location of the pointer */
int DisplayPointerY; /* saved Y location of the pointer */
};
#endif
#if TARGET_HOST_MS_WINDOWS
#include "../mswin/freeglut_internal_mswin.h"
@ -366,42 +399,7 @@ struct tagSFG_State
typedef struct tagSFG_Display SFG_Display;
struct tagSFG_Display
{
#if TARGET_HOST_POSIX_X11
Display* Display; /* The display we are being run in. */
int Screen; /* The screen we are about to use. */
Window RootWindow; /* The screen's root window. */
int Connection; /* The display's connection number */
Atom DeleteWindow; /* The window deletion atom */
Atom State; /* The state atom */
Atom StateFullScreen; /* The full screen atom */
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
int prev_xsz, prev_ysz;
int prev_refresh;
int prev_size_valid;
#endif /* HAVE_X11_EXTENSIONS_XRANDR_H */
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
/*
* XF86VidMode may be compilable even if it fails at runtime. Therefore,
* the validity of the VidMode has to be tracked
*/
int DisplayModeValid; /* Flag that indicates runtime status*/
XF86VidModeModeLine DisplayMode; /* Current screen's display settings */
int DisplayModeClock; /* The display mode's refresh rate */
int DisplayViewPortX; /* saved X location of the viewport */
int DisplayViewPortY; /* saved Y location of the viewport */
#endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */
int DisplayPointerX; /* saved X location of the pointer */
int DisplayPointerY; /* saved Y location of the pointer */
#elif TARGET_HOST_MS_WINDOWS
HINSTANCE Instance; /* The application's instance */
DEVMODE DisplayMode; /* Desktop's display settings */
char *DisplayName; /* Display name for multi display support*/
#endif
SFG_PlatformDisplay pDisplay;
int ScreenWidth; /* The screen's width in pixels */
int ScreenHeight; /* The screen's height in pixels */

View File

@ -98,9 +98,9 @@ extern void fgPlatformMainLoopPreliminaryWork ( void );
#if TARGET_HOST_POSIX_X11
void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height )
{
XResizeWindow( fgDisplay.Display, window->Window.Handle,
XResizeWindow( fgDisplay.pDisplay.Display, window->Window.Handle,
width, height );
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */
}
#endif
@ -427,14 +427,14 @@ void fgPlatformSleepForEvents( long msec )
* need to allow that we may have an empty socket but non-
* empty event queue.
*/
if( ! XPending( fgDisplay.Display ) )
if( ! XPending( fgDisplay.pDisplay.Display ) )
{
fd_set fdset;
int err;
int socket;
struct timeval wait;
socket = ConnectionNumber( fgDisplay.Display );
socket = ConnectionNumber( fgDisplay.pDisplay.Display );
FD_ZERO( &fdset );
FD_SET( socket, &fdset );
wait.tv_sec = msec / 1000;
@ -943,9 +943,9 @@ void fgPlatformProcessSingleEvent ( void )
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoopEvent" );
while( XPending( fgDisplay.Display ) )
while( XPending( fgDisplay.pDisplay.Display ) )
{
XNextEvent( fgDisplay.Display, &event );
XNextEvent( fgDisplay.pDisplay.Display, &event );
#if _DEBUG
fghPrintEvent( &event );
#endif
@ -958,7 +958,7 @@ void fgPlatformProcessSingleEvent ( void )
break;
}
/* Destroy the window when the WM_DELETE_WINDOW message arrives */
if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.pDisplay.DeleteWindow )
{
GETWINDOW( xclient );
@ -1256,7 +1256,7 @@ void fgPlatformProcessSingleEvent ( void )
*/
char keys[32];
XQueryKeymap( fgDisplay.Display, keys ); /* Look at X11 keystate to detect repeat mode */
XQueryKeymap( fgDisplay.pDisplay.Display, keys ); /* Look at X11 keystate to detect repeat mode */
if ( event.xkey.keycode<256 ) /* XQueryKeymap is limited to 256 keycodes */
{

View File

@ -149,9 +149,9 @@ GLvoid fgPlatformGetGameModeVMaxExtent( SFG_Window* window, int* x, int* y )
Window w;
XTranslateCoordinates(
fgDisplay.Display,
fgDisplay.pDisplay.Display,
window->Window.Handle,
fgDisplay.RootWindow,
fgDisplay.pDisplay.RootWindow,
0, 0, &wx, &wy, &w);
*x = fgState.GameModeSize.X + wx;

View File

@ -41,11 +41,11 @@ void fgPlatformRememberState( void )
/* hack to get around my stupid cross-gcc headers */
#define FREEGLUT_ENUM_CURRENT_SETTINGS -1
EnumDisplaySettings( fgDisplay.DisplayName, FREEGLUT_ENUM_CURRENT_SETTINGS,
&fgDisplay.DisplayMode );
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, FREEGLUT_ENUM_CURRENT_SETTINGS,
&fgDisplay.pDisplay.DisplayMode );
/* Make sure we will be restoring all settings needed */
fgDisplay.DisplayMode.dmFields |=
fgDisplay.pDisplay.DisplayMode.dmFields |=
DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
}
@ -56,7 +56,7 @@ void fgPlatformRememberState( void )
void fgPlatformRestoreState( void )
{
/* Restore the previously remembered desktop display settings */
ChangeDisplaySettingsEx( fgDisplay.DisplayName,&fgDisplay.DisplayMode, 0,0,0 );
ChangeDisplaySettingsEx( fgDisplay.pDisplay.DisplayName,&fgDisplay.pDisplay.DisplayMode, 0,0,0 );
}
@ -75,7 +75,7 @@ GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
success = GL_FALSE;
EnumDisplaySettings( fgDisplay.DisplayName, -1, &devMode );
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, -1, &devMode );
devMode.dmFields = 0;
if (fgState.GameModeSize.X!=-1)
@ -99,7 +99,7 @@ GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
devMode.dmFields |= DM_DISPLAYFREQUENCY;
}
switch ( ChangeDisplaySettingsEx(fgDisplay.DisplayName, &devMode, NULL, haveToTest ? CDS_TEST : CDS_FULLSCREEN , NULL) )
switch ( ChangeDisplaySettingsEx(fgDisplay.pDisplay.DisplayName, &devMode, NULL, haveToTest ? CDS_TEST : CDS_FULLSCREEN , NULL) )
{
case DISP_CHANGE_SUCCESSFUL:
success = GL_TRUE;
@ -107,7 +107,7 @@ GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
if (!haveToTest)
{
/* update vars in case if windows switched to proper mode */
EnumDisplaySettings( fgDisplay.DisplayName, FREEGLUT_ENUM_CURRENT_SETTINGS, &devMode );
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, FREEGLUT_ENUM_CURRENT_SETTINGS, &devMode );
fgState.GameModeSize.X = devMode.dmPelsWidth;
fgState.GameModeSize.Y = devMode.dmPelsHeight;
fgState.GameModeDepth = devMode.dmBitsPerPel;

View File

@ -43,9 +43,9 @@ void fgPlatformInitialize( const char* displayName )
ATOM atom;
/* What we need to do is to initialize the fgDisplay global structure here. */
fgDisplay.Instance = GetModuleHandle( NULL );
fgDisplay.DisplayName= displayName ? strdup(displayName) : 0 ;
atom = GetClassInfo( fgDisplay.Instance, _T("FREEGLUT"), &wc );
fgDisplay.pDisplay.Instance = GetModuleHandle( NULL );
fgDisplay.pDisplay.DisplayName= displayName ? strdup(displayName) : 0 ;
atom = GetClassInfo( fgDisplay.pDisplay.Instance, _T("FREEGLUT"), &wc );
if( atom == 0 )
{
@ -62,8 +62,8 @@ void fgPlatformInitialize( const char* displayName )
wc.lpfnWndProc = fgPlatformWindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = fgDisplay.Instance;
wc.hIcon = LoadIcon( fgDisplay.Instance, _T("GLUT_ICON") );
wc.hInstance = fgDisplay.pDisplay.Instance;
wc.hIcon = LoadIcon( fgDisplay.pDisplay.Instance, _T("GLUT_ICON") );
#if defined(_WIN32_WCE)
wc.style = CS_HREDRAW | CS_VREDRAW;
@ -97,9 +97,9 @@ void fgPlatformInitialize( const char* displayName )
ReleaseDC( desktop, context );
}
/* If we have a DisplayName try to use it for metrics */
if( fgDisplay.DisplayName )
if( fgDisplay.pDisplay.DisplayName )
{
HDC context = CreateDC(fgDisplay.DisplayName,0,0,0);
HDC context = CreateDC(fgDisplay.pDisplay.DisplayName,0,0,0);
if( context )
{
fgDisplay.ScreenWidth = GetDeviceCaps( context, HORZRES );
@ -147,10 +147,10 @@ void fgPlatformDeinitialiseInputDevices ( void )
void fgPlatformCloseDisplay ( void )
{
if( fgDisplay.DisplayName )
if( fgDisplay.pDisplay.DisplayName )
{
free( fgDisplay.DisplayName );
fgDisplay.DisplayName = NULL;
free( fgDisplay.pDisplay.DisplayName );
fgDisplay.pDisplay.DisplayName = NULL;
}
/* Reset the timer granularity */

View File

@ -28,6 +28,13 @@
#ifndef FREEGLUT_INTERNAL_MSWIN_H
#define FREEGLUT_INTERNAL_MSWIN_H
typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
struct tagSFG_PlatformDisplay
{
HINSTANCE Instance; /* The application's instance */
DEVMODE DisplayMode; /* Desktop's display settings */
char *DisplayName; /* Display name for multi display support*/
};

View File

@ -313,12 +313,12 @@ GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
/* create a dummy window */
ZeroMemory(&wndCls, sizeof(wndCls));
wndCls.lpfnWndProc = DefWindowProc;
wndCls.hInstance = fgDisplay.Instance;
wndCls.hInstance = fgDisplay.pDisplay.Instance;
wndCls.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
wndCls.lpszClassName = _T("FREEGLUT_dummy");
RegisterClass( &wndCls );
hWnd=CreateWindow(_T("FREEGLUT_dummy"), _T(""), WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW , 0,0,0,0, 0, 0, fgDisplay.Instance, 0 );
hWnd=CreateWindow(_T("FREEGLUT_dummy"), _T(""), WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW , 0,0,0,0, 0, 0, fgDisplay.pDisplay.Instance, 0 );
hDC=GetDC(hWnd);
SetPixelFormat( hDC, pixelformat, ppfd );
@ -350,7 +350,7 @@ GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
wglDeleteContext(rc);
ReleaseDC(hWnd, hDC);
DestroyWindow(hWnd);
UnregisterClass(_T("FREEGLUT_dummy"), fgDisplay.Instance);
UnregisterClass(_T("FREEGLUT_dummy"), fgDisplay.pDisplay.Instance);
}
success = ( pixelformat != 0 ) && ( checkOnly || SetPixelFormat( current_hDC, pixelformat, ppfd ) );
@ -571,7 +571,7 @@ static BOOL CALLBACK m_proc(HMONITOR mon,
/*
* this function returns the origin of the screen identified by
* fgDisplay.DisplayName, and 0 otherwise.
* fgDisplay.pDisplay.DisplayName, and 0 otherwise.
* This is used in fgOpenWindow to open the gamemode window on the screen
* identified by the -display command line argument. The function should
* not be called otherwise.
@ -582,12 +582,12 @@ static void get_display_origin(int *xp,int *yp)
*xp = 0;
*yp = 0;
if( fgDisplay.DisplayName )
if( fgDisplay.pDisplay.DisplayName )
{
m_proc_t st;
st.x=xp;
st.y=yp;
st.name=fgDisplay.DisplayName;
st.name=fgDisplay.pDisplay.DisplayName;
EnumDisplayMonitors(0,0,m_proc,(LPARAM)&st);
}
}
@ -599,7 +599,7 @@ static void get_display_origin(int *xp,int *yp)
*xp = 0;
*yp = 0;
if( fgDisplay.DisplayName )
if( fgDisplay.pDisplay.DisplayName )
{
fgWarning( "for working -display support FreeGLUT must be compiled with WINVER >= 0x0500");
}
@ -624,7 +624,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
ATOM atom;
/* Grab the window class we have registered on glutInit(): */
atom = GetClassInfo( fgDisplay.Instance, _T("FREEGLUT"), &wc );
atom = GetClassInfo( fgDisplay.pDisplay.Instance, _T("FREEGLUT"), &wc );
FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Info Not Found",
"fgOpenWindow" );
@ -748,7 +748,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
0,0, 240,320,
NULL,
NULL,
fgDisplay.Instance,
fgDisplay.pDisplay.Instance,
(LPVOID) window
);
@ -770,7 +770,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
x, y, w, h,
(HWND) window->Parent == NULL ? NULL : window->Parent->Window.Handle,
(HMENU) NULL,
fgDisplay.Instance,
fgDisplay.pDisplay.Instance,
(LPVOID) window
);
#endif /* defined(_WIN32_WCE) */