From b0811138ccbb61486fc9d51372c31d591fcbcf85 Mon Sep 17 00:00:00 2001 From: dcnieho Date: Wed, 27 Aug 2014 10:14:44 +0000 Subject: [PATCH 1/2] caption height should include the width of the border atop the window git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1700 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/freeglut/progs/demos/Resizer/Resizer.cpp | 2 +- freeglut/freeglut/src/mswin/fg_state_mswin.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/freeglut/freeglut/progs/demos/Resizer/Resizer.cpp b/freeglut/freeglut/progs/demos/Resizer/Resizer.cpp index f2ff68a..4828915 100644 --- a/freeglut/freeglut/progs/demos/Resizer/Resizer.cpp +++ b/freeglut/freeglut/progs/demos/Resizer/Resizer.cpp @@ -334,7 +334,7 @@ void Timer(int unused) width, height, x ,y, x-border, - y-border-caption); + y-caption); else printf("child window %dx%d, top-left of client at: (%d,%d), relative to parent\n", width, height, diff --git a/freeglut/freeglut/src/mswin/fg_state_mswin.c b/freeglut/freeglut/src/mswin/fg_state_mswin.c index 4c0ca30..aada564 100644 --- a/freeglut/freeglut/src/mswin/fg_state_mswin.c +++ b/freeglut/freeglut/src/mswin/fg_state_mswin.c @@ -256,7 +256,7 @@ int fgPlatformGlutGet ( GLenum eWhat ) * all other extra pixels are assumed to be atop the window, forming the caption. */ borderWidth = ((winRect.right-winRect.left)-(clientRect.right-clientRect.left))/2; - captionHeight = (winRect.bottom-winRect.top)-(clientRect.bottom-clientRect.top)-borderWidth*2; + captionHeight = (winRect.bottom-winRect.top)-(clientRect.bottom-clientRect.top)-borderWidth; /* include top border in caption height */ switch( eWhat ) { From 9141845a49e5e114476d6c948fc8caa9471fb320 Mon Sep 17 00:00:00 2001 From: dcnieho Date: Wed, 27 Aug 2014 11:45:58 +0000 Subject: [PATCH 2/2] 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 --- freeglut/freeglut/src/x11/fg_state_x11.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/freeglut/freeglut/src/x11/fg_state_x11.c b/freeglut/freeglut/src/x11/fg_state_x11.c index 206478f..79a7ac9 100644 --- a/freeglut/freeglut/src/x11/fg_state_x11.c +++ b/freeglut/freeglut/src/x11/fg_state_x11.c @@ -88,15 +88,23 @@ int fgPlatformGlutGet ( GLenum eWhat ) case GLUT_WINDOW_HEADER_HEIGHT: { int x, y; - Window w; + Window p,w; if( fgStructure.CurrentWindow == NULL ) 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( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, - fgDisplay.pDisplay.RootWindow, + p, 0, 0, &x, &y, &w); switch ( eWhat ) @@ -105,7 +113,8 @@ int fgPlatformGlutGet ( GLenum eWhat ) 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; XTranslateCoordinates( fgDisplay.pDisplay.Display,