X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_cursor.c;h=390e0cbf81b7c4b27b691392a9def619ca81a89c;hb=a14928fc505633d395e18db84ce7dbfd7386fa5f;hp=e473e16ccbc0fa5939ffcf2dba6f096453b49f12;hpb=bc2136f7281927764a09f6c66d59336c5bf77f98;p=freeglut diff --git a/src/freeglut_cursor.c b/src/freeglut_cursor.c index e473e16..390e0cb 100644 --- a/src/freeglut_cursor.c +++ b/src/freeglut_cursor.c @@ -28,7 +28,7 @@ #include #include "freeglut_internal.h" -#if TARGET_HOST_UNIX_X11 +#if TARGET_HOST_POSIX_X11 #include #endif @@ -41,9 +41,9 @@ * apart from the windowing system version. */ -/* -- INTERNAL FUNCTIONS --------------------------------------------------- */ +/* -- PRIVATE FUNCTIONS --------------------------------------------------- */ -#if TARGET_HOST_UNIX_X11 +#if TARGET_HOST_POSIX_X11 /* * A factory method for an empty cursor */ @@ -104,17 +104,14 @@ static cursorCacheEntry cursorCache[] = { }; #endif -/* -- INTERFACE FUNCTIONS -------------------------------------------------- */ +/* -- INTERNAL FUNCTIONS ---------------------------------------------------- */ /* * Set the cursor image to be used for the current window */ -void FGAPIENTRY glutSetCursor( int cursorID ) +void fgSetCursor ( SFG_Window *window, int cursorID ) { - FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetCursor" ); - FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetCursor" ); - -#if TARGET_HOST_UNIX_X11 +#if TARGET_HOST_POSIX_X11 { Cursor cursor; /* @@ -150,23 +147,25 @@ void FGAPIENTRY glutSetCursor( int cursorID ) } } - if ( ( cursorIDToUse != GLUT_CURSOR_NONE ) && ( cursor == None ) ) { + if ( cursorIDToUse == GLUT_CURSOR_INHERIT ) { + XUndefineCursor( fgDisplay.Display, window->Window.Handle ); + } else if ( cursor != None ) { + XDefineCursor( fgDisplay.Display, window->Window.Handle, cursor ); + } else if ( cursorIDToUse != GLUT_CURSOR_NONE ) { fgError( "Failed to create cursor" ); } - XDefineCursor( fgDisplay.Display, - fgStructure.Window->Window.Handle, cursor ); } -#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE +#elif TARGET_HOST_MS_WINDOWS /* - * This is a temporary solution only... + * Joe Krahn is re-writing the following code. */ /* Set the cursor AND change it for this window class. */ # define MAP_CURSOR(a,b) \ case a: \ SetCursor( LoadCursor( NULL, b ) ); \ - SetClassLong( fgStructure.Window->Window.Handle, \ + SetClassLong( window->Window.Handle, \ GCL_HCURSOR, \ ( LONG )LoadCursor( NULL, b ) ); \ break; @@ -175,7 +174,7 @@ void FGAPIENTRY glutSetCursor( int cursorID ) # define ZAP_CURSOR(a,b) \ case a: \ SetCursor( NULL ); \ - SetClassLong( fgStructure.Window->Window.Handle, \ + SetClassLong( window->Window.Handle, \ GCL_HCURSOR, ( LONG )NULL ); \ break; @@ -211,7 +210,20 @@ void FGAPIENTRY glutSetCursor( int cursorID ) } #endif - fgStructure.Window->State.Cursor = cursorID; + window->State.Cursor = cursorID; +} + +/* -- INTERFACE FUNCTIONS -------------------------------------------------- */ + +/* + * Set the cursor image to be used for the current window + */ +void FGAPIENTRY glutSetCursor( int cursorID ) +{ + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetCursor" ); + FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetCursor" ); + + fgSetCursor ( fgStructure.CurrentWindow, cursorID ); } /* @@ -222,19 +234,19 @@ void FGAPIENTRY glutWarpPointer( int x, int y ) FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWarpPointer" ); FREEGLUT_EXIT_IF_NO_WINDOW ( "glutWarpPointer" ); -#if TARGET_HOST_UNIX_X11 +#if TARGET_HOST_POSIX_X11 XWarpPointer( fgDisplay.Display, None, - fgStructure.Window->Window.Handle, + fgStructure.CurrentWindow->Window.Handle, 0, 0, 0, 0, x, y ); /* Make the warp visible immediately. */ XFlush( fgDisplay.Display ); -#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE +#elif TARGET_HOST_MS_WINDOWS { POINT coords; @@ -242,7 +254,7 @@ void FGAPIENTRY glutWarpPointer( int x, int y ) coords.y = y; /* ClientToScreen() translates {coords} for us. */ - ClientToScreen( fgStructure.Window->Window.Handle, &coords ); + ClientToScreen( fgStructure.CurrentWindow->Window.Handle, &coords ); SetCursorPos( coords.x, coords.y ); }