X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fx11%2Ffg_cursor_x11.c;h=fcadb004ba670d3cfa6665e3e7a26cb6b7e4c835;hb=55b33225784fde2baa271c1351427afedd8068ec;hp=3098e53d9b6868b7652b2d859f44a0b33b6705ec;hpb=5b3d339481bac6dbaeb599bffc1325f716585bfe;p=freeglut diff --git a/src/x11/fg_cursor_x11.c b/src/x11/fg_cursor_x11.c index 3098e53..fcadb00 100644 --- a/src/x11/fg_cursor_x11.c +++ b/src/x11/fg_cursor_x11.c @@ -149,3 +149,27 @@ void fgPlatformWarpPointer ( int x, int y ) XFlush( fgDisplay.pDisplay.Display ); } +void fghPlatformGetCursorPos(const SFG_Window *window, GLboolean client, SFG_XYUse *mouse_pos) +{ + /* 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 clientX, clientY; + + XQueryPointer(fgDisplay.pDisplay.Display, w, + &junk_window, &junk_window, + &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; +}