4 * Window management methods.
6 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7 * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8 * Creation date: Fri Dec 3 1999
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #include "../include/GL/freeglut.h"
33 #include "freeglut_internal.h"
36 * TODO BEFORE THE STABLE RELEASE:
38 * fgChooseVisual() -- OK, but what about glutInitDisplayString()?
39 * fgSetupPixelFormat -- ignores the display mode settings
40 * fgOpenWindow() -- check the Win32 version, -iconic handling!
41 * fgCloseWindow() -- check the Win32 version
42 * glutCreateWindow() -- Check when default position and size is {-1,-1}
43 * glutCreateSubWindow() -- Check when default position and size is {-1,-1}
44 * glutDestroyWindow() -- check the Win32 version
45 * glutSetWindow() -- check the Win32 version
46 * glutGetWindow() -- OK
47 * glutSetWindowTitle() -- check the Win32 version
48 * glutSetIconTitle() -- check the Win32 version
49 * glutShowWindow() -- check the Win32 version
50 * glutHideWindow() -- check the Win32 version
51 * glutIconifyWindow() -- check the Win32 version
52 * glutReshapeWindow() -- check the Win32 version
53 * glutPositionWindow() -- check the Win32 version
54 * glutPushWindow() -- check the Win32 version
55 * glutPopWindow() -- check the Win32 version
58 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
61 * Chooses a visual basing on the current display mode settings
63 #if TARGET_HOST_UNIX_X11
65 XVisualInfo* fgChooseVisual( void )
67 #define BUFFER_SIZES 6
68 int bufferSize[BUFFER_SIZES] = { 16, 12, 8, 4, 2, 1 };
69 GLboolean wantIndexedMode = GL_FALSE;
74 * First we have to process the display mode settings...
77 * Why is there a semi-colon in this #define? The code
78 * that uses the macro seems to always add more semicolons...
80 #define ATTRIB(a) attributes[where++]=a;
81 #define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);}
83 if( fgState.DisplayMode & GLUT_INDEX )
85 ATTRIB_VAL( GLX_BUFFER_SIZE, 8 );
86 wantIndexedMode = GL_TRUE;
91 ATTRIB_VAL( GLX_RED_SIZE, 1 );
92 ATTRIB_VAL( GLX_GREEN_SIZE, 1 );
93 ATTRIB_VAL( GLX_BLUE_SIZE, 1 );
94 if( fgState.DisplayMode & GLUT_ALPHA )
95 ATTRIB_VAL( GLX_ALPHA_SIZE, 1 );
98 if( fgState.DisplayMode & GLUT_DOUBLE )
99 ATTRIB( GLX_DOUBLEBUFFER );
101 if( fgState.DisplayMode & GLUT_STEREO )
102 ATTRIB( GLX_STEREO );
104 if( fgState.DisplayMode & GLUT_DEPTH )
105 ATTRIB_VAL( GLX_DEPTH_SIZE, 1 );
107 if( fgState.DisplayMode & GLUT_STENCIL )
108 ATTRIB_VAL( GLX_STENCIL_SIZE, 1 );
110 if( fgState.DisplayMode & GLUT_ACCUM )
112 ATTRIB_VAL( GLX_ACCUM_RED_SIZE, 1 );
113 ATTRIB_VAL( GLX_ACCUM_GREEN_SIZE, 1 );
114 ATTRIB_VAL( GLX_ACCUM_BLUE_SIZE, 1 );
115 if( fgState.DisplayMode & GLUT_ALPHA )
116 ATTRIB_VAL( GLX_ACCUM_ALPHA_SIZE, 1 );
120 * Push a null at the end of the list
124 if( ! wantIndexedMode )
125 return glXChooseVisual( fgDisplay.Display, fgDisplay.Screen,
129 XVisualInfo* visualInfo;
133 * In indexed mode, we need to check how many bits of depth can we
134 * achieve. We do this by trying each possibility from the list
135 * given in the {bufferSize} array. If we match, we return to caller.
137 for( i=0; i<BUFFER_SIZES; i++ )
139 attributes[ 1 ] = bufferSize[ i ];
140 visualInfo = glXChooseVisual( fgDisplay.Display, fgDisplay.Screen,
142 if( visualInfo != NULL )
151 * Setup the pixel format for a Win32 window
153 #if TARGET_HOST_WIN32
154 GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
155 unsigned char layer_type )
157 PIXELFORMATDESCRIPTOR* ppfd, pfd;
158 int flags, pixelformat;
160 freeglut_return_val_if_fail( window != NULL, 0 );
161 flags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
162 if( fgState.DisplayMode & GLUT_DOUBLE )
163 flags |= PFD_DOUBLEBUFFER;
165 #if defined(_MSC_VER)
166 #pragma message( "fgSetupPixelFormat(): there is still some work to do here!" )
170 * Specify which pixel format do we opt for...
172 pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
175 pfd.iPixelType = PFD_TYPE_RGBA;
186 pfd.cAccumRedBits = 0;
187 pfd.cAccumGreenBits = 0;
188 pfd.cAccumBlueBits = 0;
189 pfd.cAccumAlphaBits = 0;
192 pfd.cStencilBits = 0;
195 pfd.cStencilBits = 8;
198 pfd.iLayerType = layer_type;
201 pfd.dwVisibleMask = 0;
202 pfd.dwDamageMask = 0;
204 pfd.cColorBits = (BYTE) GetDeviceCaps( window->Window.Device, BITSPIXEL );
207 pixelformat = ChoosePixelFormat( window->Window.Device, ppfd );
208 if( pixelformat == 0 )
213 return SetPixelFormat( window->Window.Device, pixelformat, ppfd );
218 * Sets the OpenGL context and the fgStructure "Current Window" pointer to
219 * the window structure passed in.
221 void fgSetWindow ( SFG_Window *window )
223 #if TARGET_HOST_UNIX_X11
227 window->Window.Handle,
228 window->Window.Context
230 #elif TARGET_HOST_WIN32
231 if( fgStructure.Window )
232 ReleaseDC( fgStructure.Window->Window.Handle,
233 fgStructure.Window->Window.Device );
237 window->Window.Device = GetDC( window->Window.Handle );
239 window->Window.Device,
240 window->Window.Context
244 fgStructure.Window = window;
249 * Opens a window. Requires a SFG_Window object created and attached
250 * to the freeglut structure. OpenGL context is created here.
252 void fgOpenWindow( SFG_Window* window, const char* title,
253 int x, int y, int w, int h,
254 GLboolean gameMode, GLboolean isSubWindow )
256 #if TARGET_HOST_UNIX_X11
257 XSetWindowAttributes winAttr;
258 XTextProperty textProperty;
259 XSizeHints sizeHints;
263 freeglut_assert_ready;
266 * XXX fgChooseVisual() is a common part of all three.
267 * XXX With a little thought, we should be able to greatly
270 if( !window->IsMenu )
271 window->Window.VisualInfo = fgChooseVisual( );
272 else if( fgStructure.MenuContext )
273 window->Window.VisualInfo = fgChooseVisual( );
276 unsigned int current_DisplayMode = fgState.DisplayMode ;
277 fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ;
278 window->Window.VisualInfo = fgChooseVisual( );
279 fgState.DisplayMode = current_DisplayMode ;
282 if( ! window->Window.VisualInfo )
285 * The "fgChooseVisual" returned a null meaning that the visual
286 * context is not available.
287 * Try a couple of variations to see if they will work.
289 if( !( fgState.DisplayMode & GLUT_DOUBLE ) )
291 fgState.DisplayMode |= GLUT_DOUBLE ;
292 window->Window.VisualInfo = fgChooseVisual( );
293 fgState.DisplayMode &= ~GLUT_DOUBLE;
297 * GLUT also checks for multi-sampling, but I don't see that
298 * anywhere else in FREEGLUT so I won't bother with it for the moment.
303 * XXX This seems to be abusing an assert() for error-checking.
304 * XXX It is possible that the visual simply can't be found,
305 * XXX in which case we should print an error and return a 0
306 * XXX for the window id, I think.
308 assert( window->Window.VisualInfo != NULL );
310 window->State.IsOffscreen = GL_FALSE;
311 if( fgState.DisplayMode & GLUT_OFFSCREEN )
313 window->State.IsOffscreen = GL_TRUE;
314 window->Window.Pixmap = XCreatePixmap(
315 fgDisplay.Display, fgDisplay.RootWindow,
317 window->Window.VisualInfo->depth
319 if( False != window->Window.Pixmap )
321 window->Window.Handle = glXCreateGLXPixmap(
323 window->Window.VisualInfo,
324 window->Window.Pixmap
326 if( False == window->Window.Handle )
327 XFreePixmap( fgDisplay.Display, window->Window.Pixmap );
333 * XXX HINT: the masks should be updated when adding/removing callbacks.
334 * XXX This might speed up message processing. Is that true?
336 * XXX A: Not appreciably, but it WILL make it easier to debug.
337 * XXX Try tracing old GLUT and try tracing freeglut. Old GLUT
338 * XXX turns off events that it doesn't need and is a whole lot
339 * XXX more pleasant to trace. (Hint: Think mouse-motion!)
341 * XXX It may make a difference in networked environments or on
342 * XXX some very slow systems, but I think that that is secondary
343 * XXX to making debugging easier.
346 StructureNotifyMask | SubstructureNotifyMask | ExposureMask |
347 ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyRelease |
348 VisibilityChangeMask | EnterWindowMask | LeaveWindowMask |
349 PointerMotionMask | ButtonMotionMask;
350 winAttr.background_pixmap = None;
351 winAttr.background_pixel = 0;
352 winAttr.border_pixel = 0;
354 winAttr.colormap = XCreateColormap(
355 fgDisplay.Display, fgDisplay.RootWindow,
356 window->Window.VisualInfo->visual, AllocNone
359 mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
361 if ( window->IsMenu )
363 winAttr.override_redirect = True;
364 mask |= CWOverrideRedirect;
367 window->Window.Handle = XCreateWindow(
369 window->Parent == NULL ? fgDisplay.RootWindow :
370 window->Parent->Window.Handle,
372 window->Window.VisualInfo->depth, InputOutput,
373 window->Window.VisualInfo->visual, mask,
378 * The GLX context creation, possibly trying the direct context rendering
379 * or else use the current context if the user has so specified
384 * If there isn't already an OpenGL rendering context for menu
387 if( !fgStructure.MenuContext )
389 fgStructure.MenuContext =
390 (SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );
391 fgStructure.MenuContext->VisualInfo = window->Window.VisualInfo;
392 fgStructure.MenuContext->Context = glXCreateContext(
393 fgDisplay.Display, fgStructure.MenuContext->VisualInfo,
394 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
398 /* window->Window.Context = fgStructure.MenuContext->Context ; */
399 window->Window.Context = glXCreateContext(
400 fgDisplay.Display, window->Window.VisualInfo,
401 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
404 else if( fgState.UseCurrentContext )
406 window->Window.Context = glXGetCurrentContext( );
408 if( ! window->Window.Context )
409 window->Window.Context = glXCreateContext(
410 fgDisplay.Display, window->Window.VisualInfo,
411 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
415 window->Window.Context = glXCreateContext(
416 fgDisplay.Display, window->Window.VisualInfo,
417 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
420 if( fgState.ForceDirectContext &&
421 !glXIsDirect( fgDisplay.Display, window->Window.Context ) )
422 fgError( "unable to force direct context rendering for window '%s'",
427 window->Window.Handle,
428 window->Window.Context
432 * XXX Assume the new window is visible by default
433 * XXX Is this a safe assumption?
435 window->State.Visible = GL_TRUE;
438 if ( fgState.Position.Use )
439 sizeHints.flags |= USPosition;
440 if ( fgState.Size.Use )
441 sizeHints.flags |= USSize;
444 * Fill in the size hints values now (the x, y, width and height
445 * settings are obsolote, are there any more WMs that support them?)
446 * Unless the X servers actually stop supporting these, we should
447 * continue to fill them in. It is *not* our place to tell the user
448 * that they should replace a window manager that they like, and which
449 * works, just because *we* think that it's not "modern" enough.
454 sizeHints.height = h;
456 wmHints.flags = StateHint;
457 wmHints.initial_state = fgState.ForceIconic ? IconicState : NormalState;
458 if( GL_FALSE == window->State.IsOffscreen )
461 * Prepare the window and iconified window names...
463 XStringListToTextProperty( (char **) &title, 1, &textProperty );
467 window->Window.Handle,
477 XSetWMProtocols( fgDisplay.Display, window->Window.Handle,
478 &fgDisplay.DeleteWindow, 1 );
480 XMapWindow( fgDisplay.Display, window->Window.Handle );
483 #elif TARGET_HOST_WIN32
489 freeglut_assert_ready;
492 * Grab the window class we have registered on glutInit():
494 atom = GetClassInfo( fgDisplay.Instance, "FREEGLUT", &wc );
499 assert( window->Parent == NULL );
502 * Set the window creation flags appropriately to make the window
505 flags = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
509 if ( ( ! isSubWindow ) && ( ! window->IsMenu ) )
512 * Update the window dimensions, taking account of window
513 * decorations. "freeglut" is to create the window with the
514 * outside of its border at (x,y) and with dimensions (w,h).
516 w += (GetSystemMetrics( SM_CXSIZEFRAME ) )*2;
517 h += (GetSystemMetrics( SM_CYSIZEFRAME ) )*2 +
518 GetSystemMetrics( SM_CYCAPTION );
521 if( ! fgState.Position.Use )
526 if( ! fgState.Size.Use )
533 * There's a small difference between creating the top, child and
536 flags = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
538 if ( window->IsMenu )
540 else if( window->Parent == NULL )
541 flags |= WS_OVERLAPPEDWINDOW;
546 window->Window.Handle = CreateWindow(
551 (HWND) window->Parent == NULL ? NULL : window->Parent->Window.Handle,
556 if( !( window->Window.Handle ) )
557 fgError( "Failed to create a window (%s)!", title );
559 ShowWindow( window->Window.Handle,
560 fgState.ForceIconic ? SW_SHOWMINIMIZED : SW_SHOW );
561 UpdateWindow( window->Window.Handle );
562 ShowCursor( TRUE ); /* XXX Old comments say "hide cusror"! */
566 fgSetWindow( window );
568 window->Window.DoubleBuffered =
569 ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0;
571 if ( ! window->Window.DoubleBuffered )
573 glDrawBuffer ( GL_FRONT );
574 glReadBuffer ( GL_FRONT );
579 * Closes a window, destroying the frame and OpenGL context
581 void fgCloseWindow( SFG_Window* window )
583 freeglut_assert_ready;
585 #if TARGET_HOST_UNIX_X11
587 glXDestroyContext( fgDisplay.Display, window->Window.Context );
588 if( GL_FALSE == window->State.IsOffscreen )
589 XDestroyWindow( fgDisplay.Display, window->Window.Handle );
592 glXDestroyGLXPixmap( fgDisplay.Display, window->Window.Handle );
593 XFreePixmap( fgDisplay.Display, window->Window.Pixmap );
595 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
597 #elif TARGET_HOST_WIN32
600 * Make sure we don't close a window with current context active
602 if( fgStructure.Window == window )
603 wglMakeCurrent( NULL, NULL );
606 * Step through the list of windows. If the rendering context
607 * is not being used by another window, then we delete it.
613 for( iter = (SFG_Window *)fgStructure.Windows.First;
615 iter = (SFG_Window *)iter->Node.Next )
617 if( ( iter->Window.Context == window->Window.Context ) &&
623 wglDeleteContext( window->Window.Context );
626 DestroyWindow( window->Window.Handle );
631 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
634 * Creates a new top-level freeglut window
636 int FGAPIENTRY glutCreateWindow( const char* title )
638 return fgCreateWindow( NULL, title, fgState.Position.X, fgState.Position.Y,
639 fgState.Size.X, fgState.Size.Y, GL_FALSE,
644 * This function creates a sub window.
646 int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
650 if( GL_FALSE == fgStructure.Window->State.IsOffscreen )
652 SFG_Window* window = NULL;
653 SFG_Window* parent = NULL;
655 freeglut_assert_ready;
656 parent = fgWindowByID( parentID );
657 freeglut_return_val_if_fail( parent != NULL, 0 );
658 window = fgCreateWindow( parent, "", x, y, w, h, GL_FALSE, GL_FALSE );
665 * Destroys a window and all of its subwindows
667 void FGAPIENTRY glutDestroyWindow( int windowID )
669 SFG_Window* window = fgWindowByID( windowID );
670 freeglut_return_if_fail( window != NULL );
672 fgExecutionState ExecState = fgState.ExecState;
673 fgAddToWindowDestroyList( window );
674 fgState.ExecState = ExecState;
679 * This function selects the current window
681 void FGAPIENTRY glutSetWindow( int ID )
683 SFG_Window* window = NULL;
685 freeglut_assert_ready;
686 if( fgStructure.Window != NULL )
687 if( fgStructure.Window->ID == ID )
690 window = fgWindowByID( ID );
693 fgWarning( "glutSetWindow(): window ID %i not found!", ID );
697 fgSetWindow( window );
701 * This function returns the ID number of the current window, 0 if none exists
703 int FGAPIENTRY glutGetWindow( void )
705 freeglut_assert_ready;
706 if( fgStructure.Window == NULL )
708 return fgStructure.Window->ID;
712 * This function makes the current window visible
714 void FGAPIENTRY glutShowWindow( void )
716 freeglut_assert_ready;
717 freeglut_assert_window;
719 if( GL_FALSE == fgStructure.Window->State.IsOffscreen )
721 #if TARGET_HOST_UNIX_X11
723 XMapWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
724 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
726 #elif TARGET_HOST_WIN32
728 ShowWindow( fgStructure.Window->Window.Handle, SW_SHOW );
732 fgStructure.Window->State.Redisplay = GL_TRUE;
736 * This function hides the current window
738 void FGAPIENTRY glutHideWindow( void )
740 freeglut_assert_ready;
741 freeglut_assert_window;
743 if( GL_FALSE == fgStructure.Window->State.IsOffscreen )
745 #if TARGET_HOST_UNIX_X11
747 if( fgStructure.Window->Parent == NULL )
748 XWithdrawWindow( fgDisplay.Display,
749 fgStructure.Window->Window.Handle,
752 XUnmapWindow( fgDisplay.Display,
753 fgStructure.Window->Window.Handle );
754 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
756 #elif TARGET_HOST_WIN32
758 ShowWindow( fgStructure.Window->Window.Handle, SW_HIDE );
762 fgStructure.Window->State.Redisplay = GL_FALSE;
766 * Iconify the current window (top-level windows only)
768 void FGAPIENTRY glutIconifyWindow( void )
770 freeglut_assert_ready;
771 freeglut_assert_window;
773 fgStructure.Window->State.Visible = GL_FALSE;
774 if( GL_FALSE == fgStructure.Window->State.IsOffscreen )
776 #if TARGET_HOST_UNIX_X11
778 XIconifyWindow( fgDisplay.Display, fgStructure.Window->Window.Handle,
780 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
782 #elif TARGET_HOST_WIN32
784 ShowWindow( fgStructure.Window->Window.Handle, SW_MINIMIZE );
788 fgStructure.Window->State.Redisplay = GL_FALSE;
792 * Set the current window's title
794 void FGAPIENTRY glutSetWindowTitle( const char* title )
796 freeglut_assert_ready;
797 freeglut_assert_window;
798 if( ! fgStructure.Window->Parent &&
799 ( GL_FALSE == fgStructure.Window->State.IsOffscreen ) )
801 #if TARGET_HOST_UNIX_X11
805 text.value = (unsigned char *) title;
806 text.encoding = XA_STRING;
808 text.nitems = strlen( title );
812 fgStructure.Window->Window.Handle,
816 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
818 #elif TARGET_HOST_WIN32
820 SetWindowText( fgStructure.Window->Window.Handle, title );
827 * Set the current window's iconified title
829 void FGAPIENTRY glutSetIconTitle( const char* title )
831 freeglut_assert_ready;
832 freeglut_assert_window;
834 if( ! fgStructure.Window->Parent &&
835 GL_FALSE == fgStructure.Window->State.IsOffscreen )
837 #if TARGET_HOST_UNIX_X11
841 text.value = (unsigned char *) title;
842 text.encoding = XA_STRING;
844 text.nitems = strlen( title );
848 fgStructure.Window->Window.Handle,
852 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
854 #elif TARGET_HOST_WIN32
856 SetWindowText( fgStructure.Window->Window.Handle, title );
863 * Change the current window's size
865 void FGAPIENTRY glutReshapeWindow( int width, int height )
867 freeglut_assert_ready;
868 freeglut_assert_window;
870 /* XXX Could delete/create/set-window-id for offscreen. */
871 if( GL_FALSE == fgStructure.Window->State.IsOffscreen )
873 fgStructure.Window->State.NeedToResize = GL_TRUE;
874 fgStructure.Window->State.Width = width ;
875 fgStructure.Window->State.Height = height;
880 * Change the current window's position
882 void FGAPIENTRY glutPositionWindow( int x, int y )
884 freeglut_assert_ready;
885 freeglut_assert_window;
887 if( GL_FALSE == fgStructure.Window->State.IsOffscreen )
889 #if TARGET_HOST_UNIX_X11
891 XMoveWindow( fgDisplay.Display, fgStructure.Window->Window.Handle,
893 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
895 #elif TARGET_HOST_WIN32
899 GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
901 fgStructure.Window->Window.Handle,
904 winRect.right - winRect.left,
905 winRect.bottom - winRect.top,
914 * Lowers the current window (by Z order change)
916 void FGAPIENTRY glutPushWindow( void )
918 freeglut_assert_ready;
919 freeglut_assert_window;
921 if( GL_FALSE == fgStructure.Window->State.IsOffscreen )
923 #if TARGET_HOST_UNIX_X11
925 XLowerWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
927 #elif TARGET_HOST_WIN32
930 fgStructure.Window->Window.Handle,
933 SWP_NOSIZE | SWP_NOMOVE
941 * Raises the current window (by Z order change)
943 void FGAPIENTRY glutPopWindow( void )
945 freeglut_assert_ready;
946 freeglut_assert_window;
948 if( GL_FALSE == fgStructure.Window->State.IsOffscreen )
950 #if TARGET_HOST_UNIX_X11
952 XRaiseWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
954 #elif TARGET_HOST_WIN32
957 fgStructure.Window->Window.Handle,
960 SWP_NOSIZE | SWP_NOMOVE
968 * Resize the current window so that it fits the whole screen
970 void FGAPIENTRY glutFullScreen( void )
972 freeglut_assert_ready;
973 freeglut_assert_window;
975 if( GL_FALSE == fgStructure.Window->State.IsOffscreen )
977 #if TARGET_HOST_UNIX_X11
983 fgStructure.Window->Window.Handle,
985 fgDisplay.ScreenWidth,
986 fgDisplay.ScreenHeight
989 XFlush( fgDisplay.Display ); /* This is needed */
991 XTranslateCoordinates(
993 fgStructure.Window->Window.Handle,
994 fgDisplay.RootWindow,
1002 fgStructure.Window->Window.Handle,
1005 XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
1007 #elif TARGET_HOST_WIN32
1010 /* For fullscreen mode, force the top-left corner to 0,0
1011 * and adjust the window rectangle so that the client area
1012 * covers the whole screen.
1017 rect.right = fgDisplay.ScreenWidth;
1018 rect.bottom = fgDisplay.ScreenHeight;
1020 AdjustWindowRect ( &rect, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS |
1021 WS_CLIPCHILDREN, FALSE );
1024 * SWP_NOACTIVATE Do not activate the window
1025 * SWP_NOOWNERZORDER Do not change position in z-order
1026 * SWP_NOSENDCHANGING Supress WM_WINDOWPOSCHANGING message
1027 * SWP_NOZORDER Retains the current Z order (ignore 2nd param)
1030 SetWindowPos( fgStructure.Window->Window.Handle,
1034 rect.right - rect.left,
1035 rect.bottom - rect.top,
1036 SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
1044 * A.Donev: Set and retrieve the window's user data
1046 void* FGAPIENTRY glutGetWindowData( void )
1048 return fgStructure.Window->UserData;
1051 void FGAPIENTRY glutSetWindowData(void* data)
1053 fgStructure.Window->UserData = data;
1056 /*** END OF FILE ***/