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 #define G_LOG_DOMAIN "freeglut-window"
34 #include "../include/GL/freeglut.h"
35 #include "freeglut_internal.h"
38 * TODO BEFORE THE STABLE RELEASE:
40 * fgChooseVisual() -- OK, but what about glutInitDisplayString()?
41 * fgSetupPixelFormat -- ignores the display mode settings
42 * fgOpenWindow() -- check the Win32 version, -iconic handling!
43 * fgCloseWindow() -- check the Win32 version
44 * glutCreateWindow() -- Check when default position and size is {-1,-1}
45 * glutCreateSubWindow() -- Check when default position and size is {-1,-1}
46 * glutDestroyWindow() -- check the Win32 version
47 * glutSetWindow() -- check the Win32 version
48 * glutGetWindow() -- OK
49 * glutSetWindowTitle() -- check the Win32 version
50 * glutSetIconTitle() -- check the Win32 version
51 * glutShowWindow() -- check the Win32 version
52 * glutHideWindow() -- check the Win32 version
53 * glutIconifyWindow() -- check the Win32 version
54 * glutReshapeWindow() -- check the Win32 version
55 * glutPositionWindow() -- check the Win32 version
56 * glutPushWindow() -- check the Win32 version
57 * glutPopWindow() -- check the Win32 version
60 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
63 * Chooses a visual basing on the current display mode settings
65 #if TARGET_HOST_UNIX_X11
67 XVisualInfo* fgChooseVisual( void )
69 #define BUFFER_SIZES 6
70 int bufferSize[BUFFER_SIZES] = { 16, 12, 8, 4, 2, 1 };
71 GLboolean wantIndexedMode = FALSE;
76 * First we have to process the display mode settings...
79 * Why is there a semi-colon in this #define? The code
80 * that uses the macro seems to always add more semicolons...
82 #define ATTRIB(a) attributes[where++]=a;
83 #define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);}
85 if( fgState.DisplayMode & GLUT_INDEX )
87 ATTRIB_VAL( GLX_BUFFER_SIZE, 8 );
88 wantIndexedMode = TRUE;
93 ATTRIB_VAL( GLX_RED_SIZE, 1 );
94 ATTRIB_VAL( GLX_GREEN_SIZE, 1 );
95 ATTRIB_VAL( GLX_BLUE_SIZE, 1 );
96 if( fgState.DisplayMode & GLUT_ALPHA )
97 ATTRIB_VAL( GLX_ALPHA_SIZE, 1 );
100 if( fgState.DisplayMode & GLUT_DOUBLE )
101 ATTRIB( GLX_DOUBLEBUFFER );
103 if( fgState.DisplayMode & GLUT_STEREO )
104 ATTRIB( GLX_STEREO );
106 if( fgState.DisplayMode & GLUT_DEPTH )
107 ATTRIB_VAL( GLX_DEPTH_SIZE, 1 );
109 if( fgState.DisplayMode & GLUT_STENCIL )
110 ATTRIB_VAL( GLX_STENCIL_SIZE, 1 );
112 if( fgState.DisplayMode & GLUT_ACCUM )
114 ATTRIB_VAL( GLX_ACCUM_RED_SIZE, 1 );
115 ATTRIB_VAL( GLX_ACCUM_GREEN_SIZE, 1 );
116 ATTRIB_VAL( GLX_ACCUM_BLUE_SIZE, 1 );
117 if( fgState.DisplayMode & GLUT_ALPHA )
118 ATTRIB_VAL( GLX_ACCUM_ALPHA_SIZE, 1 );
122 * Push a null at the end of the list
126 if( wantIndexedMode == FALSE )
127 return glXChooseVisual( fgDisplay.Display, fgDisplay.Screen,
131 XVisualInfo* visualInfo;
135 * In indexed mode, we need to check how many bits of depth can we
136 * achieve. We do this by trying each possibility from the list
137 * given in the {bufferSize} array. If we match, we return to caller.
139 for( i=0; i<BUFFER_SIZES; i++ )
141 attributes[ 1 ] = bufferSize[ i ];
142 visualInfo = glXChooseVisual( fgDisplay.Display, fgDisplay.Screen,
144 if( visualInfo != NULL )
153 * Setup the pixel format for a Win32 window
155 #if TARGET_HOST_WIN32
156 GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
157 unsigned char layer_type )
159 PIXELFORMATDESCRIPTOR* ppfd, pfd;
160 int flags, pixelformat;
162 freeglut_return_val_if_fail( window != NULL, 0 );
163 flags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
164 if( fgState.DisplayMode & GLUT_DOUBLE )
165 flags |= PFD_DOUBLEBUFFER;
167 #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, int x, int y, int w, int h, GLboolean gameMode, int isSubWindow )
254 #if TARGET_HOST_UNIX_X11
255 XSetWindowAttributes winAttr;
256 XTextProperty textProperty;
257 XSizeHints sizeHints;
261 freeglut_assert_ready;
264 * Here we are upon the stage. Have the visual selected.
266 if ( fgState.BuildingAMenu )
269 * If there isn't already an OpenGL rendering context for menu windows, make one
271 if ( !fgStructure.MenuContext )
273 unsigned int current_DisplayMode = fgState.DisplayMode ;
274 fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ;
275 window->Window.VisualInfo = fgChooseVisual();
276 fgState.DisplayMode = current_DisplayMode ;
279 window->Window.VisualInfo = fgChooseVisual();
282 window->Window.VisualInfo = fgChooseVisual();
284 if ( ! window->Window.VisualInfo )
287 * The "fgChooseVisual" returned a null meaning that the visual context is not available.
288 * Try a couple of variations to see if they will work.
290 if ( ! ( fgState.DisplayMode & GLUT_DOUBLE ) )
293 * Single buffering--try it doubled
295 fgState.DisplayMode |= GLUT_DOUBLE ;
296 window->Window.VisualInfo = fgChooseVisual();
297 /* OK, we got a double-buffered window, but we only wanted
298 * single-buffered. Clear the double-buffer flag now.
300 fgState.DisplayMode &= ~GLUT_DOUBLE ;
304 * GLUT also checks for multi-sampling, but I don't see that anywhere else in FREEGLUT
305 * so I won't bother with it for the moment.
309 assert( window->Window.VisualInfo != NULL );
312 * Have the windows attributes set
314 * HINT: the masks should be updated when adding/removing callbacks.
315 * This might speed up message processing. Is that true?
317 winAttr.event_mask = StructureNotifyMask | SubstructureNotifyMask | ExposureMask |
318 ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyRelease |
319 VisibilityChangeMask | EnterWindowMask | LeaveWindowMask |
320 PointerMotionMask | ButtonMotionMask;
321 winAttr.background_pixmap = None;
322 winAttr.background_pixel = 0;
323 winAttr.border_pixel = 0;
326 * The color map is required, too
328 winAttr.colormap = XCreateColormap(
329 fgDisplay.Display, fgDisplay.RootWindow,
330 window->Window.VisualInfo->visual, AllocNone
334 * This tells the XCreateWindow() what attributes are we supplying it with
336 mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
339 * If this is a menu window we want the window manager to ignore it.
341 if ( fgState.BuildingAMenu )
343 winAttr.override_redirect = True;
344 mask |= CWOverrideRedirect;
348 * Have the window created now
350 window->Window.Handle = XCreateWindow(
352 window->Parent == NULL ? fgDisplay.RootWindow : window->Parent->Window.Handle,
354 window->Window.VisualInfo->depth, InputOutput,
355 window->Window.VisualInfo->visual, mask,
360 * The GLX context creation, possibly trying the direct context rendering
361 * or else use the current context if the user has so specified
363 if ( fgState.BuildingAMenu )
366 * If there isn't already an OpenGL rendering context for menu windows, make one
368 if ( !fgStructure.MenuContext )
370 fgStructure.MenuContext = (SFG_MenuContext *)malloc ( sizeof(SFG_MenuContext) ) ;
371 fgStructure.MenuContext->VisualInfo = window->Window.VisualInfo ;
372 fgStructure.MenuContext->Context = glXCreateContext(
373 fgDisplay.Display, fgStructure.MenuContext->VisualInfo,
374 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
378 /* window->Window.Context = fgStructure.MenuContext->Context ; */
379 window->Window.Context = glXCreateContext(
380 fgDisplay.Display, window->Window.VisualInfo,
381 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
384 else if ( fgState.UseCurrentContext == TRUE )
386 window->Window.Context = glXGetCurrentContext();
388 if ( ! window->Window.Context )
389 window->Window.Context = glXCreateContext(
390 fgDisplay.Display, window->Window.VisualInfo,
391 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
395 window->Window.Context = glXCreateContext(
396 fgDisplay.Display, window->Window.VisualInfo,
397 NULL, fgState.ForceDirectContext | fgState.TryDirectContext
401 * Make sure the context is direct when the user wants it forced
403 if( fgState.ForceDirectContext && !glXIsDirect( fgDisplay.Display, window->Window.Context ) )
404 fgError( "unable to force direct context rendering for window '%s'", title );
407 * Set the new context as the current one. That's all about the window creation.
411 window->Window.Handle,
412 window->Window.Context
416 * Assume the new window is visible by default
418 window->State.Visible = TRUE;
421 * For the position and size hints -- make sure we are passing valid values
425 if (fgState.Position.Use == TRUE) sizeHints.flags |= USPosition;
426 if (fgState.Size.Use == TRUE) sizeHints.flags |= USSize;
429 * Fill in the size hints values now (the x, y, width and height
430 * settings are obsolote, are there any more WMs that support them?)
432 sizeHints.x = x; sizeHints.y = y;
433 sizeHints.width = w; sizeHints.height = h;
436 * We can have forced all new windows start in iconified state:
438 wmHints.flags = StateHint;
439 wmHints.initial_state = (fgState.ForceIconic == FALSE) ? NormalState : IconicState;
442 * Prepare the window and iconified window names...
444 XStringListToTextProperty( (char **) &title, 1, &textProperty );
447 * Set the window's properties now
451 window->Window.Handle,
462 * Make sure we are informed about the window deletion commands
464 XSetWMProtocols( fgDisplay.Display, window->Window.Handle, &fgDisplay.DeleteWindow, 1 );
467 * Finally, have the window mapped to our display
469 XMapWindow( fgDisplay.Display, window->Window.Handle );
471 #elif TARGET_HOST_WIN32
477 freeglut_assert_ready;
480 * Grab the window class we have registered on glutInit():
482 atom = GetClassInfo( fgDisplay.Instance, "FREEGLUT", &wc );
485 if( gameMode == FALSE )
487 if ( ( !isSubWindow ) && ( ! window->IsMenu ) )
490 * Update the window dimensions, taking account of window decorations.
491 * "freeglut" is to create the window with the outside of its border at (x,y)
492 * and with dimensions (w,h).
494 w += (GetSystemMetrics( SM_CXSIZEFRAME ) )*2;
495 h += (GetSystemMetrics( SM_CYSIZEFRAME ) )*2 + GetSystemMetrics( SM_CYCAPTION );
499 * Check if the user wants us to use the default position/size
501 if( fgState.Position.Use == FALSE ) { x = CW_USEDEFAULT; y = CW_USEDEFAULT; }
502 if( fgState.Size .Use == FALSE ) { w = CW_USEDEFAULT; h = CW_USEDEFAULT; }
505 * There's a small difference between creating the top, child and game mode windows
507 flags = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
510 * If we're a menu, set our flags to include WS_POPUP to remove decorations
512 if ( window->IsMenu )
514 else if( window->Parent == NULL )
515 flags |= WS_OVERLAPPEDWINDOW;
522 * In game mode, the story is a little bit different...
524 assert( window->Parent == NULL );
527 * Set the window creation flags appropriately to make the window entirely visible:
529 flags = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
533 * Create the window now, passing the freeglut window structure as the parameter
535 window->Window.Handle = CreateWindow(
540 (HWND) window->Parent == NULL ? NULL : window->Parent->Window.Handle,
547 * Make sure window was created
549 assert( window->Window.Handle != NULL );
552 * Show and update the main window. Hide the mouse cursor.
554 ShowWindow( window->Window.Handle, fgState.ForceIconic ? SW_SHOWMINIMIZED : SW_SHOW );
555 UpdateWindow( window->Window.Handle );
561 * Save the window's single- or double-buffering state
563 window->Window.DoubleBuffered = ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0 ;
566 * If it's not double-buffered, make sure the rendering is done to the front buffer.
568 if ( ! window->Window.DoubleBuffered )
570 glDrawBuffer ( GL_FRONT ) ;
571 glReadBuffer ( GL_FRONT ) ;
575 * Set the newly created window as the current one
577 fgSetWindow( window );
581 * Closes a window, destroying the frame and OpenGL context
583 void fgCloseWindow( SFG_Window* window )
585 freeglut_assert_ready;
587 #if TARGET_HOST_UNIX_X11
589 * As easy as kill bunnies with axes. Destroy the context first:
591 glXDestroyContext( fgDisplay.Display, window->Window.Context );
594 * Then have the window killed:
596 XDestroyWindow( fgDisplay.Display, window->Window.Handle );
599 * Finally, flush the rests down the stream
601 XFlush( fgDisplay.Display );
603 #elif TARGET_HOST_WIN32
605 * Send the WM_CLOSE message to the window now
608 window->Window.Handle,
618 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
621 * Creates a new top-level freeglut window
623 int FGAPIENTRY glutCreateWindow( const char* title )
626 * Create a new window and return its unique ID number
628 return( fgCreateWindow( NULL, title, fgState.Position.X, fgState.Position.Y,
629 fgState.Size.X, fgState.Size.Y, FALSE )->ID );
633 * This function creates a sub window.
635 int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
637 SFG_Window* window = NULL;
638 SFG_Window* parent = NULL;
640 freeglut_assert_ready;
643 * Find a parent to the newly created window...
645 parent = fgWindowByID( parentID );
648 * Fail if the parent has not been found
650 freeglut_return_val_if_fail( parent != NULL, 0 );
653 * Create the new window
655 window = fgCreateWindow( parent, "", x, y, w, h, FALSE );
658 * Return the new window's ID
660 return( window->ID );
664 * Destroys a window and all of its subwindows
666 void FGAPIENTRY glutDestroyWindow( int windowID )
668 fgExecutionState ExecState = fgState.ExecState ;
671 * Grab the freeglut window pointer from the structure
673 SFG_Window* window = fgWindowByID( windowID );
674 freeglut_return_if_fail( window != NULL );
677 * There is a function that performs all needed steps
678 * defined in freeglut_structure.c. Let's use it:
680 fgAddToWindowDestroyList( window, TRUE );
683 * Since the "fgAddToWindowDestroyList" function could easily have set the "ExecState"
684 * to stop, let's set it back to what it was.
686 fgState.ExecState = ExecState ;
690 * This function selects the current window
692 void FGAPIENTRY glutSetWindow( int ID )
694 SFG_Window* window = NULL;
697 * Make sure we don't get called too early
699 freeglut_assert_ready;
702 * Be wise. Be wise. Be wise. Be quick.
704 if( fgStructure.Window != NULL )
705 if( fgStructure.Window->ID == ID )
709 * Now we are sure there is sense in looking for the window
711 window = fgWindowByID( ID );
714 * In the case of an utter failure...
719 * ...issue a warning message and keep rolling on
721 fgWarning( "glutSetWindow(): window ID %i not found!", ID );
725 fgSetWindow ( window ) ;
729 * This function returns the ID number of the current window, 0 if none exists
731 int FGAPIENTRY glutGetWindow( void )
733 freeglut_assert_ready;
736 * Do we have a current window selected?
738 if( fgStructure.Window == NULL )
741 * Nope. Return zero to mark the state.
747 * Otherwise, return the ID of the current window
749 return( fgStructure.Window->ID );
753 * This function makes the current window visible
755 void FGAPIENTRY glutShowWindow( void )
757 freeglut_assert_ready; freeglut_assert_window;
759 #if TARGET_HOST_UNIX_X11
761 * Showing the window is done via mapping under X
763 XMapWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
764 XFlush( fgDisplay.Display );
766 #elif TARGET_HOST_WIN32
768 * Restore the window's originial position and size
770 ShowWindow( fgStructure.Window->Window.Handle, SW_SHOW );
775 * Since the window is visible, we need to redisplay it ...
777 fgStructure.Window->State.Redisplay = TRUE;
782 * This function hides the current window
784 void FGAPIENTRY glutHideWindow( void )
786 freeglut_assert_ready; freeglut_assert_window;
788 #if TARGET_HOST_UNIX_X11
790 * The way we hide a window depends on if we're dealing
791 * with a top-level or children one...
793 if( fgStructure.Window->Parent == NULL )
796 * This is a top-level window
798 XWithdrawWindow( fgDisplay.Display, fgStructure.Window->Window.Handle, fgDisplay.Screen );
803 * Nope, it's a child window
805 XUnmapWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
809 * Flush the X state now
811 XFlush( fgDisplay.Display );
813 #elif TARGET_HOST_WIN32
817 ShowWindow( fgStructure.Window->Window.Handle, SW_HIDE );
822 * Since the window is hidden, we don't need to redisplay it ...
824 fgStructure.Window->State.Redisplay = FALSE;
828 * Iconify the current window (top-level windows only)
830 void FGAPIENTRY glutIconifyWindow( void )
832 freeglut_assert_ready; freeglut_assert_window;
834 #if TARGET_HOST_UNIX_X11
836 * Iconify the window and flush the X state
838 XIconifyWindow( fgDisplay.Display, fgStructure.Window->Window.Handle, fgDisplay.Screen );
839 XFlush( fgDisplay.Display );
841 #elif TARGET_HOST_WIN32
843 * Minimize the current window (this should be the same as X window iconifying)
845 ShowWindow( fgStructure.Window->Window.Handle, SW_MINIMIZE );
850 * Since the window is just an icon, we don't need to redisplay it ...
852 fgStructure.Window->State.Redisplay = FALSE;
857 * Set the current window's title
859 void FGAPIENTRY glutSetWindowTitle( const char* title )
861 freeglut_assert_ready; freeglut_assert_window;
864 * Works only for top-level windows
866 if( fgStructure.Window->Parent != NULL )
869 #if TARGET_HOST_UNIX_X11
874 * Prepare the text properties
876 text.value = (unsigned char *) title;
877 text.encoding = XA_STRING;
879 text.nitems = strlen( title );
886 fgStructure.Window->Window.Handle,
891 * Have the X display state flushed
893 XFlush( fgDisplay.Display );
896 #elif TARGET_HOST_WIN32
898 * This seems to be a bit easier under Win32
900 SetWindowText( fgStructure.Window->Window.Handle, title );
906 * Set the current window's iconified title
908 void FGAPIENTRY glutSetIconTitle( const char* title )
910 freeglut_assert_ready; freeglut_assert_window;
913 * Works only for top-level windows
915 if( fgStructure.Window->Parent != NULL )
918 #if TARGET_HOST_UNIX_X11
923 * Prepare the text properties
925 text.value = (unsigned char *) title;
926 text.encoding = XA_STRING;
928 text.nitems = strlen( title );
935 fgStructure.Window->Window.Handle,
940 * Have the X display state flushed
942 XFlush( fgDisplay.Display );
945 #elif TARGET_HOST_WIN32
947 * This seems to be a bit easier under Win32
949 SetWindowText( fgStructure.Window->Window.Handle, title );
955 * Change the current window's size
957 void FGAPIENTRY glutReshapeWindow( int width, int height )
959 freeglut_assert_ready; freeglut_assert_window;
961 #if TARGET_HOST_UNIX_X11
963 * Resize the window and flush the X state
965 XResizeWindow( fgDisplay.Display, fgStructure.Window->Window.Handle, width, height );
966 XFlush( fgDisplay.Display );
968 #elif TARGET_HOST_WIN32
974 * First off, grab the current window's position
976 GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
980 if ( fgStructure.Window->Parent == NULL ) /* If this is not a subwindow ... */
983 * Adjust the size of the window to allow for the size of the frame, if we are not a menu
985 if ( ! fgStructure.Window->IsMenu )
987 width += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
988 height += GetSystemMetrics( SM_CYSIZEFRAME ) * 2 + GetSystemMetrics( SM_CYCAPTION );
991 else /* This is a subwindow, get the parent window's position and subtract it off */
993 GetWindowRect ( fgStructure.Window->Parent->Window.Handle, &winRect ) ;
994 x -= winRect.left + GetSystemMetrics( SM_CXSIZEFRAME ) ;
995 y -= winRect.top + GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION ) ;
999 * Resize the window, forcing a redraw to happen
1002 fgStructure.Window->Window.Handle,
1014 * Change the current window's position
1016 void FGAPIENTRY glutPositionWindow( int x, int y )
1018 freeglut_assert_ready; freeglut_assert_window;
1020 #if TARGET_HOST_UNIX_X11
1022 * Reposition the window and flush the X state
1024 XMoveWindow( fgDisplay.Display, fgStructure.Window->Window.Handle, x, y );
1025 XFlush( fgDisplay.Display );
1027 #elif TARGET_HOST_WIN32
1032 * First off, grab the current window's position
1034 GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
1037 * Reposition the window, forcing a redraw to happen
1040 fgStructure.Window->Window.Handle,
1043 winRect.right - winRect.left,
1044 winRect.bottom - winRect.top,
1053 * Lowers the current window (by Z order change)
1055 void FGAPIENTRY glutPushWindow( void )
1057 freeglut_assert_ready; freeglut_assert_window;
1059 #if TARGET_HOST_UNIX_X11
1061 * Lower the current window
1063 XLowerWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
1065 #elif TARGET_HOST_WIN32
1067 * Set the new window's Z position, not affecting the rest of the settings:
1070 fgStructure.Window->Window.Handle,
1073 SWP_NOSIZE | SWP_NOMOVE
1080 * Raises the current window (by Z order change)
1082 void FGAPIENTRY glutPopWindow( void )
1084 freeglut_assert_ready; freeglut_assert_window;
1086 #if TARGET_HOST_UNIX_X11
1088 * Raise the current window
1090 XRaiseWindow( fgDisplay.Display, fgStructure.Window->Window.Handle );
1092 #elif TARGET_HOST_WIN32
1094 * Set the new window's Z position, not affecting the rest of the settings:
1097 fgStructure.Window->Window.Handle,
1100 SWP_NOSIZE | SWP_NOMOVE
1107 * Resize the current window so that it fits the whole screen
1109 void FGAPIENTRY glutFullScreen( void )
1111 freeglut_assert_ready; freeglut_assert_window;
1113 #if TARGET_HOST_UNIX_X11
1120 fgStructure.Window->Window.Handle,
1122 fgDisplay.ScreenWidth,
1123 fgDisplay.ScreenHeight
1125 XFlush( fgDisplay.Display );
1127 XTranslateCoordinates(
1129 fgStructure.Window->Window.Handle,
1130 fgDisplay.RootWindow,
1138 fgStructure.Window->Window.Handle,
1141 XFlush( fgDisplay.Display );
1144 #elif TARGET_HOST_WIN32
1146 fgStructure.Window->Window.Handle,
1148 fgDisplay.ScreenWidth,
1149 fgDisplay.ScreenHeight,
1156 * A.Donev: Set and retrieve the window's user data
1158 void* FGAPIENTRY glutGetWindowData( void )
1160 return(fgStructure.Window->UserData);
1163 void FGAPIENTRY glutSetWindowData(void* data)
1165 fgStructure.Window->UserData=data;
1168 /*** END OF FILE ***/