Commit 1bb3d17c authored by Sean O'Brien's avatar Sean O'Brien Committed by Commit Bot

Add and implement wayland protocol for pinch gestures

Extends the wl_pointer protocol using the wayland upstream
zwp_pointer_gestures protocol to pass information about pinch gestures.

BUG=b:25668308

Change-Id: I9f90ebebec3f8476181e0426401827a3cf1064e4
Reviewed-on: https://chromium-review.googlesource.com/699017
Commit-Queue: Sean O'Brien <seobrien@chromium.org>
Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506828}
parent bbb84a0f
......@@ -8,7 +8,7 @@
#include "ash/public/cpp/shell_window_ids.h"
#include "components/exo/pointer_delegate.h"
#include "components/exo/pointer_stylus_delegate.h"
#include "components/exo/pointer_gesture_pinch_delegate.h"
#include "components/exo/surface.h"
#include "components/exo/wm_helper.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
......@@ -96,6 +96,8 @@ Pointer::~Pointer() {
focus_surface_->RemoveSurfaceObserver(this);
focus_surface_->UnregisterCursorProvider(this);
}
if (pinch_delegate_)
pinch_delegate_->OnPointerDestroying(this);
auto* helper = WMHelper::GetInstance();
helper->RemoveDisplayConfigurationObserver(this);
helper->RemoveCursorObserver(this);
......@@ -151,6 +153,10 @@ gfx::NativeCursor Pointer::GetCursor() {
return cursor_;
}
void Pointer::SetGesturePinchDelegate(PointerGesturePinchDelegate* delegate) {
pinch_delegate_ = delegate;
}
////////////////////////////////////////////////////////////////////////////////
// SurfaceDelegate overrides:
......@@ -293,6 +299,36 @@ void Pointer::OnScrollEvent(ui::ScrollEvent* event) {
OnMouseEvent(event);
}
void Pointer::OnGestureEvent(ui::GestureEvent* event) {
// We don't want to handle gestures generated from touchscreen events,
// we handle touch events in touch.cc
if (event->details().device_type() != ui::GestureDeviceType::DEVICE_TOUCHPAD)
return;
if (!focus_surface_ || !pinch_delegate_)
return;
switch (event->type()) {
case ui::ET_GESTURE_PINCH_BEGIN:
pinch_delegate_->OnPointerPinchBegin(event->unique_touch_event_id(),
event->time_stamp(), focus_surface_);
delegate_->OnPointerFrame();
break;
case ui::ET_GESTURE_PINCH_UPDATE:
pinch_delegate_->OnPointerPinchUpdate(event->time_stamp(),
event->details().scale());
delegate_->OnPointerFrame();
break;
case ui::ET_GESTURE_PINCH_END:
pinch_delegate_->OnPointerPinchEnd(event->unique_touch_event_id(),
event->time_stamp());
delegate_->OnPointerFrame();
break;
default:
break;
}
}
////////////////////////////////////////////////////////////////////////////////
// WMHelper::CursorObserver overrides:
......
......@@ -32,6 +32,7 @@ class MouseEvent;
namespace exo {
class PointerDelegate;
class PointerGesturePinchDelegate;
class Surface;
class SurfaceTreeHost;
......@@ -53,6 +54,9 @@ class Pointer : public SurfaceTreeHost,
// pointer location, in surface local coordinates.
void SetCursor(Surface* surface, const gfx::Point& hotspot);
// Set delegate for pinch events.
void SetGesturePinchDelegate(PointerGesturePinchDelegate* delegate);
// Returns the current cursor for the pointer.
gfx::NativeCursor GetCursor();
......@@ -65,6 +69,7 @@ class Pointer : public SurfaceTreeHost,
// Overridden from ui::EventHandler:
void OnMouseEvent(ui::MouseEvent* event) override;
void OnScrollEvent(ui::ScrollEvent* event) override;
void OnGestureEvent(ui::GestureEvent* event) override;
// Overridden from WMHelper::CursorObserver:
void OnCursorSizeChanged(ui::CursorSize cursor_size) override;
......@@ -95,6 +100,9 @@ class Pointer : public SurfaceTreeHost,
// The delegate instance that all events are dispatched to.
PointerDelegate* const delegate_;
// The delegate instance that all pinch related events are dispatched to.
PointerGesturePinchDelegate* pinch_delegate_ = nullptr;
// The current focus surface for the pointer.
Surface* focus_surface_ = nullptr;
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_EXO_POINTER_GESTURE_PINCH_DELEGATE_H_
#define COMPONENTS_EXO_POINTER_GESTURE_PINCH_DELEGATE_H_
#include "base/time/time.h"
namespace exo {
class Pointer;
// Handles pinch event details on pointers. Used as an extension to the
// PointerDelegate.
class PointerGesturePinchDelegate {
public:
// Called at the top of the pointer's destructor, to give observers a
// chance to remove themselves.
virtual void OnPointerDestroying(Pointer* pointer) = 0;
virtual void OnPointerPinchBegin(uint32_t unique_touch_event_id,
base::TimeTicks time_stamp,
Surface* surface) = 0;
virtual void OnPointerPinchUpdate(base::TimeTicks time_stamp,
float scale) = 0;
virtual void OnPointerPinchEnd(uint32_t unique_touch_event_id,
base::TimeTicks time_stamp) = 0;
protected:
virtual ~PointerGesturePinchDelegate() {}
};
} // namespace exo
#endif // COMPONENTS_EXO_POINTER_GESTURE_PINCH_DELEGATE_H_
......@@ -64,6 +64,7 @@ source_set("wayland") {
"//third_party/wayland-protocols:gaming_input_protocol",
"//third_party/wayland-protocols:keyboard_configuration_protocol",
"//third_party/wayland-protocols:keyboard_extension_protocol",
"//third_party/wayland-protocols:pointer_gestures_protocol",
"//third_party/wayland-protocols:presentation_time_protocol",
"//third_party/wayland-protocols:remote_shell_protocol",
"//third_party/wayland-protocols:secure_output_protocol",
......
......@@ -12,6 +12,7 @@
#include <keyboard-configuration-unstable-v1-server-protocol.h>
#include <keyboard-extension-unstable-v1-server-protocol.h>
#include <linux/input.h>
#include <pointer-gestures-unstable-v1-server-protocol.h>
#include <presentation-time-server-protocol.h>
#include <remote-shell-unstable-v1-server-protocol.h>
#include <secure-output-unstable-v1-server-protocol.h>
......@@ -71,6 +72,7 @@
#include "components/exo/notification_surface_manager.h"
#include "components/exo/pointer.h"
#include "components/exo/pointer_delegate.h"
#include "components/exo/pointer_gesture_pinch_delegate.h"
#include "components/exo/shared_memory.h"
#include "components/exo/shell_surface.h"
#include "components/exo/sub_surface.h"
......@@ -4093,6 +4095,95 @@ void bind_stylus_v2(wl_client* client,
nullptr);
}
////////////////////////////////////////////////////////////////////////////////
// pointer_gesture_swipe_v1 interface:
void pointer_gestures_get_swipe_gesture(wl_client* client,
wl_resource* resource,
uint32_t id,
wl_resource* pointer_resource) {
NOTIMPLEMENTED();
}
////////////////////////////////////////////////////////////////////////////////
// pointer_gesture_pinch_v1 interface:
class WaylandPointerGesturePinchDelegate : public PointerGesturePinchDelegate {
public:
WaylandPointerGesturePinchDelegate(wl_resource* resource, Pointer* pointer)
: resource_(resource), pointer_(pointer) {
pointer_->SetGesturePinchDelegate(this);
}
~WaylandPointerGesturePinchDelegate() override {
if (pointer_)
pointer_->SetGesturePinchDelegate(nullptr);
}
void OnPointerDestroying(Pointer* pointer) override { pointer_ = nullptr; }
void OnPointerPinchBegin(uint32_t unique_touch_event_id,
base::TimeTicks time_stamp,
Surface* surface) override {
wl_resource* surface_resource = GetSurfaceResource(surface);
DCHECK(surface_resource);
zwp_pointer_gesture_pinch_v1_send_begin(resource_, unique_touch_event_id,
TimeTicksToMilliseconds(time_stamp),
surface_resource, 2);
}
void OnPointerPinchUpdate(base::TimeTicks time_stamp, float scale) override {
zwp_pointer_gesture_pinch_v1_send_update(
resource_, TimeTicksToMilliseconds(time_stamp), 0, 0,
wl_fixed_from_double(scale), 0);
}
void OnPointerPinchEnd(uint32_t unique_touch_event_id,
base::TimeTicks time_stamp) override {
zwp_pointer_gesture_pinch_v1_send_end(resource_, unique_touch_event_id,
TimeTicksToMilliseconds(time_stamp),
0);
}
private:
wl_resource* const resource_;
Pointer* pointer_;
DISALLOW_COPY_AND_ASSIGN(WaylandPointerGesturePinchDelegate);
};
void pointer_gesture_pinch_destroy(wl_client* client, wl_resource* resource) {
wl_resource_destroy(resource);
}
const struct zwp_pointer_gesture_pinch_v1_interface
pointer_gesture_pinch_implementation = {pointer_gesture_pinch_destroy};
void pointer_gestures_get_pinch_gesture(wl_client* client,
wl_resource* resource,
uint32_t id,
wl_resource* pointer_resource) {
Pointer* pointer = GetUserDataAs<Pointer>(pointer_resource);
wl_resource* pointer_gesture_pinch_resource = wl_resource_create(
client, &zwp_pointer_gesture_pinch_v1_interface, 1, id);
SetImplementation(pointer_gesture_pinch_resource,
&pointer_gesture_pinch_implementation,
base::MakeUnique<WaylandPointerGesturePinchDelegate>(
pointer_gesture_pinch_resource, pointer));
}
////////////////////////////////////////////////////////////////////////////////
// pointer_gestures_v1 interface:
const struct zwp_pointer_gestures_v1_interface pointer_gestures_implementation =
{pointer_gestures_get_swipe_gesture, pointer_gestures_get_pinch_gesture};
void bind_pointer_gestures(wl_client* client,
void* data,
uint32_t version,
uint32_t id) {
wl_resource* resource = wl_resource_create(
client, &zwp_pointer_gestures_v1_interface, version, id);
wl_resource_set_implementation(resource, &pointer_gestures_implementation,
data, nullptr);
}
////////////////////////////////////////////////////////////////////////////////
// pointer_stylus interface (deprecated)
// TODO(denniskempin): Remove once client no longer depends on this interface.
......@@ -4440,6 +4531,8 @@ Server::Server(Display* display)
bind_stylus_v1_DEPRECATED);
wl_global_create(wl_display_.get(), &zcr_stylus_v2_interface, 1, display_,
bind_stylus_v2);
wl_global_create(wl_display_.get(), &zwp_pointer_gestures_v1_interface, 1,
display_, bind_pointer_gestures);
wl_global_create(wl_display_.get(), &zcr_keyboard_configuration_v1_interface,
2, display_, bind_keyboard_configuration);
wl_global_create(wl_display_.get(), &zcr_stylus_tools_v1_interface, 1,
......
......@@ -221,6 +221,27 @@ source_set("stylus_protocol") {
public_configs = [ ":stylus_protocol_config" ]
}
config("pointer_gestures_protocol_config") {
include_dirs = [ "include/protocol" ]
}
source_set("pointer_gestures_protocol") {
sources = [
"include/protocol/pointer-gestures-unstable-v1-client-protocol.h",
"include/protocol/pointer-gestures-unstable-v1-server-protocol.h",
"protocol/pointer-gestures-v1-protocol.c",
]
deps = [
"//third_party/wayland:wayland_util",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_configs = [ ":pointer_gestures_protocol_config" ]
}
config("keyboard_configuration_protocol_config") {
include_dirs = [ "include/protocol" ]
}
......
......@@ -64,4 +64,6 @@ To import a new snapshot of wayland-protocols:
wayland-scanner code < unstable/keyboard/keyboard-extension-unstable-v1.xml > protocol/keyboard-extension-protocol.c
wayland-scanner server-header < unstable/keyboard/keyboard-extension-unstable-v1.xml > include/protocol/keyboard-extension-unstable-v1-server-protocol.h
wayland-scanner client-header < unstable/keyboard/keyboard-extension-unstable-v1.xml > include/protocol/keyboard-extension-unstable-v1-client-protocol.h
wayland-scanner client-header < src/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml > include/protocol/pointer-gestures-unstable-v1-client-protocol.h
wayland-scanner server-header < src/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml > include/protocol/pointer-gestures-unstable-v1-server-protocol.h
- Update this README to reflect the new version number.
#ifndef POINTER_GESTURES_UNSTABLE_V1_CLIENT_PROTOCOL_H
#define POINTER_GESTURES_UNSTABLE_V1_CLIENT_PROTOCOL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "wayland-client.h"
struct wl_client;
struct wl_resource;
struct zwp_pointer_gestures_v1;
struct zwp_pointer_gesture_swipe_v1;
struct zwp_pointer_gesture_pinch_v1;
extern const struct wl_interface zwp_pointer_gestures_v1_interface;
extern const struct wl_interface zwp_pointer_gesture_swipe_v1_interface;
extern const struct wl_interface zwp_pointer_gesture_pinch_v1_interface;
#define ZWP_POINTER_GESTURES_V1_GET_SWIPE_GESTURE 0
#define ZWP_POINTER_GESTURES_V1_GET_PINCH_GESTURE 1
static inline void
zwp_pointer_gestures_v1_set_user_data(struct zwp_pointer_gestures_v1 *zwp_pointer_gestures_v1, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zwp_pointer_gestures_v1, user_data);
}
static inline void *
zwp_pointer_gestures_v1_get_user_data(struct zwp_pointer_gestures_v1 *zwp_pointer_gestures_v1)
{
return wl_proxy_get_user_data((struct wl_proxy *) zwp_pointer_gestures_v1);
}
static inline void
zwp_pointer_gestures_v1_destroy(struct zwp_pointer_gestures_v1 *zwp_pointer_gestures_v1)
{
wl_proxy_destroy((struct wl_proxy *) zwp_pointer_gestures_v1);
}
static inline struct zwp_pointer_gesture_swipe_v1 *
zwp_pointer_gestures_v1_get_swipe_gesture(struct zwp_pointer_gestures_v1 *zwp_pointer_gestures_v1, struct wl_pointer *pointer)
{
struct wl_proxy *id;
id = wl_proxy_marshal_constructor((struct wl_proxy *) zwp_pointer_gestures_v1,
ZWP_POINTER_GESTURES_V1_GET_SWIPE_GESTURE, &zwp_pointer_gesture_swipe_v1_interface, NULL, pointer);
return (struct zwp_pointer_gesture_swipe_v1 *) id;
}
static inline struct zwp_pointer_gesture_pinch_v1 *
zwp_pointer_gestures_v1_get_pinch_gesture(struct zwp_pointer_gestures_v1 *zwp_pointer_gestures_v1, struct wl_pointer *pointer)
{
struct wl_proxy *id;
id = wl_proxy_marshal_constructor((struct wl_proxy *) zwp_pointer_gestures_v1,
ZWP_POINTER_GESTURES_V1_GET_PINCH_GESTURE, &zwp_pointer_gesture_pinch_v1_interface, NULL, pointer);
return (struct zwp_pointer_gesture_pinch_v1 *) id;
}
/**
* zwp_pointer_gesture_swipe_v1 - a swipe gesture object
* @begin: multi-finger swipe begin
* @update: multi-finger swipe motion
* @end: multi-finger swipe end
*
* A swipe gesture object notifies a client about a multi-finger swipe
* gesture detected on an indirect input device such as a touchpad. The
* gesture is usually initiated by multiple fingers moving in the same
* direction but once initiated the direction may change. The precise
* conditions of when such a gesture is detected are
* implementation-dependent.
*
* A gesture consists of three stages: begin, update (optional) and end.
* There cannot be multiple simultaneous pinch or swipe gestures on a same
* pointer/seat, how compositors prevent these situations is
* implementation-dependent.
*
* A gesture may be cancelled by the compositor or the hardware. Clients
* should not consider performing permanent or irreversible actions until
* the end of a gesture has been received.
*/
struct zwp_pointer_gesture_swipe_v1_listener {
/**
* begin - multi-finger swipe begin
* @serial: (none)
* @time: timestamp with millisecond granularity
* @surface: (none)
* @fingers: number of fingers
*
* This event is sent when a multi-finger swipe gesture is
* detected on the device.
*/
void (*begin)(void *data,
struct zwp_pointer_gesture_swipe_v1 *zwp_pointer_gesture_swipe_v1,
uint32_t serial,
uint32_t time,
struct wl_surface *surface,
uint32_t fingers);
/**
* update - multi-finger swipe motion
* @time: timestamp with millisecond granularity
* @dx: delta x coordinate in surface coordinate space
* @dy: delta y coordinate in surface coordinate space
*
* This event is sent when a multi-finger swipe gesture changes
* the position of the logical center.
*
* The dx and dy coordinates are relative coordinates of the
* logical center of the gesture compared to the previous event.
*/
void (*update)(void *data,
struct zwp_pointer_gesture_swipe_v1 *zwp_pointer_gesture_swipe_v1,
uint32_t time,
wl_fixed_t dx,
wl_fixed_t dy);
/**
* end - multi-finger swipe end
* @serial: (none)
* @time: timestamp with millisecond granularity
* @cancelled: 1 if the gesture was cancelled, 0 otherwise
*
* This event is sent when a multi-finger swipe gesture ceases to
* be valid. This may happen when one or more fingers are lifted or
* the gesture is cancelled.
*
* When a gesture is cancelled, the client should undo state
* changes caused by this gesture. What causes a gesture to be
* cancelled is implementation-dependent.
*/
void (*end)(void *data,
struct zwp_pointer_gesture_swipe_v1 *zwp_pointer_gesture_swipe_v1,
uint32_t serial,
uint32_t time,
int32_t cancelled);
};
static inline int
zwp_pointer_gesture_swipe_v1_add_listener(struct zwp_pointer_gesture_swipe_v1 *zwp_pointer_gesture_swipe_v1,
const struct zwp_pointer_gesture_swipe_v1_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) zwp_pointer_gesture_swipe_v1,
(void (**)(void)) listener, data);
}
#define ZWP_POINTER_GESTURE_SWIPE_V1_DESTROY 0
static inline void
zwp_pointer_gesture_swipe_v1_set_user_data(struct zwp_pointer_gesture_swipe_v1 *zwp_pointer_gesture_swipe_v1, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zwp_pointer_gesture_swipe_v1, user_data);
}
static inline void *
zwp_pointer_gesture_swipe_v1_get_user_data(struct zwp_pointer_gesture_swipe_v1 *zwp_pointer_gesture_swipe_v1)
{
return wl_proxy_get_user_data((struct wl_proxy *) zwp_pointer_gesture_swipe_v1);
}
static inline void
zwp_pointer_gesture_swipe_v1_destroy(struct zwp_pointer_gesture_swipe_v1 *zwp_pointer_gesture_swipe_v1)
{
wl_proxy_marshal((struct wl_proxy *) zwp_pointer_gesture_swipe_v1,
ZWP_POINTER_GESTURE_SWIPE_V1_DESTROY);
wl_proxy_destroy((struct wl_proxy *) zwp_pointer_gesture_swipe_v1);
}
/**
* zwp_pointer_gesture_pinch_v1 - a pinch gesture object
* @begin: multi-finger pinch begin
* @update: multi-finger pinch motion
* @end: multi-finger pinch end
*
* A pinch gesture object notifies a client about a multi-finger pinch
* gesture detected on an indirect input device such as a touchpad. The
* gesture is usually initiated by multiple fingers moving towards each
* other or away from each other, or by two or more fingers rotating around
* a logical center of gravity. The precise conditions of when such a
* gesture is detected are implementation-dependent.
*
* A gesture consists of three stages: begin, update (optional) and end.
* There cannot be multiple simultaneous pinch or swipe gestures on a same
* pointer/seat, how compositors prevent these situations is
* implementation-dependent.
*
* A gesture may be cancelled by the compositor or the hardware. Clients
* should not consider performing permanent or irreversible actions until
* the end of a gesture has been received.
*/
struct zwp_pointer_gesture_pinch_v1_listener {
/**
* begin - multi-finger pinch begin
* @serial: (none)
* @time: timestamp with millisecond granularity
* @surface: (none)
* @fingers: number of fingers
*
* This event is sent when a multi-finger pinch gesture is
* detected on the device.
*/
void (*begin)(void *data,
struct zwp_pointer_gesture_pinch_v1 *zwp_pointer_gesture_pinch_v1,
uint32_t serial,
uint32_t time,
struct wl_surface *surface,
uint32_t fingers);
/**
* update - multi-finger pinch motion
* @time: timestamp with millisecond granularity
* @dx: delta x coordinate in surface coordinate space
* @dy: delta y coordinate in surface coordinate space
* @scale: scale relative to the initial finger position
* @rotation: angle in degrees cw relative to the previous event
*
* This event is sent when a multi-finger pinch gesture changes
* the position of the logical center, the rotation or the relative
* scale.
*
* The dx and dy coordinates are relative coordinates in the
* surface coordinate space of the logical center of the gesture.
*
* The scale factor is an absolute scale compared to the
* pointer_gesture_pinch.begin event, e.g. a scale of 2 means the
* fingers are now twice as far apart as on
* pointer_gesture_pinch.begin.
*
* The rotation is the relative angle in degrees clockwise compared
* to the previous pointer_gesture_pinch.begin or
* pointer_gesture_pinch.update event.
*/
void (*update)(void *data,
struct zwp_pointer_gesture_pinch_v1 *zwp_pointer_gesture_pinch_v1,
uint32_t time,
wl_fixed_t dx,
wl_fixed_t dy,
wl_fixed_t scale,
wl_fixed_t rotation);
/**
* end - multi-finger pinch end
* @serial: (none)
* @time: timestamp with millisecond granularity
* @cancelled: 1 if the gesture was cancelled, 0 otherwise
*
* This event is sent when a multi-finger pinch gesture ceases to
* be valid. This may happen when one or more fingers are lifted or
* the gesture is cancelled.
*
* When a gesture is cancelled, the client should undo state
* changes caused by this gesture. What causes a gesture to be
* cancelled is implementation-dependent.
*/
void (*end)(void *data,
struct zwp_pointer_gesture_pinch_v1 *zwp_pointer_gesture_pinch_v1,
uint32_t serial,
uint32_t time,
int32_t cancelled);
};
static inline int
zwp_pointer_gesture_pinch_v1_add_listener(struct zwp_pointer_gesture_pinch_v1 *zwp_pointer_gesture_pinch_v1,
const struct zwp_pointer_gesture_pinch_v1_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) zwp_pointer_gesture_pinch_v1,
(void (**)(void)) listener, data);
}
#define ZWP_POINTER_GESTURE_PINCH_V1_DESTROY 0
static inline void
zwp_pointer_gesture_pinch_v1_set_user_data(struct zwp_pointer_gesture_pinch_v1 *zwp_pointer_gesture_pinch_v1, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zwp_pointer_gesture_pinch_v1, user_data);
}
static inline void *
zwp_pointer_gesture_pinch_v1_get_user_data(struct zwp_pointer_gesture_pinch_v1 *zwp_pointer_gesture_pinch_v1)
{
return wl_proxy_get_user_data((struct wl_proxy *) zwp_pointer_gesture_pinch_v1);
}
static inline void
zwp_pointer_gesture_pinch_v1_destroy(struct zwp_pointer_gesture_pinch_v1 *zwp_pointer_gesture_pinch_v1)
{
wl_proxy_marshal((struct wl_proxy *) zwp_pointer_gesture_pinch_v1,
ZWP_POINTER_GESTURE_PINCH_V1_DESTROY);
wl_proxy_destroy((struct wl_proxy *) zwp_pointer_gesture_pinch_v1);
}
#ifdef __cplusplus
}
#endif
#endif
#ifndef POINTER_GESTURES_UNSTABLE_V1_SERVER_PROTOCOL_H
#define POINTER_GESTURES_UNSTABLE_V1_SERVER_PROTOCOL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "wayland-util.h"
struct wl_client;
struct wl_resource;
struct zwp_pointer_gestures_v1;
struct zwp_pointer_gesture_swipe_v1;
struct zwp_pointer_gesture_pinch_v1;
extern const struct wl_interface zwp_pointer_gestures_v1_interface;
extern const struct wl_interface zwp_pointer_gesture_swipe_v1_interface;
extern const struct wl_interface zwp_pointer_gesture_pinch_v1_interface;
/**
* zwp_pointer_gestures_v1 - touchpad gestures
* @get_swipe_gesture: get swipe gesture
* @get_pinch_gesture: get pinch gesture
*
* A global interface to provide semantic touchpad gestures for a given
* pointer.
*
* Two gestures are currently supported: swipe and zoom/rotate. All
* gestures follow a three-stage cycle: begin, update, end and are
* identified by a unique id.
*
* Warning! The protocol described in this file is experimental and
* backward incompatible changes may be made. Backward compatible changes
* may be added together with the corresponding interface version bump.
* Backward incompatible changes are done by bumping the version number in
* the protocol and interface names and resetting the interface version.
* Once the protocol is to be declared stable, the 'z' prefix and the
* version number in the protocol and interface names are removed and the
* interface version number is reset.
*/
struct zwp_pointer_gestures_v1_interface {
/**
* get_swipe_gesture - get swipe gesture
* @id: (none)
* @pointer: (none)
*
* Create a swipe gesture object. See the
* wl_pointer_gesture_swipe interface for details.
*/
void (*get_swipe_gesture)(struct wl_client *client,
struct wl_resource *resource,
uint32_t id,
struct wl_resource *pointer);
/**
* get_pinch_gesture - get pinch gesture
* @id: (none)
* @pointer: (none)
*
* Create a pinch gesture object. See the
* wl_pointer_gesture_pinch interface for details.
*/
void (*get_pinch_gesture)(struct wl_client *client,
struct wl_resource *resource,
uint32_t id,
struct wl_resource *pointer);
};
/**
* zwp_pointer_gesture_swipe_v1 - a swipe gesture object
* @destroy: destroy the pointer swipe gesture object
*
* A swipe gesture object notifies a client about a multi-finger swipe
* gesture detected on an indirect input device such as a touchpad. The
* gesture is usually initiated by multiple fingers moving in the same
* direction but once initiated the direction may change. The precise
* conditions of when such a gesture is detected are
* implementation-dependent.
*
* A gesture consists of three stages: begin, update (optional) and end.
* There cannot be multiple simultaneous pinch or swipe gestures on a same
* pointer/seat, how compositors prevent these situations is
* implementation-dependent.
*
* A gesture may be cancelled by the compositor or the hardware. Clients
* should not consider performing permanent or irreversible actions until
* the end of a gesture has been received.
*/
struct zwp_pointer_gesture_swipe_v1_interface {
/**
* destroy - destroy the pointer swipe gesture object
*
*
*/
void (*destroy)(struct wl_client *client,
struct wl_resource *resource);
};
#define ZWP_POINTER_GESTURE_SWIPE_V1_BEGIN 0
#define ZWP_POINTER_GESTURE_SWIPE_V1_UPDATE 1
#define ZWP_POINTER_GESTURE_SWIPE_V1_END 2
static inline void
zwp_pointer_gesture_swipe_v1_send_begin(struct wl_resource *resource_, uint32_t serial, uint32_t time, struct wl_resource *surface, uint32_t fingers)
{
wl_resource_post_event(resource_, ZWP_POINTER_GESTURE_SWIPE_V1_BEGIN, serial, time, surface, fingers);
}
static inline void
zwp_pointer_gesture_swipe_v1_send_update(struct wl_resource *resource_, uint32_t time, wl_fixed_t dx, wl_fixed_t dy)
{
wl_resource_post_event(resource_, ZWP_POINTER_GESTURE_SWIPE_V1_UPDATE, time, dx, dy);
}
static inline void
zwp_pointer_gesture_swipe_v1_send_end(struct wl_resource *resource_, uint32_t serial, uint32_t time, int32_t cancelled)
{
wl_resource_post_event(resource_, ZWP_POINTER_GESTURE_SWIPE_V1_END, serial, time, cancelled);
}
/**
* zwp_pointer_gesture_pinch_v1 - a pinch gesture object
* @destroy: destroy the pinch gesture object
*
* A pinch gesture object notifies a client about a multi-finger pinch
* gesture detected on an indirect input device such as a touchpad. The
* gesture is usually initiated by multiple fingers moving towards each
* other or away from each other, or by two or more fingers rotating around
* a logical center of gravity. The precise conditions of when such a
* gesture is detected are implementation-dependent.
*
* A gesture consists of three stages: begin, update (optional) and end.
* There cannot be multiple simultaneous pinch or swipe gestures on a same
* pointer/seat, how compositors prevent these situations is
* implementation-dependent.
*
* A gesture may be cancelled by the compositor or the hardware. Clients
* should not consider performing permanent or irreversible actions until
* the end of a gesture has been received.
*/
struct zwp_pointer_gesture_pinch_v1_interface {
/**
* destroy - destroy the pinch gesture object
*
*
*/
void (*destroy)(struct wl_client *client,
struct wl_resource *resource);
};
#define ZWP_POINTER_GESTURE_PINCH_V1_BEGIN 0
#define ZWP_POINTER_GESTURE_PINCH_V1_UPDATE 1
#define ZWP_POINTER_GESTURE_PINCH_V1_END 2
static inline void
zwp_pointer_gesture_pinch_v1_send_begin(struct wl_resource *resource_, uint32_t serial, uint32_t time, struct wl_resource *surface, uint32_t fingers)
{
wl_resource_post_event(resource_, ZWP_POINTER_GESTURE_PINCH_V1_BEGIN, serial, time, surface, fingers);
}
static inline void
zwp_pointer_gesture_pinch_v1_send_update(struct wl_resource *resource_, uint32_t time, wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t scale, wl_fixed_t rotation)
{
wl_resource_post_event(resource_, ZWP_POINTER_GESTURE_PINCH_V1_UPDATE, time, dx, dy, scale, rotation);
}
static inline void
zwp_pointer_gesture_pinch_v1_send_end(struct wl_resource *resource_, uint32_t serial, uint32_t time, int32_t cancelled)
{
wl_resource_post_event(resource_, ZWP_POINTER_GESTURE_PINCH_V1_END, serial, time, cancelled);
}
#ifdef __cplusplus
}
#endif
#endif
#include <stdlib.h>
#include <stdint.h>
#include "wayland-util.h"
extern const struct wl_interface zwp_pointer_gesture_swipe_v1_interface;
extern const struct wl_interface wl_pointer_interface;
extern const struct wl_interface zwp_pointer_gesture_pinch_v1_interface;
extern const struct wl_interface wl_pointer_interface;
extern const struct wl_interface wl_surface_interface;
extern const struct wl_interface wl_surface_interface;
static const struct wl_interface *types[] = {
NULL,
NULL,
NULL,
NULL,
NULL,
&zwp_pointer_gesture_swipe_v1_interface,
&wl_pointer_interface,
&zwp_pointer_gesture_pinch_v1_interface,
&wl_pointer_interface,
NULL,
NULL,
&wl_surface_interface,
NULL,
NULL,
NULL,
&wl_surface_interface,
NULL,
};
static const struct wl_message zwp_pointer_gestures_v1_requests[] = {
{ "get_swipe_gesture", "no", types + 5 },
{ "get_pinch_gesture", "no", types + 7 },
};
WL_EXPORT const struct wl_interface zwp_pointer_gestures_v1_interface = {
"zwp_pointer_gestures_v1", 1,
2, zwp_pointer_gestures_v1_requests,
0, NULL,
};
static const struct wl_message zwp_pointer_gesture_swipe_v1_requests[] = {
{ "destroy", "", types + 0 },
};
static const struct wl_message zwp_pointer_gesture_swipe_v1_events[] = {
{ "begin", "uuou", types + 9 },
{ "update", "uff", types + 0 },
{ "end", "uui", types + 0 },
};
WL_EXPORT const struct wl_interface zwp_pointer_gesture_swipe_v1_interface = {
"zwp_pointer_gesture_swipe_v1", 1,
1, zwp_pointer_gesture_swipe_v1_requests,
3, zwp_pointer_gesture_swipe_v1_events,
};
static const struct wl_message zwp_pointer_gesture_pinch_v1_requests[] = {
{ "destroy", "", types + 0 },
};
static const struct wl_message zwp_pointer_gesture_pinch_v1_events[] = {
{ "begin", "uuou", types + 13 },
{ "update", "uffff", types + 0 },
{ "end", "uui", types + 0 },
};
WL_EXPORT const struct wl_interface zwp_pointer_gesture_pinch_v1_interface = {
"zwp_pointer_gesture_pinch_v1", 1,
1, zwp_pointer_gesture_pinch_v1_requests,
3, zwp_pointer_gesture_pinch_v1_events,
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment