简体   繁体   English

将XCB事件移植到XLib事件

[英]Porting XCB events to XLib Events

I'm using Qt 5.3.2 and an input handling library called gainput . 我正在使用Qt 5.3.2和一个名为gainput的输入处理库。 Gainput can only accept XLib events and not XCB event structures. Gainput只能接受XLib事件,不能接受XCB事件结构。 The big problem is that Qt is using xcb. 最大的问题是Qt正在使用xcb。 Is there some "easy" way of porting xcb events to xlib events? 有没有将xcb事件移植到xlib事件的“简便”方法?

xcb_generic_event_t* xcbEvent = /* ... Poll/Wait for events ... */
XEvent* xlibEvent = GenericEventConvertionFunction(xcbEvent); // Something like this...

I don't think there is an easy way to get what you are looking for. 我认为没有一种简单的方法可以得到想要的东西。

I'm not familiar with Qt, gainput or the nature of your project, but you can "convert" an existing Xlib connection into an xcb connecion . 我不熟悉Qt,putput或项目的性质,但是您可以将现有的Xlib连接“转换”为xcb连接 This way you can mix Xlib and XCB calls. 这样,您可以混合使用Xlib和XCB调用。

Only one of Xlib and XCB can manage the event queue. Xlib和XCB中只有一个可以管理事件队列。 By default, Xlib does. 默认情况下,Xlib会这样做。 To change this, call XSetEventQueueOwner() (from "Xlib-xcb.h") before making other calls. 要更改此设置,请在进行其他调用之前调用XSetEventQueueOwner()(来自“ Xlib-xcb.h”)。

Ideally you could inititally create a Xlib Display object, create a corresponding xcb_display, use the former for Qt and poll/wait on the latter and pass it gainput 理想情况下,您可以初始创建一个Xlib Display对象,创建一个对应的xcb_display,将前者用于Qt并对其进行轮询/等待,然后将其传递给gainput

One thing of note is that you can only convert one way. 需要注意的一件事是,您只能转换一种方式。

How do you get a Display object given an xcb_connection_t object? 给定xcb_connection_t对象,如何获取显示对象? You can't. 你不能

If this solution is not sufficient. 如果此解决方案还不够。 I know of no good way to solve your problem. 我知道没有解决您问题的好方法。 On the bright side Xlib and xcb events are more of less equivalent so a manual conversion wouldn't be too hard (the sizes of at least some events of are different so straight casting won't be enough) 从好的方面来说,Xlib和xcb事件的等效性较小,因此手动转换不会太难(至少某些事件的大小不同,因此直接进行转换是不够的)

EDIT 编辑

I believe someone had a similar question a few years ago. 我相信几年前有人也有类似的问题 Apparently Display *display = QX11Info::display(); 显然Display *display = QX11Info::display(); is a thing you can do 你可以做的一件事

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM