【问题标题】:X11 - Setting Cursor Position Not WorkingX11 - 设置光标位置不起作用
【发布时间】: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 examplexdotool mousemove_relative 50 50 怎么样,对你有用吗?
  • 我可以尽快尝试做一个例子,但 xdotool 什么也没做。
  • 所以看起来你的 X 服务器阻止了鼠标扭曲工作。您可能在使用虚拟机吗?

标签: linux cursor mouse x11 windowing


【解决方案1】:

这个问题的答案比较傻。我在 Wayland 上使用 Gnome,假设它也支持 X11。我猜错了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-01-31
    • 1970-01-01
    • 1970-01-01
    • 2012-12-13
    • 1970-01-01
    • 2022-10-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多