Controlling multiple pointers with Xlib or xinput in ubuntu/linux

廉价感情. 提交于 2021-02-10 23:25:50

问题


I'm creating a system that uses multiple cursors (pointers) in multiple xsessions. My computer has multiple video cards in it for controlling different monitors. I want to have a different cursor on each screen and control each. Each monitor is a different session.

I started using the xlib library in C to control the single cursor I have using the following command:

XWarpPointer(display,None,window,0,0,0,0,x,y);

This works perfectly for one cursor. Then I created a second cursor using xinput in the terminal:

>>xinput create-master second

and then I have two cursors on screen. I can go and control each with a separate mouse by using the reattach command:

>>xinput reattach MOUSEID POINTERID

The last step is to control each cursor separately using xlib. When I use the xWarpPointer command it just moves the original cursor around and I can't find a way to designate which cursor to control. I have also been unable to find a way to set the default pointer. You can see a list of all the pointers using "xinput list" in terminal. Does anyone know how I can

Thanks for the help!


回答1:


You need to use XIWarpPointer request from XInput2 extension, it takes deviceid as parameter

Bool     XIWarpPointer(
        Display*            display,
        int                 deviceid,
        Window              src_win,
        Window              dst_win,
        double              src_x,
        double              src_y,
        unsigned int        src_width,
        unsigned int        src_height,
        double              dst_x,
        double              dst_y
    );


来源:https://stackoverflow.com/questions/13714831/controlling-multiple-pointers-with-xlib-or-xinput-in-ubuntu-linux

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