glutGet window position should be relative to parent

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1701 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2014-08-27 11:45:58 +00:00
parent b0811138cc
commit 9141845a49

View File

@ -88,15 +88,23 @@ int fgPlatformGlutGet ( GLenum eWhat )
case GLUT_WINDOW_HEADER_HEIGHT: case GLUT_WINDOW_HEADER_HEIGHT:
{ {
int x, y; int x, y;
Window w; Window p,w;
if( fgStructure.CurrentWindow == NULL ) if( fgStructure.CurrentWindow == NULL )
return 0; return 0;
if (fgStructure.CurrentWindow->Parent)
/* For child window, we should return relative to upper-left
* of parent's client area.
*/
p = fgStructure.CurrentWindow->Parent->Window.Handle;
else
p = fgDisplay.pDisplay.RootWindow;
XTranslateCoordinates( XTranslateCoordinates(
fgDisplay.pDisplay.Display, fgDisplay.pDisplay.Display,
fgStructure.CurrentWindow->Window.Handle, fgStructure.CurrentWindow->Window.Handle,
fgDisplay.pDisplay.RootWindow, p,
0, 0, &x, &y, &w); 0, 0, &x, &y, &w);
switch ( eWhat ) switch ( eWhat )
@ -105,7 +113,8 @@ int fgPlatformGlutGet ( GLenum eWhat )
case GLUT_WINDOW_Y: return y; case GLUT_WINDOW_Y: return y;
} }
if ( w == 0 ) if ( w == 0 || fgStructure.CurrentWindow->Parent)
/* logic below needs w, and child windows don't have borders */
return 0; return 0;
XTranslateCoordinates( XTranslateCoordinates(
fgDisplay.pDisplay.Display, fgDisplay.pDisplay.Display,