X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fx11%2Ffg_cursor_x11.c;h=6d889f25aa041c7a4e6ccd3fa626ce29c179f50f;hb=34617b0203c6a98039588e84b801aec805963610;hp=d8ce64c61d93b14f869b5cf9875268bf839c35e2;hpb=450b0d2bd03f4d7721fa2fe5f54f38d787accb06;p=freeglut diff --git a/src/x11/fg_cursor_x11.c b/src/x11/fg_cursor_x11.c index d8ce64c..6d889f2 100644 --- a/src/x11/fg_cursor_x11.c +++ b/src/x11/fg_cursor_x11.c @@ -1,5 +1,5 @@ /* - * freeglut_cursor_x11.c + * fg_cursor_x11.c * * The Windows-specific mouse cursor related stuff. * @@ -149,16 +149,27 @@ void fgPlatformWarpPointer ( int x, int y ) XFlush( fgDisplay.pDisplay.Display ); } -void fghPlatformGetCursorPos(SFG_XYUse *mouse_pos) +void fghPlatformGetCursorPos(const SFG_Window *window, GLboolean client, SFG_XYUse *mouse_pos) { - /* Get current pointer location in screen coordinates + /* Get current pointer location in screen coordinates (if client is false or window is NULL), else + * Get current pointer location relative to top-left of client area of window (if client is true and window is not NULL) */ + Window w = (client && window && window->Window.Handle)? window->Window.Handle: fgDisplay.pDisplay.RootWindow; Window junk_window; unsigned int junk_mask; - int junk_pos; + int clientX, clientY; - XQueryPointer(fgDisplay.pDisplay.Display, fgDisplay.pDisplay.RootWindow, + XQueryPointer(fgDisplay.pDisplay.Display, w, &junk_window, &junk_window, - &mouse_pos->X, &mouse_pos->Y, - &junk_pos, &junk_pos, &junk_mask); + &mouse_pos->X, &mouse_pos->Y, /* Screen coords relative to root window's top-left */ + &clientX, &clientY, /* Client coords relative to window's top-left */ + &junk_mask); + + if (client && window && window->Window.Handle) + { + mouse_pos->X = clientX; + mouse_pos->Y = clientY; + } + + mouse_pos->Use = GL_TRUE; }