我想让QT5.1.1触摸示例应用程序与qtwayland模块一起工作。
我看到了橱窗,还有威斯顿的触摸痕迹。我看到qtwayland也是被触发的回调功能,是注册的触摸向上,触摸向下,触摸运动。
但是,QT不会在QT应用程序中调用QPushButton处理程序。
连接API使用如下:连接(ui->b_音频,信号(按下()),这个,插槽(on_b_audio_clicked();
知道为什么会发生这种事吗?请提出可能的问题,以便我可以探索和调试。
提前谢谢。布什汉。
发布于 2014-01-17 10:42:44
在QtWayland中,QWaylandInputDevice::touch_frame()通过QWindowSystemInterface::handleTouchEvent()将触点传递到Qt内部窗口系统。Weston根本不发送WL_TOUCH_FRAME事件,因此按钮或QML MouseArea永远不会接收触摸事件。您可以在weston/src/evdev.c中的evdev_flush_motion()结尾添加以下行:
notify_touch(master, time, 0, 0, 0, WL_TOUCH_FRAME);并在weston/src/input.c中重写notify_touch():
WL_EXPORT void
notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
wl_fixed_t x, wl_fixed_t y, int touch_type)
{
struct weston_compositor *ec = seat->compositor;
struct weston_touch *touch = seat->touch;
struct weston_touch_grab *grab = touch->grab;
struct weston_surface *es;
wl_fixed_t sx, sy;
struct weston_touch *grab_touch = grab->touch;
/* Update grab's global coordinates. */
touch->grab_x = x;
touch->grab_y = y;
switch (touch_type) {
case WL_TOUCH_DOWN:
weston_compositor_idle_inhibit(ec);
seat->num_tp++;
/* the first finger down picks the surface, and all further go
* to that surface for the remainder of the touch session i.e.
* until all touch points are up again. */
if (seat->num_tp == 1) {
es = weston_compositor_pick_surface(ec, x, y, &sx, &sy);
weston_touch_set_focus(seat, es);
} else if (touch->focus) {
es = (struct weston_surface *) touch->focus;
weston_surface_from_global_fixed(es, x, y, &sx, &sy);
} else {
/* Unexpected condition: We have non-initial touch but
* there is no focused surface.
*/
weston_log("touch event received with %d points down"
"but no surface focused\n", seat->num_tp);
return;
}
grab->interface->down(grab, time, touch_id, sx, sy);
if (seat->num_tp == 1) {
touch->grab_serial =
wl_display_get_serial(ec->wl_display);
touch->grab_time = time;
touch->grab_x = x;
touch->grab_y = y;
}
break;
case WL_TOUCH_MOTION:
es = (struct weston_surface *) touch->focus;
if (!es)
break;
weston_surface_from_global_fixed(es, x, y, &sx, &sy);
grab->interface->motion(grab, time, touch_id, sx, sy);
break;
case WL_TOUCH_UP:
weston_compositor_idle_release(ec);
seat->num_tp--;
grab->interface->up(grab, time, touch_id);
break;
case WL_TOUCH_FRAME:
if (grab_touch->focus_resource) {
wl_touch_send_frame(grab_touch->focus_resource);
if (seat->num_tp == 0)
weston_touch_set_focus(seat, NULL);
}
}
}同时,我发现weston不能正确处理多点触摸,因为它的mt结构(下面)使用了一个int值“槽”,它只能跟踪当前的插槽号。
struct {
int slot;
int32_t x[MAX_SLOTS];
int32_t y[MAX_SLOTS];
} mt;在多点触摸协议类型B中,每个插槽与一个手指接触相关联,并且在一个触摸帧中得到多个插槽事件,例如,一个touch_down帧;
ABS_MT_SLOT
ABS_MT_TRACKING_ID
ABS_MT_POSITION_X
ABS_MT_POSITION_Y
ABS_MT_SLOT
ABS_MT_TRACKING_ID
ABS_MT_POSITION_X
ABS_MT_POSITION_Y
EV_SYNweston处理从第一个时隙事件到EV_SYN事件的事件,如果遇到EV_SYN,则调用notify_touch()。因此,weston不能通过具有不同时隙号参数的notify_touch()顺序发送这两个触摸事件。
在我的重新实现中,我更改了mt结构:
struct {
int current_slot;
uint32_t num_down_event;
uint32_t num_motion_event;
uint32_t num_up_event;
int slots[MAX_CONTACTS];
int32_t x[MAX_SLOTS];
int32_t y[MAX_SLOTS];
} mt;发布于 2014-09-01 13:26:18
这是https://bugreports.qt-project.org/browse/QTBUG-36602,我们计划在QT5.4.0中提供一个解决方案。当我们这样做的时候,touch_frame似乎被发送到touch_motion,而不是touch_up。(用wayland、weston和libinput的最新版本进行测试)
https://stackoverflow.com/questions/18201614
复制相似问题