【发布时间】:2017-03-23 10:25:23
【问题描述】:
我正在尝试设置我的 X11 光标位置。我尝试调用 XWarpPointer 并将窗口设置为无、根 (DefaultRootWindow(display)) 到先前创建的窗口 (XCreateWindow)。正在调用该函数,鼠标速度变慢了一点,但它并没有实际移动。为什么会这样?
void GameWindow::ResetCursor() {
SetCursor(resX / 2, resY / 2);
}
void GameWindow::SetCursor(int x, int y) {
// Window root = DefaultRootWindow(display);
XWarpPointer(display, None, root, 0, 0, 0, 0, x, y);
XFlush(display);
}
编辑:这是整个 X11 窗口化文件,以防您在此处找不到原因。 https://gist.github.com/KarimIO/7db1f50778fda63a36c10242989baab6
【问题讨论】:
-
无法编译您的源代码,没有头文件。请出示minimal reproducible example。
-
我的代码有几万行。不确定,但相当大。
-
你应该把它减少到minimal reproducible example。
xdotool mousemove_relative 50 50怎么样,对你有用吗? -
我可以尽快尝试做一个例子,但 xdotool 什么也没做。
-
所以看起来你的 X 服务器阻止了鼠标扭曲工作。您可能在使用虚拟机吗?
标签: linux cursor mouse x11 windowing