From 409ca5b1336e43b80eb030634f43ef6b707ee3ad Mon Sep 17 00:00:00 2001 From: dcnieho Date: Fri, 23 Nov 2012 08:21:24 +0000 Subject: [PATCH] now providing new position of child relative to parent in the position callback also need to set position func for the child window in the resizer demo git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1480 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/freeglut/progs/demos/Resizer/Resizer.cpp | 4 +++- freeglut/freeglut/src/mswin/fg_main_mswin.c | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/freeglut/freeglut/progs/demos/Resizer/Resizer.cpp b/freeglut/freeglut/progs/demos/Resizer/Resizer.cpp index c2ca76d..3caf38e 100644 --- a/freeglut/freeglut/progs/demos/Resizer/Resizer.cpp +++ b/freeglut/freeglut/progs/demos/Resizer/Resizer.cpp @@ -12,7 +12,8 @@ GLboolean bChildPosDone = GL_FALSE, bChildSizeDone = GL_FALSE; void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY ); void Redisplay(); -void Reshape(int x, int y); +void Reshape(int width, int height); +void Position(int x, int y); @@ -117,6 +118,7 @@ void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY ) glutKeyboardFunc( SampleKeyboard ); glutDisplayFunc( Redisplay ); glutReshapeFunc( Reshape ); + glutPositionFunc( Position ); } else { diff --git a/freeglut/freeglut/src/mswin/fg_main_mswin.c b/freeglut/freeglut/src/mswin/fg_main_mswin.c index 981acad..3ecde1f 100644 --- a/freeglut/freeglut/src/mswin/fg_main_mswin.c +++ b/freeglut/freeglut/src/mswin/fg_main_mswin.c @@ -432,6 +432,18 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, SFG_Window* saved_window = fgStructure.CurrentWindow; RECT windowRect; GetWindowRect( window->Window.Handle, &windowRect ); + + if (window->Parent) + { + /* For child window, we should return relative to upper-left + * of parent's client area. + */ + POINT topleft = {windowRect.left,windowRect.top}; + + ScreenToClient(window->Parent->Window.Handle,&topleft); + windowRect.left = topleft.x; + windowRect.top = topleft.y; + } INVOKE_WCB( *window, Position, ( windowRect.left, windowRect.top ) ); fgSetWindow(saved_window);