Moving the mouse pointer in C++ fails on Linux

流过昼夜 提交于 2019-12-24 01:12:39

问题


I'm using the following code to hide and show the mouse cursor:

XDefineCursor( m_display, m_window, show ? None : m_hiddenCursor );  
XFlush( m_display );

That works fine. However, when I run this:

XWarpPointer( m_display, None, m_window, 0, 0, 0, 0, x, y );
XFlush( m_display );

The mouse doesn't move at all. Simply nothing happens. SetMousePos, which I'm using for Windows, works fine.


回答1:


It's been a while, but doesn't XWarpPointer make a relative move of the cursor using the passed offsets? It looks like the passed offsets are (0,0) meaning that the cursor wouldn't move. I think the routine you want to use is XMovePointer.

Share and enjoy.



来源:https://stackoverflow.com/questions/4155282/moving-the-mouse-pointer-in-c-fails-on-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!