diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-11-14 12:14:04 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-11-14 12:14:04 +0100 |
| commit | 19e40058dab55e2525fb2389823f04a788d074d3 (patch) | |
| tree | d8e0212b14b9ef5bd47da538f4585843f62f6bab | |
| parent | 52f6b6abbb9c5438efba270f8dfff6d2759a0f89 (diff) | |
Libdecor-gtk and GTK Shell: take care of touch events
| -rw-r--r-- | libdecor/build/fl_libdecor-plugins.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/libdecor/build/fl_libdecor-plugins.c b/libdecor/build/fl_libdecor-plugins.c index 0f7e2fe34..a5adbbbc2 100644 --- a/libdecor/build/fl_libdecor-plugins.c +++ b/libdecor/build/fl_libdecor-plugins.c @@ -382,6 +382,41 @@ static void fltk_pointer_button(void *data, } +// libdecor's touch_down member of wl_touch_listener objects +void (*decor_touch_down)(void *data, struct wl_touch *wl_touch, uint32_t serial, + uint32_t time, struct wl_surface *surface, int32_t id, + wl_fixed_t x, wl_fixed_t y); + + +// FLTK's replacement for touch_down member of wl_touch_listener objects +static void fltk_touch_down(void *data, struct wl_touch *wl_touch, uint32_t serial, + uint32_t time, struct wl_surface *surface, int32_t id, wl_fixed_t x, wl_fixed_t y) +{ + struct seat *seat = data; + struct libdecor_frame_gtk *frame_gtk; + if (!surface || !own_surface(surface)) return; + frame_gtk = wl_surface_get_user_data(surface); + if (!frame_gtk) return; + seat->touch_focus = surface; + frame_gtk->touch_active = get_component_for_surface(frame_gtk, surface); + if (!frame_gtk->touch_active) return; + + if (frame_gtk->touch_active->type == HEADER && + frame_gtk->hdr_focus.type < HEADER_MIN && + time - seat->touch_down_time_stamp < + (uint32_t)frame_gtk->plugin_gtk->double_click_time_ms + ) { + struct gtk_surface1 *gtk_surface = gtk_shell1_get_gtk_surface( + gtk_shell, surface); + gtk_surface1_titlebar_gesture(gtk_surface, serial, seat->wl_seat, + GTK_SURFACE1_GESTURE_DOUBLE_CLICK); + gtk_surface1_release(gtk_surface); + } else { + decor_touch_down(data, wl_touch, serial, time, surface, id, x, y); + } +} + + struct wl_object { // copied from wayland-private.h const struct wl_interface *interface; const void *implementation; @@ -416,6 +451,23 @@ void use_FLTK_pointer_button(struct libdecor_frame *frame) { fltk_listener->button = fltk_pointer_button; // replace the pointer listener by a copy whose button member is FLTK's object->implementation = fltk_listener; + + object = (struct wl_object *)seat->wl_touch; + if (object) { + struct wl_touch_listener *decor_touch_listener = + (struct wl_touch_listener*)object->implementation; + struct wl_touch_listener *fltk_touch_listener = + (struct wl_touch_listener*)malloc(sizeof(struct wl_touch_listener)); + // initialize FLTK's touch listener with libdecor's values + *fltk_touch_listener = *decor_touch_listener; + // memorize libdecor's down cb + decor_touch_down = decor_touch_listener->down; + // replace libdecor's down by FLTK's + fltk_touch_listener->down = fltk_touch_down; + // replace the touch listener by a copy whose down member is FLTK's + object->implementation = fltk_touch_listener; + } + // get gnome's double_click_time_ms value doubleclick_time = lfg->plugin_gtk->double_click_time_ms; #endif // HAVE_GTK && !USE_SYSTEM_LIBDECOR |
