Title: [233421] trunk/Tools
Revision
233421
Author
[email protected]
Date
2018-07-02 04:51:40 -0700 (Mon, 02 Jul 2018)

Log Message

[WPE] Add touch support to WindowViewBackend
https://bugs.webkit.org/show_bug.cgi?id=187245

Reviewed by Carlos Garcia Campos.

Add touch input support to the WindowViewBackend implementation,
plugging into the Wayland protocol in order to get properly notified
about these events, and then dispatching them against the appropriate
wpe_view_backend object so that WebKit can process them.

* wpe/backends/ViewBackend.cpp:
(WPEToolingBackends::ViewBackend::dispatchInputTouchEvent):
* wpe/backends/ViewBackend.h:
* wpe/backends/WindowViewBackend.cpp:
* wpe/backends/WindowViewBackend.h:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (233420 => 233421)


--- trunk/Tools/ChangeLog	2018-07-02 11:41:30 UTC (rev 233420)
+++ trunk/Tools/ChangeLog	2018-07-02 11:51:40 UTC (rev 233421)
@@ -1,3 +1,21 @@
+2018-07-02  Zan Dobersek  <[email protected]>
+
+        [WPE] Add touch support to WindowViewBackend
+        https://bugs.webkit.org/show_bug.cgi?id=187245
+
+        Reviewed by Carlos Garcia Campos.
+
+        Add touch input support to the WindowViewBackend implementation,
+        plugging into the Wayland protocol in order to get properly notified
+        about these events, and then dispatching them against the appropriate
+        wpe_view_backend object so that WebKit can process them.
+
+        * wpe/backends/ViewBackend.cpp:
+        (WPEToolingBackends::ViewBackend::dispatchInputTouchEvent):
+        * wpe/backends/ViewBackend.h:
+        * wpe/backends/WindowViewBackend.cpp:
+        * wpe/backends/WindowViewBackend.h:
+
 2018-07-02  Rob Buis  <[email protected]>
 
         [GTK] ASSERTION FAILED: url == m_string in UserAgentQuirks test

Modified: trunk/Tools/wpe/backends/ViewBackend.cpp (233420 => 233421)


--- trunk/Tools/wpe/backends/ViewBackend.cpp	2018-07-02 11:41:30 UTC (rev 233420)
+++ trunk/Tools/wpe/backends/ViewBackend.cpp	2018-07-02 11:51:40 UTC (rev 233421)
@@ -134,4 +134,11 @@
     wpe_view_backend_dispatch_keyboard_event(backend(), event);
 }
 
+void ViewBackend::dispatchInputTouchEvent(struct wpe_input_touch_event* event)
+{
+    if (m_inputClient && m_inputClient->dispatchTouchEvent(event))
+        return;
+    wpe_view_backend_dispatch_touch_event(backend(), event);
+}
+
 } // namespace WPEToolingBackends

Modified: trunk/Tools/wpe/backends/ViewBackend.h (233420 => 233421)


--- trunk/Tools/wpe/backends/ViewBackend.h	2018-07-02 11:41:30 UTC (rev 233420)
+++ trunk/Tools/wpe/backends/ViewBackend.h	2018-07-02 11:51:40 UTC (rev 233421)
@@ -50,6 +50,7 @@
         virtual bool dispatchPointerEvent(struct wpe_input_pointer_event*) { return false; }
         virtual bool dispatchAxisEvent(struct wpe_input_axis_event*) { return false; }
         virtual bool dispatchKeyboardEvent(struct wpe_input_keyboard_event*) { return false; }
+        virtual bool dispatchTouchEvent(struct wpe_input_touch_event*) { return false; }
     };
     void setInputClient(std::unique_ptr<InputClient>&&);
 
@@ -63,6 +64,7 @@
     void dispatchInputPointerEvent(struct wpe_input_pointer_event*);
     void dispatchInputAxisEvent(struct wpe_input_axis_event*);
     void dispatchInputKeyboardEvent(struct wpe_input_keyboard_event*);
+    void dispatchInputTouchEvent(struct wpe_input_touch_event*);
 
     virtual void displayBuffer(struct wl_resource*) = 0;
 

Modified: trunk/Tools/wpe/backends/WindowViewBackend.cpp (233420 => 233421)


--- trunk/Tools/wpe/backends/WindowViewBackend.cpp	2018-07-02 11:41:30 UTC (rev 233420)
+++ trunk/Tools/wpe/backends/WindowViewBackend.cpp	2018-07-02 11:51:40 UTC (rev 233421)
@@ -311,6 +311,66 @@
     },
 };
 
