xcb-xinput: Issue when creating master devices
I have been trying to switch an application from xlib to xcb. The application made Xlib calls like
XIAddMasterInfo add = {.type = XIAddMaster, .name = (char*)name, .send_core = 1, .enable = 1};
XIChangeHierarchy(dpy, (XIAnyHierarchyChangeInfo*)&add, 1);
And have been failing to convert it to xcb. Looking at similar calls (and the limited documentation), I've attempted the following (simplified for the sake of clarity)
#include <xcb/xinput.h>
typedef struct {
xcb_input_hierarchy_change_t change;
xcb_input_hierarchy_change_data_t data;
} xcb_hierachry_change_holder;
int main() {
xcb_connection_t* dis = xcb_connect(NULL, NULL);
char name[5] = "name";
xcb_hierachry_change_holder changes = {
{XCB_INPUT_HIERARCHY_CHANGE_TYPE_ADD_MASTER, 1},
{.add_master = { .name_len = 4, .send_core = 1, .enable = 1, .name = (char*)name}}
};
xcb_input_xi_change_hierarchy(dis, 1, &changes.change);
xcb_flush(dis);
xcb_disconnect(dis);
}
Any guesses on what this actually does?
xinput
⎡ Virtual core pointer id=2 [master pointer (3)]
...
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
...
⎡ pointer id=9 [master pointer (0)]
⎣ keyboard id=10 [master keyboard (0)]
↳ XTEST keyboard id=18 [slave keyboard (10)]
∼ XTEST pointer id=17 [floating slave]
It kinda worked, but the master devices don't have the name and they aren't linked to the paired device. The XTEST device being floating is a probably also not a good sign. I have similar problems with the other XCB_INPUT_HIERARCHY_CHANGE_TYPE. Can read the current state with xcb fine and everything seemed to work with Xlib.