From fed8fe1b9bedd4557d723759138c8e1c5ec7deb0 Mon Sep 17 00:00:00 2001 From: songliy Date: Mon, 18 Oct 2021 21:48:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E6=A8=A1=E6=8F=90=E4=BA=A4=E8=81=94?= =?UTF-8?q?=E8=B0=83=E4=BB=A3=E7=A0=81=20Signed-off-by:=20licheng.li=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BUILD.gn | 11 +++++--- libweston/libinput-device.c | 46 +++++++++++++++++++++------------- libweston/libinput-seat.c | 50 +++++++++++++++++++++++++------------ weston.ini | 2 +- 4 files changed, 71 insertions(+), 38 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index af4b3d0d..e52cbe42 100755 --- a/BUILD.gn +++ b/BUILD.gn @@ -1,4 +1,5 @@ import("//build/ohos.gni") +import("//foundation/multimodalinput/input/multimodalinput_mini.gni") import("//third_party/wayland_standard/wayland_protocol.gni") group("default") { @@ -151,8 +152,8 @@ ohos_shared_library("libweston") { deps = [ ":trace", + "//foundation/multimodalinput/input/patch/diff_libinput_mmi:libinput-third-mmi", "//third_party/libdrm:libdrm", - "//third_party/libinput:libinput-third", "//utils/native/base:utils", ] @@ -221,7 +222,7 @@ ohos_static_library("libexec_weston") { ":trace", ":weston_screenshooter_protocol", "//foundation/graphic/standard/frameworks/vsync:libvsync_module", - "//third_party/libinput:libinput-third", + "//foundation/multimodalinput/input/patch/diff_libinput_mmi:libinput-third-mmi", "//third_party/wayland-protocols_standard:input_method_unstable_v1_protocol", "//third_party/wayland-protocols_standard:text_input_unstable_v1_protocol", ] @@ -425,14 +426,18 @@ ohos_shared_library("drm-backend") { ":libweston", ":trace", "//foundation/graphic/standard/frameworks/vsync:libvsync_module", + "//foundation/multimodalinput/input/patch/diff_libinput_mmi:libinput-third-mmi", "//third_party/libdrm:libdrm", - "//third_party/libinput:libinput-third", "//third_party/wayland-protocols_standard:linux_dmabuf_unstable_v1_protocol", "//third_party/wayland-protocols_standard:presentation_time_protocol", "//third_party/wayland-protocols_standard:relative_pointer_unstable_v1_protocol", "//third_party/wayland_standard:wayland_core_protocol", ] + if (is_mmi_have_hdf) { + defines = [ "LIBINPUT_THIRD_HDF" ] + } + public_deps = [] part_name = "graphic_standard" diff --git a/libweston/libinput-device.c b/libweston/libinput-device.c index 65652209..6d33929f 100644 --- a/libweston/libinput-device.c +++ b/libweston/libinput-device.c @@ -385,31 +385,41 @@ static const struct weston_touch_device_ops touch_calibration_ops = { static struct weston_touch_device * create_touch_device(struct evdev_device *device) { - const struct weston_touch_device_ops *ops = NULL; - struct weston_touch_device *touch_device; - struct udev_device *udev_device; + const struct weston_touch_device_ops *ops = NULL; + struct weston_touch_device *touch_device; +#ifndef LIBINPUT_THIRD_HDF + struct udev_device *udev_device; +#endif - if (libinput_device_config_calibration_has_matrix(device->device)) - ops = &touch_calibration_ops; + if (libinput_device_config_calibration_has_matrix(device->device)) + ops = &touch_calibration_ops; - udev_device = libinput_device_get_udev_device(device->device); - if (!udev_device) - return NULL; +#ifndef LIBINPUT_THIRD_HDF + udev_device = libinput_device_get_udev_device(device->device); + if (!udev_device) + return NULL; +#endif - touch_device = weston_touch_create_touch_device(device->seat->touch_state, - udev_device_get_syspath(udev_device), - device, ops); + touch_device = weston_touch_create_touch_device(device->seat->touch_state, +#ifndef LIBINPUT_THIRD_HDF + udev_device_get_syspath(udev_device), +#else + "hdf", +#endif + device, ops); - udev_device_unref(udev_device); +#ifndef LIBINPUT_THIRD_HDF + udev_device_unref(udev_device); +#endif - if (!touch_device) - return NULL; + if (!touch_device) + return NULL; - weston_log("Touchscreen - %s - %s\n", - libinput_device_get_name(device->device), - touch_device->syspath); + weston_log("Touchscreen - %s - %s\n", + libinput_device_get_name(device->device), + touch_device->syspath); - return touch_device; + return touch_device; } static void diff --git a/libweston/libinput-seat.c b/libweston/libinput-seat.c index ac88fb5b..5982d9c5 100644 --- a/libweston/libinput-seat.c +++ b/libweston/libinput-seat.c @@ -212,25 +212,43 @@ process_event(struct libinput_event *event) return; } +bool +is_touch_active(struct libinput_event* event) +{ + if (!event) { + return false; + } + enum libinput_event_type type = libinput_event_get_type(event); + if (type == LIBINPUT_EVENT_TOUCH_DOWN || type == LIBINPUT_EVENT_TOUCH_MOTION) { + struct libinput_device *libinput_dev = libinput_event_get_device(event); + if (!libinput_dev) { + return false; + } + struct evdev_device *device = libinput_device_get_user_data(libinput_dev); + if (!device || !device->output) { + return false; + } + struct weston_touch *touch = device->touch_device->aggregate; + if (!touch || !weston_touch_has_focus_resource(touch)) { + return false; + } + } + return true; +} + static void process_events(struct udev_input *input) { - struct libinput_event *event; - - while ((event = libinput_get_event(input->libinput))) { - process_event(event); - // for multi model input. - if (g_libinput_event_listener) - { - weston_log("process_events: call libinput_event_listener.\n"); - g_libinput_event_listener(event); - } - else - { - weston_log("process_events: libinput_event_listener is not set.\n"); - } - libinput_event_destroy(event); - } + struct libinput_event *event = NULL; + while ((event = libinput_get_event(input->libinput))) { + process_event(event); + if (g_libinput_event_listener && is_touch_active(event)) { + g_libinput_event_listener(event); + } else { + weston_log("process_events: libinput_event_listener is not set.\n"); + } + libinput_event_destroy(event); + } } static int diff --git a/weston.ini b/weston.ini index 4f90b21a..7861dd0f 100644 --- a/weston.ini +++ b/weston.ini @@ -1,6 +1,6 @@ [core] shell=libivi-shell.z.so -modules=libivi-controller.z.so,libwmserver.z.so +modules=libivi-controller.z.so,libwmserver.z.so,libmmi-server.z.so [ivi-shell] ivi-input-module=libivi-input-controller.z.so