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 値「slot」を使用しているため、weston はマルチタッチを適切に処理していないことがわかりました。
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_SYN
weston は最初のスロット イベントから EV_SYN イベントまでのイベントを処理し、EV_SYN が発生した場合は notify_touch() を呼び出します。したがって、weston は、notify_touch() を介して異なるスロット番号パラメーターで 2 つのタッチダウン イベントを連続して送信することはできません。
私の再実装では、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;
- num_down_event: 触れた指の数を追跡する
- num_motion_event: 指の動きを追跡する
- num_up_event: 何本の指が持ち上げられたかを追跡します
- スロット: すべてのタッチ フレームでスロット番号を追跡します