多屏系统中C中鼠标光标位置
在多屏Linux下,如何在C语言的X窗口中设置鼠标光标?我有 2 个显示器(具有不同的分辨率)插入到一台 Linux 电脑上。 我使用“:0.1”来寻址第二个监视器。我从显示器 1 运行应用程序,同时将鼠标保持在显示器 1 上......结果鼠标移动但不会跳到显示器 2 上。 如果我手动将鼠标光标放在显示器 2 上并从显示器 1 运行应用程序,鼠标就会移动。
我需要一种在显示器之间移动光标的方法。
#include "Xlib.h"
int main() {
int delta_x = 5, delta_y = 5;
Display *display = XOpenDisplay(":0.1");
// move pointer relative to current position
XWarpPointer(display, None, None, 0, 0, 0, 0, delta_x, delta_y);
XCloseDisplay(display);
}
how can I set the mouse cursor in an X window in C under Linux with multi screens? I have 2 monitors (with different resolution) plugged to a single linux pc.
I used ":0.1" to address the second monitor. I run the application from monitor 1 keeping the mouse on the monitor 1 as well....as result mouse moves but don't jump on monitor 2.
If I manually put the mouse cursor on monitor 2 and run the application from monitor 1, mouse moves.
I need a way to move the cursor between monitors.
#include "Xlib.h"
int main() {
int delta_x = 5, delta_y = 5;
Display *display = XOpenDisplay(":0.1");
// move pointer relative to current position
XWarpPointer(display, None, None, 0, 0, 0, 0, delta_x, delta_y);
XCloseDisplay(display);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要传递您希望指针移动到的显示器的根窗口的句柄:
这里有一个完整的工作 C 示例:
http://www.ishiboo.com/~danny/Projects/xwarppointer/
可能有用:)
You need to pass the handle of the root window of the display you want the pointer to move to:
There is a complete working C example here:
http://www.ishiboo.com/~danny/Projects/xwarppointer/
which may be of use :)