From 88ff42cfa5f0e82e980aea7ba663a0bd148cfa83 Mon Sep 17 00:00:00 2001 From: Diederick Niehorster Date: Sun, 29 Jul 2012 05:11:53 +0000 Subject: [PATCH] some cleanup now have function fghPlatformGetMousePos to get current mouse position in screen coordinates Using this in fg_menu as all that code should be platform independent git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1376 7f0cb862-5218-0410-a997-914c9d46530a --- src/fg_internal.h | 4 +-- src/fg_menu.c | 11 ++++---- src/mswin/fg_window_mswin.c | 60 +++++++++++++++++++++++-------------------- 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/src/fg_internal.h b/src/fg_internal.h index 61ae5ce..129654a 100644 --- a/src/fg_internal.h +++ b/src/fg_internal.h @@ -371,8 +371,8 @@ struct tagSFG_Context SFG_PlatformContext pContext; /* The window's FBConfig (X11) or device context (Windows) */ int DoubleBuffered; /* Treat the window as double-buffered */ - GLint attribute_v_coord; - GLint attribute_v_normal; + GLint attribute_v_coord; + GLint attribute_v_normal; }; diff --git a/src/fg_menu.c b/src/fg_menu.c index f96295b..ff1b21e 100644 --- a/src/fg_menu.c +++ b/src/fg_menu.c @@ -720,12 +720,13 @@ void fgDeactivateMenu( SFG_Window *window ) if (fgState.MenuStatusCallback) { /* Get cursor position on screen and convert to relative to parent_window's client area */ - POINT mouse_pos; - GetCursorPos(&mouse_pos); - mouse_pos.x -= glutGet( GLUT_WINDOW_X ); - mouse_pos.y -= glutGet( GLUT_WINDOW_Y ); + SFG_XYUse mouse_pos; + fghPlatformGetMousePos(&mouse_pos); + + mouse_pos.X -= glutGet( GLUT_WINDOW_X ); + mouse_pos.Y -= glutGet( GLUT_WINDOW_Y ); - fgState.MenuStatusCallback(GLUT_MENU_NOT_IN_USE, mouse_pos.x, mouse_pos.y); + fgState.MenuStatusCallback(GLUT_MENU_NOT_IN_USE, mouse_pos.X, mouse_pos.Y); } } } diff --git a/src/mswin/fg_window_mswin.c b/src/mswin/fg_window_mswin.c index 2837c5c..b09c008 100644 --- a/src/mswin/fg_window_mswin.c +++ b/src/mswin/fg_window_mswin.c @@ -85,13 +85,6 @@ typedef BOOL (WINAPI *pRegisterTouchWindow)(HWND,ULONG); static pRegisterTouchWindow fghRegisterTouchWindow = (pRegisterTouchWindow)0xDEADBEEF; #endif -/* - * Helper functions for getting client area from the window rect - * and the window rect from the client area given the style of the window - * (or a valid window pointer from which the style can be queried). - */ -extern void fghGetBorderWidth(const DWORD windowStyle, int* xBorderWidth, int* yBorderWidth); - /* * Setup the pixel format for a Win32 window @@ -378,6 +371,38 @@ void fgPlatformSetWindow ( SFG_Window *window ) } +void fghPlatformGetMousePos(SFG_XYUse *mouse_pos) +{ + POINT pos; + GetCursorPos(&pos); + + mouse_pos->X = pos.x; + mouse_pos->Y = pos.y; + mouse_pos->Use = GL_TRUE; +} + +/* Returns the width of the window borders based on the window's style. +*/ +void fghGetBorderWidth(const DWORD windowStyle, int* xBorderWidth, int* yBorderWidth) +{ + if (windowStyle & WS_THICKFRAME) + { + *xBorderWidth = GetSystemMetrics(SM_CXSIZEFRAME); + *yBorderWidth = GetSystemMetrics(SM_CYSIZEFRAME); + } + else if (windowStyle & WS_DLGFRAME) + { + *xBorderWidth = GetSystemMetrics(SM_CXFIXEDFRAME); + *yBorderWidth = GetSystemMetrics(SM_CYFIXEDFRAME); + } + else + { + *xBorderWidth = 0; + *yBorderWidth = 0; + } +} + + /* Computes position of corners of window Rect (outer position including * decorations) based on the provided client rect and based on the style @@ -516,27 +541,6 @@ RECT fghGetClientArea( const SFG_Window *window, BOOL wantPosOutside ) return windowRect; } -/* Returns the width of the window borders based on the window's style. - */ -void fghGetBorderWidth(const DWORD windowStyle, int* xBorderWidth, int* yBorderWidth) -{ - if (windowStyle & WS_THICKFRAME) - { - *xBorderWidth = GetSystemMetrics(SM_CXSIZEFRAME); - *yBorderWidth = GetSystemMetrics(SM_CYSIZEFRAME); - } - else if (windowStyle & WS_DLGFRAME) - { - *xBorderWidth = GetSystemMetrics(SM_CXFIXEDFRAME); - *yBorderWidth = GetSystemMetrics(SM_CYFIXEDFRAME); - } - else - { - *xBorderWidth = 0; - *yBorderWidth = 0; - } -} - #if(WINVER >= 0x500) typedef struct { -- 1.7.10.4