+const struct wl_touch_listener WindowViewBackend::s_touchListener = {
+    // down
+    [](void* data, struct wl_touch*, uint32_t, uint32_t time, struct wl_surface* surface, int32_t id, wl_fixed_t x, wl_fixed_t y)
+    {
+        auto& window = *static_cast<WindowViewBackend*>(data);
+        if (window.m_surface != surface || id < 0 || id >= 10)
+            return;
+
+        auto& seatData = window.m_seatData;
+        seatData.touch.tracking = true;
+        struct wpe_input_touch_event_raw rawEvent = { wpe_input_touch_event_type_down,
+            time, id, wl_fixed_to_int(x), wl_fixed_to_int(y) };
+        memcpy(&seatData.touch.points[id], &rawEvent, sizeof(struct wpe_input_touch_event_raw));
+
+        struct wpe_input_touch_event event = { seatData.touch.points, 10,
+            rawEvent.type, rawEvent.id, rawEvent.time };
+        window.dispatchInputTouchEvent(&event);
+    },
+    // up
+    [](void* data, struct wl_touch*, uint32_t, uint32_t time, int32_t id)
+    {
+        auto& window = *static_cast<WindowViewBackend*>(data);
+        auto& seatData = window.m_seatData;
+        if (!seatData.touch.tracking || id < 0 || id >= 10)
+            return;
+
+        seatData.touch.tracking = false;
+
+        struct wpe_input_touch_event_raw rawEvent = { wpe_input_touch_event_type_up,
+            time, id, seatData.touch.points[id].x, seatData.touch.points[id].y };
+        memcpy(&seatData.touch.points[id], &rawEvent, sizeof(struct wpe_input_touch_event_raw));
+
+        struct wpe_input_touch_event event = { seatData.touch.points, 10,
+            rawEvent.type, rawEvent.id, rawEvent.time };
+        window.dispatchInputTouchEvent(&event);
+
+        memset(&seatData.touch.points[id], 0x00, sizeof(struct wpe_input_touch_event_raw));
+    },
+    // motion
+    [](void* data, struct wl_touch*, uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y)
+    {
+        auto& window = *static_cast<WindowViewBackend*>(data);
+        auto& seatData = window.m_seatData;
+        if (!seatData.touch.tracking || id < 0 || id >= 10)
+            return;
+
+        struct wpe_input_touch_event_raw rawEvent = { wpe_input_touch_event_type_motion,
+            time, id, wl_fixed_to_int(x), wl_fixed_to_int(y) };
+        memcpy(&seatData.touch.points[id], &rawEvent, sizeof(struct wpe_input_touch_event_raw));
+
+        struct wpe_input_touch_event event = { seatData.touch.points, 10,
+            rawEvent.type, rawEvent.id, rawEvent.time };
+        window.dispatchInputTouchEvent(&event);
+    },
+    // frame
+    [](void*, struct wl_touch*) { },
+    // cancel
+    [](void*, struct wl_touch*) { },
+};
+
 const struct wl_seat_listener WindowViewBackend::s_seatListener = {
     // capabilities
     [](void* data, struct wl_seat* seat, uint32_t capabilities)
@@ -339,6 +399,17 @@
             wl_keyboard_destroy(seatData.keyboard.object);
             seatData.keyboard.object = nullptr;
         }
+
+        // WL_SEAT_CAPABILITY_TOUCH
+        const bool hasTouchCap = capabilities & WL_SEAT_CAPABILITY_TOUCH;
+        if (hasTouchCap && !seatData.touch.object) {
+            seatData.touch.object = wl_seat_get_touch(seat);
+            wl_touch_add_listener(seatData.touch.object, &s_touchListener, window);
+        }
+        if (!hasTouchCap && seatData.touch.object) {
+            wl_touch_destroy(seatData.touch.object);
+            seatData.touch.object = nullptr;
+        }
     },
     // name
     [](void*, struct wl_seat*, const char*) { }

Modified: trunk/Tools/wpe/backends/WindowViewBackend.h (233420 => 233421)


--- trunk/Tools/wpe/backends/WindowViewBackend.h	2018-07-02 11:41:30 UTC (rev 233420)
+++ trunk/Tools/wpe/backends/WindowViewBackend.h	2018-07-02 11:51:40 UTC (rev 233421)
@@ -50,6 +50,7 @@
     static const struct zxdg_shell_v6_listener s_xdgWmBaseListener;
     static const struct wl_pointer_listener s_pointerListener;
     static const struct wl_keyboard_listener s_keyboardListener;
+    static const struct wl_touch_listener s_touchListener;
     static const struct wl_seat_listener s_seatListener;
     static const struct wl_callback_listener s_frameListener;
     static const struct zxdg_surface_v6_listener s_xdgSurfaceListener;
@@ -72,6 +73,12 @@
         } keyboard;
 
         struct {
+            struct wl_touch* object { nullptr };
+            struct wpe_input_touch_event_raw points[10];
+            bool tracking { false };
+        } touch;
+
+        struct {
             struct xkb_context* context { nullptr };
             struct xkb_keymap* keymap { nullptr };
             struct xkb_state* state { nullptr };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to