Bug 1915596 [Wayland] Get touchpad hold event directly from Wayland display r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D220551
This commit is contained in:
Martin Stransky 2024-09-06 09:16:28 +00:00
Родитель 6fb8a35bcb
Коммит a108f647bd
11 изменённых файлов: 1456 добавлений и 102 удалений

Просмотреть файл

@ -305,7 +305,7 @@ static const struct xdg_activation_token_v1_listener token_listener = {
RefPtr<FocusRequestPromise> RequestWaylandFocusPromise() {
#ifdef MOZ_WAYLAND
if (!GdkIsWaylandDisplay() || !KeymapWrapper::GetSeat()) {
if (!GdkIsWaylandDisplay() || !WaylandDisplayGet()->GetSeat()) {
LOGW("RequestWaylandFocusPromise() failed.");
return nullptr;
}
@ -349,7 +349,7 @@ RefPtr<FocusRequestPromise> RequestWaylandFocusPromise() {
aXdgToken, &token_listener,
new XDGTokenRequest(aXdgToken, transferPromise));
xdg_activation_token_v1_set_serial(aXdgToken, focusSerial,
KeymapWrapper::GetSeat());
WaylandDisplayGet()->GetSeat());
xdg_activation_token_v1_set_surface(aXdgToken, focusSurface);
xdg_activation_token_v1_commit(aXdgToken);

Просмотреть файл

@ -31,10 +31,18 @@ MOZ_EXPORT struct wl_proxy* wl_proxy_marshal_constructor(
MOZ_EXPORT struct wl_proxy* wl_proxy_marshal_constructor_versioned(
struct wl_proxy* proxy, uint32_t opcode,
const struct wl_interface* interface, uint32_t version, ...);
MOZ_EXPORT struct wl_proxy* wl_proxy_marshal_flags(
struct wl_proxy* proxy, uint32_t opcode,
const struct wl_interface* interface, uint32_t version, uint32_t flags,
...);
MOZ_EXPORT void wl_proxy_destroy(struct wl_proxy* proxy);
MOZ_EXPORT void* wl_proxy_create_wrapper(void* proxy);
MOZ_EXPORT void wl_proxy_wrapper_destroy(void* proxy_wrapper);
#ifndef WL_MARSHAL_FLAG_DESTROY
# define WL_MARSHAL_FLAG_DESTROY (1 << 0)
#endif
/* We need implement some missing functions from wayland-client-protocol.h
*/
#ifndef WL_DATA_DEVICE_MANAGER_DND_ACTION_ENUM
@ -127,6 +135,403 @@ static inline void wl_surface_damage_buffer(struct wl_surface* wl_surface,
}
#endif
#ifndef WL_POINTER_AXIS_ENUM
# define WL_POINTER_AXIS_ENUM
/**
* @ingroup iface_wl_pointer
* axis types
*
* Describes the axis types of scroll events.
*/
enum wl_pointer_axis {
/**
* vertical axis
*/
WL_POINTER_AXIS_VERTICAL_SCROLL = 0,
/**
* horizontal axis
*/
WL_POINTER_AXIS_HORIZONTAL_SCROLL = 1,
};
#endif /* WL_POINTER_AXIS_ENUM */
#ifndef WL_POINTER_AXIS_SOURCE_ENUM
# define WL_POINTER_AXIS_SOURCE_ENUM
/**
* @ingroup iface_wl_pointer
* axis source types
*
* Describes the source types for axis events. This indicates to the
* client how an axis event was physically generated; a client may
* adjust the user interface accordingly. For example, scroll events
* from a "finger" source may be in a smooth coordinate space with
* kinetic scrolling whereas a "wheel" source may be in discrete steps
* of a number of lines.
*
* The "continuous" axis source is a device generating events in a
* continuous coordinate space, but using something other than a
* finger. One example for this source is button-based scrolling where
* the vertical motion of a device is converted to scroll events while
* a button is held down.
*
* The "wheel tilt" axis source indicates that the actual device is a
* wheel but the scroll event is not caused by a rotation but a
* (usually sideways) tilt of the wheel.
*/
enum wl_pointer_axis_source {
/**
* a physical wheel rotation
*/
WL_POINTER_AXIS_SOURCE_WHEEL = 0,
/**
* finger on a touch surface
*/
WL_POINTER_AXIS_SOURCE_FINGER = 1,
/**
* continuous coordinate space
*/
WL_POINTER_AXIS_SOURCE_CONTINUOUS = 2,
/**
* a physical wheel tilt
* @since 6
*/
WL_POINTER_AXIS_SOURCE_WHEEL_TILT = 3,
};
/**
* @ingroup iface_wl_pointer
*/
# define WL_POINTER_AXIS_SOURCE_WHEEL_TILT_SINCE_VERSION 6
#endif /* WL_POINTER_AXIS_SOURCE_ENUM */
#ifndef WL_POINTER_AXIS_RELATIVE_DIRECTION_ENUM
# define WL_POINTER_AXIS_RELATIVE_DIRECTION_ENUM
/**
* @ingroup iface_wl_pointer
* axis relative direction
*
* This specifies the direction of the physical motion that caused a
* wl_pointer.axis event, relative to the wl_pointer.axis direction.
*/
enum wl_pointer_axis_relative_direction {
/**
* physical motion matches axis direction
*/
WL_POINTER_AXIS_RELATIVE_DIRECTION_IDENTICAL = 0,
/**
* physical motion is the inverse of the axis direction
*/
WL_POINTER_AXIS_RELATIVE_DIRECTION_INVERTED = 1,
};
#endif /* WL_POINTER_AXIS_RELATIVE_DIRECTION_ENUM */
/**
* @ingroup iface_wl_pointer
* @struct wl_pointer_listener
*/
struct moz_wl_pointer_listener {
/**
* enter event
*
* Notification that this seat's pointer is focused on a certain
* surface.
*
* When a seat's focus enters a surface, the pointer image is
* undefined and a client should respond to this event by setting
* an appropriate pointer image with the set_cursor request.
* @param serial serial number of the enter event
* @param surface surface entered by the pointer
* @param surface_x surface-local x coordinate
* @param surface_y surface-local y coordinate
*/
void (*enter)(void* data, struct wl_pointer* wl_pointer, uint32_t serial,
struct wl_surface* surface, wl_fixed_t surface_x,
wl_fixed_t surface_y);
/**
* leave event
*
* Notification that this seat's pointer is no longer focused on
* a certain surface.
*
* The leave notification is sent before the enter notification for
* the new focus.
* @param serial serial number of the leave event
* @param surface surface left by the pointer
*/
void (*leave)(void* data, struct wl_pointer* wl_pointer, uint32_t serial,
struct wl_surface* surface);
/**
* pointer motion event
*
* Notification of pointer location change. The arguments
* surface_x and surface_y are the location relative to the focused
* surface.
* @param time timestamp with millisecond granularity
* @param surface_x surface-local x coordinate
* @param surface_y surface-local y coordinate
*/
void (*motion)(void* data, struct wl_pointer* wl_pointer, uint32_t time,
wl_fixed_t surface_x, wl_fixed_t surface_y);
/**
* pointer button event
*
* Mouse button click and release notifications.
*
* The location of the click is given by the last motion or enter
* event. The time argument is a timestamp with millisecond
* granularity, with an undefined base.
*
* The button is a button code as defined in the Linux kernel's
* linux/input-event-codes.h header file, e.g. BTN_LEFT.
*
* Any 16-bit button code value is reserved for future additions to
* the kernel's event code list. All other button codes above
* 0xFFFF are currently undefined but may be used in future
* versions of this protocol.
* @param serial serial number of the button event
* @param time timestamp with millisecond granularity
* @param button button that produced the event
* @param state physical state of the button
*/
void (*button)(void* data, struct wl_pointer* wl_pointer, uint32_t serial,
uint32_t time, uint32_t button, uint32_t state);
/**
* axis event
*
* Scroll and other axis notifications.
*
* For scroll events (vertical and horizontal scroll axes), the
* value parameter is the length of a vector along the specified
* axis in a coordinate space identical to those of motion events,
* representing a relative movement along the specified axis.
*
* For devices that support movements non-parallel to axes multiple
* axis events will be emitted.
*
* When applicable, for example for touch pads, the server can
* choose to emit scroll events where the motion vector is
* equivalent to a motion event vector.
*
* When applicable, a client can transform its content relative to
* the scroll distance.
* @param time timestamp with millisecond granularity
* @param axis axis type
* @param value length of vector in surface-local coordinate space
*/
void (*axis)(void* data, struct wl_pointer* wl_pointer, uint32_t time,
uint32_t axis, wl_fixed_t value);
/**
* end of a pointer event sequence
*
* Indicates the end of a set of events that logically belong
* together. A client is expected to accumulate the data in all
* events within the frame before proceeding.
*
* All wl_pointer events before a wl_pointer.frame event belong
* logically together. For example, in a diagonal scroll motion the
* compositor will send an optional wl_pointer.axis_source event,
* two wl_pointer.axis events (horizontal and vertical) and finally
* a wl_pointer.frame event. The client may use this information to
* calculate a diagonal vector for scrolling.
*
* When multiple wl_pointer.axis events occur within the same
* frame, the motion vector is the combined motion of all events.
* When a wl_pointer.axis and a wl_pointer.axis_stop event occur
* within the same frame, this indicates that axis movement in one
* axis has stopped but continues in the other axis. When multiple
* wl_pointer.axis_stop events occur within the same frame, this
* indicates that these axes stopped in the same instance.
*
* A wl_pointer.frame event is sent for every logical event group,
* even if the group only contains a single wl_pointer event.
* Specifically, a client may get a sequence: motion, frame,
* button, frame, axis, frame, axis_stop, frame.
*
* The wl_pointer.enter and wl_pointer.leave events are logical
* events generated by the compositor and not the hardware. These
* events are also grouped by a wl_pointer.frame. When a pointer
* moves from one surface to another, a compositor should group the
* wl_pointer.leave event within the same wl_pointer.frame.
* However, a client must not rely on wl_pointer.leave and
* wl_pointer.enter being in the same wl_pointer.frame.
* Compositor-specific policies may require the wl_pointer.leave
* and wl_pointer.enter event being split across multiple
* wl_pointer.frame groups.
* @since 5
*/
void (*frame)(void* data, struct wl_pointer* wl_pointer);
/**
* axis source event
*
* Source information for scroll and other axes.
*
* This event does not occur on its own. It is sent before a
* wl_pointer.frame event and carries the source information for
* all events within that frame.
*
* The source specifies how this event was generated. If the source
* is wl_pointer.axis_source.finger, a wl_pointer.axis_stop event
* will be sent when the user lifts the finger off the device.
*
* If the source is wl_pointer.axis_source.wheel,
* wl_pointer.axis_source.wheel_tilt or
* wl_pointer.axis_source.continuous, a wl_pointer.axis_stop event
* may or may not be sent. Whether a compositor sends an axis_stop
* event for these sources is hardware-specific and
* implementation-dependent; clients must not rely on receiving an
* axis_stop event for these scroll sources and should treat scroll
* sequences from these scroll sources as unterminated by default.
*
* This event is optional. If the source is unknown for a
* particular axis event sequence, no event is sent. Only one
* wl_pointer.axis_source event is permitted per frame.
*
* The order of wl_pointer.axis_discrete and wl_pointer.axis_source
* is not guaranteed.
* @param axis_source source of the axis event
* @since 5
*/
void (*axis_source)(void* data, struct wl_pointer* wl_pointer,
uint32_t axis_source);
/**
* axis stop event
*
* Stop notification for scroll and other axes.
*
* For some wl_pointer.axis_source types, a wl_pointer.axis_stop
* event is sent to notify a client that the axis sequence has
* terminated. This enables the client to implement kinetic
* scrolling. See the wl_pointer.axis_source documentation for
* information on when this event may be generated.
*
* Any wl_pointer.axis events with the same axis_source after this
* event should be considered as the start of a new axis motion.
*
* The timestamp is to be interpreted identical to the timestamp in
* the wl_pointer.axis event. The timestamp value may be the same
* as a preceding wl_pointer.axis event.
* @param time timestamp with millisecond granularity
* @param axis the axis stopped with this event
* @since 5
*/
void (*axis_stop)(void* data, struct wl_pointer* wl_pointer, uint32_t time,
uint32_t axis);
/**
* axis click event
*
* Discrete step information for scroll and other axes.
*
* This event carries the axis value of the wl_pointer.axis event
* in discrete steps (e.g. mouse wheel clicks).
*
* This event is deprecated with wl_pointer version 8 - this event
* is not sent to clients supporting version 8 or later.
*
* This event does not occur on its own, it is coupled with a
* wl_pointer.axis event that represents this axis value on a
* continuous scale. The protocol guarantees that each
* axis_discrete event is always followed by exactly one axis event
* with the same axis number within the same wl_pointer.frame. Note
* that the protocol allows for other events to occur between the
* axis_discrete and its coupled axis event, including other
* axis_discrete or axis events. A wl_pointer.frame must not
* contain more than one axis_discrete event per axis type.
*
* This event is optional; continuous scrolling devices like
* two-finger scrolling on touchpads do not have discrete steps and
* do not generate this event.
*
* The discrete value carries the directional information. e.g. a
* value of -2 is two steps towards the negative direction of this
* axis.
*
* The axis number is identical to the axis number in the
* associated axis event.
*
* The order of wl_pointer.axis_discrete and wl_pointer.axis_source
* is not guaranteed.
* @param axis axis type
* @param discrete number of steps
* @since 5
* @deprecated Deprecated since version 8
*/
void (*axis_discrete)(void* data, struct wl_pointer* wl_pointer,
uint32_t axis, int32_t discrete);
/**
* axis high-resolution scroll event
*
* Discrete high-resolution scroll information.
*
* This event carries high-resolution wheel scroll information,
* with each multiple of 120 representing one logical scroll step
* (a wheel detent). For example, an axis_value120 of 30 is one
* quarter of a logical scroll step in the positive direction, a
* value120 of -240 are two logical scroll steps in the negative
* direction within the same hardware event. Clients that rely on
* discrete scrolling should accumulate the value120 to multiples
* of 120 before processing the event.
*
* The value120 must not be zero.
*
* This event replaces the wl_pointer.axis_discrete event in
* clients supporting wl_pointer version 8 or later.
*
* Where a wl_pointer.axis_source event occurs in the same
* wl_pointer.frame, the axis source applies to this event.
*
* The order of wl_pointer.axis_value120 and wl_pointer.axis_source
* is not guaranteed.
* @param axis axis type
* @param value120 scroll distance as fraction of 120
* @since 8
*/
void (*axis_value120)(void* data, struct wl_pointer* wl_pointer,
uint32_t axis, int32_t value120);
/**
* axis relative physical direction event
*
* Relative directional information of the entity causing the
* axis motion.
*
* For a wl_pointer.axis event, the
* wl_pointer.axis_relative_direction event specifies the movement
* direction of the entity causing the wl_pointer.axis event. For
* example: - if a user's fingers on a touchpad move down and this
* causes a wl_pointer.axis vertical_scroll down event, the
* physical direction is 'identical' - if a user's fingers on a
* touchpad move down and this causes a wl_pointer.axis
* vertical_scroll up scroll up event ('natural scrolling'), the
* physical direction is 'inverted'.
*
* A client may use this information to adjust scroll motion of
* components. Specifically, enabling natural scrolling causes the
* content to change direction compared to traditional scrolling.
* Some widgets like volume control sliders should usually match
* the physical direction regardless of whether natural scrolling
* is active. This event enables clients to match the scroll
* direction of a widget to the physical direction.
*
* This event does not occur on its own, it is coupled with a
* wl_pointer.axis event that represents this axis value. The
* protocol guarantees that each axis_relative_direction event is
* always followed by exactly one axis event with the same axis
* number within the same wl_pointer.frame. Note that the protocol
* allows for other events to occur between the
* axis_relative_direction and its coupled axis event.
*
* The axis number is identical to the axis number in the
* associated axis event.
*
* The order of wl_pointer.axis_relative_direction,
* wl_pointer.axis_discrete and wl_pointer.axis_source is not
* guaranteed.
* @param axis axis type
* @param direction physical direction relative to axis motion
* @since 9
*/
void (*axis_relative_direction)(void* data, struct wl_pointer* wl_pointer,
uint32_t axis, uint32_t direction);
};
#ifdef __cplusplus
}
#endif

Просмотреть файл

@ -65,12 +65,6 @@ Time KeymapWrapper::sLastRepeatableKeyTime = 0;
KeymapWrapper::RepeatState KeymapWrapper::sRepeatState =
KeymapWrapper::NOT_PRESSED;
#ifdef MOZ_WAYLAND
wl_seat* KeymapWrapper::sSeat = nullptr;
int KeymapWrapper::sSeatID = -1;
wl_keyboard* KeymapWrapper::sKeyboard = nullptr;
#endif
static const char* GetBoolName(bool aBool) { return aBool ? "TRUE" : "FALSE"; }
static const char* GetStatusName(nsEventStatus aStatus) {
@ -690,8 +684,7 @@ void KeymapWrapper::SetModifierMasks(xkb_keymap* aKeymap) {
/* This keymap routine is derived from weston-2.0.0/clients/simple-im.c
*/
static void keyboard_handle_keymap(void* data, struct wl_keyboard* wl_keyboard,
uint32_t format, int fd, uint32_t size) {
void KeymapWrapper::HandleKeymap(uint32_t format, int fd, uint32_t size) {
KeymapWrapper::ResetKeyboard();
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
@ -724,50 +717,6 @@ static void keyboard_handle_keymap(void* data, struct wl_keyboard* wl_keyboard,
xkb_context_unref(xkb_context);
}
static void keyboard_handle_enter(void* data, struct wl_keyboard* keyboard,
uint32_t serial, struct wl_surface* surface,
struct wl_array* keys) {
KeymapWrapper::SetFocusIn(surface, serial);
}
static void keyboard_handle_leave(void* data, struct wl_keyboard* keyboard,
uint32_t serial, struct wl_surface* surface) {
KeymapWrapper::SetFocusOut(surface);
}
static void keyboard_handle_key(void* data, struct wl_keyboard* keyboard,
uint32_t serial, uint32_t time, uint32_t key,
uint32_t state) {}
static void keyboard_handle_modifiers(void* data, struct wl_keyboard* keyboard,
uint32_t serial, uint32_t mods_depressed,
uint32_t mods_latched,
uint32_t mods_locked, uint32_t group) {}
static void keyboard_handle_repeat_info(void* data,
struct wl_keyboard* keyboard,
int32_t rate, int32_t delay) {}
static const struct wl_keyboard_listener keyboard_listener = {
keyboard_handle_keymap, keyboard_handle_enter,
keyboard_handle_leave, keyboard_handle_key,
keyboard_handle_modifiers, keyboard_handle_repeat_info};
static void seat_handle_capabilities(void* data, struct wl_seat* seat,
unsigned int caps) {
wl_keyboard* keyboard = KeymapWrapper::GetKeyboard();
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !keyboard) {
keyboard = wl_seat_get_keyboard(seat);
wl_keyboard_add_listener(keyboard, &keyboard_listener, nullptr);
KeymapWrapper::SetKeyboard(keyboard);
} else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && keyboard) {
KeymapWrapper::ClearKeyboard();
}
}
static const struct wl_seat_listener seat_listener = {
seat_handle_capabilities,
};
#endif
KeymapWrapper::~KeymapWrapper() {
@ -2696,35 +2645,6 @@ void KeymapWrapper::GetFocusInfo(wl_surface** aFocusSurface,
*aFocusSurface = keymapWrapper->mFocusSurface;
*aFocusSerial = keymapWrapper->mFocusSerial;
}
void KeymapWrapper::SetSeat(wl_seat* aSeat, int aId) {
sSeat = aSeat;
sSeatID = aId;
wl_seat_add_listener(aSeat, &seat_listener, nullptr);
}
void KeymapWrapper::ClearSeat(int aId) {
if (sSeatID == aId) {
ClearKeyboard();
sSeat = nullptr;
sSeatID = -1;
}
}
wl_seat* KeymapWrapper::GetSeat() { return sSeat; }
void KeymapWrapper::SetKeyboard(wl_keyboard* aKeyboard) {
sKeyboard = aKeyboard;
}
wl_keyboard* KeymapWrapper::GetKeyboard() { return sKeyboard; }
void KeymapWrapper::ClearKeyboard() {
if (sKeyboard) {
wl_keyboard_destroy(sKeyboard);
sKeyboard = nullptr;
}
}
#endif
} // namespace widget

Просмотреть файл

@ -198,6 +198,7 @@ class KeymapWrapper {
* from xkb_keymap. We call that from Wayland backend routines.
*/
static void SetModifierMasks(xkb_keymap* aKeymap);
static void HandleKeymap(uint32_t format, int fd, uint32_t size);
/**
* Wayland global focus handlers
@ -206,10 +207,6 @@ class KeymapWrapper {
static void SetFocusOut(wl_surface* aFocusSurface);
static void GetFocusInfo(wl_surface** aFocusSurface, uint32_t* aFocusSerial);
static void SetSeat(wl_seat* aSeat, int aId);
static void ClearSeat(int aId);
static wl_seat* GetSeat();
static void SetKeyboard(wl_keyboard* aKeyboard);
static wl_keyboard* GetKeyboard();
static void ClearKeyboard();
@ -497,9 +494,6 @@ class KeymapWrapper {
#endif
#ifdef MOZ_WAYLAND
static wl_seat* sSeat;
static int sSeatID;
static wl_keyboard* sKeyboard;
wl_surface* mFocusSurface = nullptr;
uint32_t mFocusSerial = 0;
#endif

Просмотреть файл

@ -19,6 +19,7 @@
#include "mozilla/Sprintf.h"
#include "WidgetUtilsGtk.h"
#include "nsGtkKeyUtils.h"
#include "nsWindow.h"
namespace mozilla::widget {
@ -57,6 +58,198 @@ nsWaylandDisplay* WaylandDisplayGet() {
void nsWaylandDisplay::SetShm(wl_shm* aShm) { mShm = aShm; }
struct PointerState {
wl_surface* surface;
nsWindow* GetWindow() {
GdkWindow* window =
static_cast<GdkWindow*>(wl_surface_get_user_data(surface));
return window ? static_cast<nsWindow*>(
g_object_get_data(G_OBJECT(window), "nsWindow"))
: nullptr;
}
} sPointerState;
static void gesture_hold_begin(void* data,
struct zwp_pointer_gesture_hold_v1* hold,
uint32_t serial, uint32_t time,
struct wl_surface* surface, uint32_t fingers) {
RefPtr<nsWindow> window = sPointerState.GetWindow();
if (!window) {
return;
}
window->OnTouchpadHoldEvent(GDK_TOUCHPAD_GESTURE_PHASE_BEGIN, time, fingers);
}
static void gesture_hold_end(void* data,
struct zwp_pointer_gesture_hold_v1* hold,
uint32_t serial, uint32_t time,
int32_t cancelled) {
RefPtr<nsWindow> window = sPointerState.GetWindow();
if (!window) {
return;
}
window->OnTouchpadHoldEvent(cancelled ? GDK_TOUCHPAD_GESTURE_PHASE_CANCEL
: GDK_TOUCHPAD_GESTURE_PHASE_END,
time, 0);
}
static const struct zwp_pointer_gesture_hold_v1_listener gesture_hold_listener =
{gesture_hold_begin, gesture_hold_end};
static void pointer_handle_enter(void* data, struct wl_pointer* pointer,
uint32_t serial, struct wl_surface* surface,
wl_fixed_t sx, wl_fixed_t sy) {
sPointerState.surface = surface;
}
static void pointer_handle_leave(void* data, struct wl_pointer* pointer,
uint32_t serial, struct wl_surface* surface) {
sPointerState.surface = nullptr;
}
static void pointer_handle_motion(void* data, struct wl_pointer* pointer,
uint32_t time, wl_fixed_t sx, wl_fixed_t sy) {
}
static void pointer_handle_button(void* data, struct wl_pointer* pointer,
uint32_t serial, uint32_t time,
uint32_t button, uint32_t state) {}
static void pointer_handle_axis(void* data, struct wl_pointer* pointer,
uint32_t time, uint32_t axis,
wl_fixed_t value) {}
static void pointer_handle_frame(void* data, struct wl_pointer* pointer) {}
static void pointer_handle_axis_source(
void* data, struct wl_pointer* pointer,
/*enum wl_pointer_axis_source */ uint32_t source) {}
static void pointer_handle_axis_stop(void* data, struct wl_pointer* pointer,
uint32_t time, uint32_t axis) {}
static void pointer_handle_axis_discrete(void* data, struct wl_pointer* pointer,
uint32_t axis, int32_t value) {}
static void pointer_handle_axis_value120(void* data, struct wl_pointer* pointer,
uint32_t axis, int32_t value) {}
static const struct moz_wl_pointer_listener pointer_listener = {
pointer_handle_enter, pointer_handle_leave,
pointer_handle_motion, pointer_handle_button,
pointer_handle_axis, pointer_handle_frame,
pointer_handle_axis_source, pointer_handle_axis_stop,
pointer_handle_axis_discrete, pointer_handle_axis_value120,
};
void nsWaylandDisplay::SetPointer(wl_pointer* aPointer) {
if (!mPointerGestures) {
return;
}
MOZ_DIAGNOSTIC_ASSERT(!mPointer);
mPointer = aPointer;
wl_pointer_add_listener(mPointer,
(const wl_pointer_listener*)&pointer_listener, this);
mPointerGestureHold =
zwp_pointer_gestures_v1_get_hold_gesture(mPointerGestures, mPointer);
zwp_pointer_gesture_hold_v1_set_user_data(mPointerGestureHold, this);
zwp_pointer_gesture_hold_v1_add_listener(mPointerGestureHold,
&gesture_hold_listener, this);
}
void nsWaylandDisplay::RemovePointer() {
wl_pointer_release(mPointer);
mPointer = nullptr;
}
static void seat_handle_capabilities(void* data, struct wl_seat* seat,
unsigned int caps) {
auto* display = static_cast<nsWaylandDisplay*>(data);
if (!display) {
return;
}
if ((caps & WL_SEAT_CAPABILITY_POINTER) && !display->GetPointer()) {
display->SetPointer(wl_seat_get_pointer(seat));
} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && display->GetPointer()) {
display->RemovePointer();
}
wl_keyboard* keyboard = display->GetKeyboard();
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !keyboard) {
display->SetKeyboard(wl_seat_get_keyboard(seat));
} else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && keyboard) {
display->ClearKeyboard();
}
}
static const struct wl_seat_listener seat_listener = {
seat_handle_capabilities,
};
void nsWaylandDisplay::SetSeat(wl_seat* aSeat, int aSeatId) {
mSeat = aSeat;
mSeatId = aSeatId;
wl_seat_add_listener(aSeat, &seat_listener, this);
}
void nsWaylandDisplay::RemoveSeat(int aSeatId) {
if (mSeatId == aSeatId) {
mSeat = nullptr;
mSeatId = -1;
}
}
/* This keymap routine is derived from weston-2.0.0/clients/simple-im.c
*/
static void keyboard_handle_keymap(void* data, struct wl_keyboard* wl_keyboard,
uint32_t format, int fd, uint32_t size) {
KeymapWrapper::HandleKeymap(format, fd, size);
}
static void keyboard_handle_enter(void* data, struct wl_keyboard* keyboard,
uint32_t serial, struct wl_surface* surface,
struct wl_array* keys) {
KeymapWrapper::SetFocusIn(surface, serial);
}
static void keyboard_handle_leave(void* data, struct wl_keyboard* keyboard,
uint32_t serial, struct wl_surface* surface) {
KeymapWrapper::SetFocusOut(surface);
}
static void keyboard_handle_key(void* data, struct wl_keyboard* keyboard,
uint32_t serial, uint32_t time, uint32_t key,
uint32_t state) {}
static void keyboard_handle_modifiers(void* data, struct wl_keyboard* keyboard,
uint32_t serial, uint32_t mods_depressed,
uint32_t mods_latched,
uint32_t mods_locked, uint32_t group) {}
static void keyboard_handle_repeat_info(void* data,
struct wl_keyboard* keyboard,
int32_t rate, int32_t delay) {}
static const struct wl_keyboard_listener keyboard_listener = {
keyboard_handle_keymap, keyboard_handle_enter,
keyboard_handle_leave, keyboard_handle_key,
keyboard_handle_modifiers, keyboard_handle_repeat_info};
void nsWaylandDisplay::SetKeyboard(wl_keyboard* aKeyboard) {
MOZ_ASSERT(aKeyboard);
MOZ_DIAGNOSTIC_ASSERT(!mKeyboard);
mKeyboard = aKeyboard;
wl_keyboard_add_listener(mKeyboard, &keyboard_listener, nullptr);
}
void nsWaylandDisplay::ClearKeyboard() {
if (mKeyboard) {
wl_keyboard_destroy(mKeyboard);
mKeyboard = nullptr;
}
}
void nsWaylandDisplay::SetCompositor(wl_compositor* aCompositor) {
mCompositor = aCompositor;
}
@ -84,6 +277,11 @@ void nsWaylandDisplay::SetPointerConstraints(
mPointerConstraints = aPointerConstraints;
}
void nsWaylandDisplay::SetPointerGestures(
zwp_pointer_gestures_v1* aPointerGestures) {
mPointerGestures = aPointerGestures;
}
void nsWaylandDisplay::SetDmabuf(zwp_linux_dmabuf_v1* aDmabuf) {
mDmabuf = aDmabuf;
}
@ -124,7 +322,8 @@ static void global_registry_handler(void* data, wl_registry* registry,
registry, id, &zwp_pointer_constraints_v1_interface, 1);
display->SetPointerConstraints(pointer_constraints);
} else if (iface.EqualsLiteral("wl_compositor")) {
// Requested wl_compositor version 4 as we need wl_surface_damage_buffer().
// Requested wl_compositor version 4 as we need
// wl_surface_damage_buffer().
auto* compositor = WaylandRegistryBind<wl_compositor>(
registry, id, &wl_compositor_interface, 4);
display->SetCompositor(compositor);
@ -152,7 +351,7 @@ static void global_registry_handler(void* data, wl_registry* registry,
} else if (iface.EqualsLiteral("wl_seat")) {
auto* seat =
WaylandRegistryBind<wl_seat>(registry, id, &wl_seat_interface, 1);
KeymapWrapper::SetSeat(seat, id);
display->SetSeat(seat, id);
} else if (iface.EqualsLiteral("wp_fractional_scale_manager_v1")) {
auto* manager = WaylandRegistryBind<wp_fractional_scale_manager_v1>(
registry, id, &wp_fractional_scale_manager_v1_interface, 1);
@ -160,12 +359,21 @@ static void global_registry_handler(void* data, wl_registry* registry,
} else if (iface.EqualsLiteral("gtk_primary_selection_device_manager") ||
iface.EqualsLiteral("zwp_primary_selection_device_manager_v1")) {
display->EnablePrimarySelection();
} else if (iface.EqualsLiteral("zwp_pointer_gestures_v1")) {
// HOLD is introduced in version 3
auto* gestures = WaylandRegistryBind<zwp_pointer_gestures_v1>(
registry, id, &zwp_pointer_gestures_v1_interface, 3);
display->SetPointerGestures(gestures);
}
}
static void global_registry_remover(void* data, wl_registry* registry,
uint32_t id) {
KeymapWrapper::ClearSeat(id);
auto* display = static_cast<nsWaylandDisplay*>(data);
if (!display) {
return;
}
display->RemoveSeat(id);
}
static const struct wl_registry_listener registry_listener = {

Просмотреть файл

@ -16,6 +16,7 @@
#include "mozilla/widget/idle-inhibit-unstable-v1-client-protocol.h"
#include "mozilla/widget/relative-pointer-unstable-v1-client-protocol.h"
#include "mozilla/widget/pointer-constraints-unstable-v1-client-protocol.h"
#include "mozilla/widget/pointer-gestures-unstable-v1-client-protocol.h"
#include "mozilla/widget/linux-dmabuf-unstable-v1-client-protocol.h"
#include "mozilla/widget/viewporter-client-protocol.h"
#include "mozilla/widget/xdg-activation-v1-client-protocol.h"
@ -57,7 +58,20 @@ class nsWaylandDisplay {
}
bool IsPrimarySelectionEnabled() { return mIsPrimarySelectionEnabled; }
wl_pointer* GetPointer() { return mPointer; }
void SetPointer(wl_pointer* aPointer);
void RemovePointer();
void SetShm(wl_shm* aShm);
void SetKeyboard(wl_keyboard* aKeyboard);
wl_keyboard* GetKeyboard() { return mKeyboard; }
void ClearKeyboard();
void SetSeat(wl_seat* aSeat, int aSeatId);
wl_seat* GetSeat() { return mSeat; }
void RemoveSeat(int aSeatId);
void SetCompositor(wl_compositor* aCompositor);
void SetSubcompositor(wl_subcompositor* aSubcompositor);
void SetDataDeviceManager(wl_data_device_manager* aDataDeviceManager);
@ -66,6 +80,7 @@ class nsWaylandDisplay {
void SetRelativePointerManager(
zwp_relative_pointer_manager_v1* aRelativePointerManager);
void SetPointerConstraints(zwp_pointer_constraints_v1* aPointerConstraints);
void SetPointerGestures(zwp_pointer_gestures_v1* aPointerGestures);
void SetDmabuf(zwp_linux_dmabuf_v1* aDmabuf);
void SetXdgActivation(xdg_activation_v1* aXdgActivation);
void SetXdgDbusAnnotationManager(
@ -84,9 +99,15 @@ class nsWaylandDisplay {
wl_compositor* mCompositor = nullptr;
wl_subcompositor* mSubcompositor = nullptr;
wl_shm* mShm = nullptr;
wl_seat* mSeat = nullptr;
int mSeatId = -1;
wl_keyboard* mKeyboard = nullptr;
wl_pointer* mPointer = nullptr;
zwp_idle_inhibit_manager_v1* mIdleInhibitManager = nullptr;
zwp_relative_pointer_manager_v1* mRelativePointerManager = nullptr;
zwp_pointer_constraints_v1* mPointerConstraints = nullptr;
zwp_pointer_gestures_v1* mPointerGestures = nullptr;
zwp_pointer_gesture_hold_v1* mPointerGestureHold = nullptr;
wp_viewporter* mViewporter = nullptr;
zwp_linux_dmabuf_v1* mDmabuf = nullptr;
xdg_activation_v1* mXdgActivation = nullptr;

Просмотреть файл

@ -141,7 +141,6 @@ using mozilla::gl::GLContextGLX;
#define MAX_RECTS_IN_REGION 100
#if !GTK_CHECK_VERSION(3, 18, 0)
struct _GdkEventTouchpadPinch {
GdkEventType type;
GdkWindow* window;
@ -159,16 +158,8 @@ struct _GdkEventTouchpadPinch {
guint state;
};
typedef enum {
GDK_TOUCHPAD_GESTURE_PHASE_BEGIN,
GDK_TOUCHPAD_GESTURE_PHASE_UPDATE,
GDK_TOUCHPAD_GESTURE_PHASE_END,
GDK_TOUCHPAD_GESTURE_PHASE_CANCEL
} GdkTouchpadGesturePhase;
gint GDK_TOUCHPAD_GESTURE_MASK = 1 << 24;
GdkEventType GDK_TOUCHPAD_PINCH = static_cast<GdkEventType>(42);
#endif
const gint kEvents = GDK_TOUCHPAD_GESTURE_MASK | GDK_EXPOSURE_MASK |
@ -5511,6 +5502,11 @@ gboolean nsWindow::OnTouchpadPinchEvent(GdkEventTouchpadPinch* aEvent) {
return TRUE;
}
void nsWindow::OnTouchpadHoldEvent(GdkTouchpadGesturePhase aPhase, guint aTime,
uint32_t aFingers) {
LOG("OnTouchpadHoldEvent: aPhase %d aFingers %d", aPhase, aFingers);
}
gboolean nsWindow::OnTouchEvent(GdkEventTouch* aEvent) {
LOG("OnTouchEvent: x=%f y=%f type=%d\n", aEvent->x, aEvent->y, aEvent->type);
if (!mHandleTouchEvent) {

Просмотреть файл

@ -109,6 +109,15 @@ typedef enum {
} GdkAnchorHints;
#endif
#if !GTK_CHECK_VERSION(3, 18, 0)
typedef enum {
GDK_TOUCHPAD_GESTURE_PHASE_BEGIN,
GDK_TOUCHPAD_GESTURE_PHASE_UPDATE,
GDK_TOUCHPAD_GESTURE_PHASE_END,
GDK_TOUCHPAD_GESTURE_PHASE_CANCEL
} GdkTouchpadGesturePhase;
#endif
namespace mozilla {
enum class NativeKeyBindingsType : uint8_t;
@ -258,6 +267,8 @@ class nsWindow final : public nsBaseWidget {
gboolean OnPropertyNotifyEvent(GtkWidget* aWidget, GdkEventProperty* aEvent);
gboolean OnTouchEvent(GdkEventTouch* aEvent);
gboolean OnTouchpadPinchEvent(GdkEventTouchpadPinch* aEvent);
void OnTouchpadHoldEvent(GdkTouchpadGesturePhase aPhase, guint aTime,
uint32_t aFingers);
gint GetInputRegionMarginInGdkCoords();

Просмотреть файл

@ -12,6 +12,7 @@ SOURCES += [
"idle-inhibit-unstable-v1-protocol.c",
"linux-dmabuf-unstable-v1-protocol.c",
"pointer-constraints-unstable-v1-protocol.c",
"pointer-gestures-unstable-v1-protocol.c",
"relative-pointer-unstable-v1-protocol.c",
"viewporter-protocol.c",
"xdg-activation-v1-protocol.c",
@ -24,6 +25,7 @@ EXPORTS.mozilla.widget += [
"idle-inhibit-unstable-v1-client-protocol.h",
"linux-dmabuf-unstable-v1-client-protocol.h",
"pointer-constraints-unstable-v1-client-protocol.h",
"pointer-gestures-unstable-v1-client-protocol.h",
"relative-pointer-unstable-v1-client-protocol.h",
"viewporter-client-protocol.h",
"xdg-activation-v1-client-protocol.h",

Просмотреть файл

@ -0,0 +1,685 @@
/* Generated by wayland-scanner 1.22.0 */
#ifndef POINTER_GESTURES_UNSTABLE_V1_CLIENT_PROTOCOL_H
#define POINTER_GESTURES_UNSTABLE_V1_CLIENT_PROTOCOL_H
#include <stdint.h>
#include <stddef.h>
#include "wayland-client.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @page page_pointer_gestures_unstable_v1 The pointer_gestures_unstable_v1
* protocol
* @section page_ifaces_pointer_gestures_unstable_v1 Interfaces
* - @subpage page_iface_zwp_pointer_gestures_v1 - touchpad gestures
* - @subpage page_iface_zwp_pointer_gesture_swipe_v1 - a swipe gesture object
* - @subpage page_iface_zwp_pointer_gesture_pinch_v1 - a pinch gesture object
* - @subpage page_iface_zwp_pointer_gesture_hold_v1 - a hold gesture object
*/
struct wl_pointer;
struct wl_surface;
struct zwp_pointer_gesture_hold_v1;
struct zwp_pointer_gesture_pinch_v1;
struct zwp_pointer_gesture_swipe_v1;
struct zwp_pointer_gestures_v1;
#ifndef ZWP_POINTER_GESTURES_V1_INTERFACE
# define ZWP_POINTER_GESTURES_V1_INTERFACE
/**
* @page page_iface_zwp_pointer_gestures_v1 zwp_pointer_gestures_v1
* @section page_iface_zwp_pointer_gestures_v1_desc Description
*
* A global interface to provide semantic touchpad gestures for a given
* pointer.
*
* Three gestures are currently supported: swipe, pinch, and hold.
* Pinch and swipe gestures follow a three-stage cycle: begin, update,
* end, hold gestures follow a two-stage cycle: begin and end. All
* gestures 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.
* @section page_iface_zwp_pointer_gestures_v1_api API
* See @ref iface_zwp_pointer_gestures_v1.
*/
/**
* @defgroup iface_zwp_pointer_gestures_v1 The zwp_pointer_gestures_v1 interface
*
* A global interface to provide semantic touchpad gestures for a given
* pointer.
*
* Three gestures are currently supported: swipe, pinch, and hold.
* Pinch and swipe gestures follow a three-stage cycle: begin, update,
* end, hold gestures follow a two-stage cycle: begin and end. All
* gestures 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.
*/
extern const struct wl_interface zwp_pointer_gestures_v1_interface;
#endif
#ifndef ZWP_POINTER_GESTURE_SWIPE_V1_INTERFACE
# define ZWP_POINTER_GESTURE_SWIPE_V1_INTERFACE
/**
* @page page_iface_zwp_pointer_gesture_swipe_v1 zwp_pointer_gesture_swipe_v1
* @section page_iface_zwp_pointer_gesture_swipe_v1_desc Description
*
* 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 hold, 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.
* @section page_iface_zwp_pointer_gesture_swipe_v1_api API
* See @ref iface_zwp_pointer_gesture_swipe_v1.
*/
/**
* @defgroup iface_zwp_pointer_gesture_swipe_v1 The zwp_pointer_gesture_swipe_v1
* interface
*
* 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 hold, 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.
*/
extern const struct wl_interface zwp_pointer_gesture_swipe_v1_interface;
#endif
#ifndef ZWP_POINTER_GESTURE_PINCH_V1_INTERFACE
# define ZWP_POINTER_GESTURE_PINCH_V1_INTERFACE
/**
* @page page_iface_zwp_pointer_gesture_pinch_v1 zwp_pointer_gesture_pinch_v1
* @section page_iface_zwp_pointer_gesture_pinch_v1_desc Description
*
* 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 hold, 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.
* @section page_iface_zwp_pointer_gesture_pinch_v1_api API
* See @ref iface_zwp_pointer_gesture_pinch_v1.
*/
/**
* @defgroup iface_zwp_pointer_gesture_pinch_v1 The zwp_pointer_gesture_pinch_v1
* interface
*
* 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 hold, 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.
*/
extern const struct wl_interface zwp_pointer_gesture_pinch_v1_interface;
#endif
#ifndef ZWP_POINTER_GESTURE_HOLD_V1_INTERFACE
# define ZWP_POINTER_GESTURE_HOLD_V1_INTERFACE
/**
* @page page_iface_zwp_pointer_gesture_hold_v1 zwp_pointer_gesture_hold_v1
* @section page_iface_zwp_pointer_gesture_hold_v1_desc Description
*
* A hold gesture object notifies a client about a single- or
* multi-finger hold gesture detected on an indirect input device such as
* a touchpad. The gesture is usually initiated by one or more fingers
* being held down without significant movement. The precise conditions
* of when such a gesture is detected are implementation-dependent.
*
* In particular, this gesture may be used to cancel kinetic scrolling.
*
* A hold gesture consists of two stages: begin and end. Unlike pinch and
* swipe there is no update stage.
* There cannot be multiple simultaneous hold, 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.
* @section page_iface_zwp_pointer_gesture_hold_v1_api API
* See @ref iface_zwp_pointer_gesture_hold_v1.
*/
/**
* @defgroup iface_zwp_pointer_gesture_hold_v1 The zwp_pointer_gesture_hold_v1
* interface
*
* A hold gesture object notifies a client about a single- or
* multi-finger hold gesture detected on an indirect input device such as
* a touchpad. The gesture is usually initiated by one or more fingers
* being held down without significant movement. The precise conditions
* of when such a gesture is detected are implementation-dependent.
*
* In particular, this gesture may be used to cancel kinetic scrolling.
*
* A hold gesture consists of two stages: begin and end. Unlike pinch and
* swipe there is no update stage.
* There cannot be multiple simultaneous hold, 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.
*/
extern const struct wl_interface zwp_pointer_gesture_hold_v1_interface;
#endif
#define ZWP_POINTER_GESTURES_V1_GET_SWIPE_GESTURE 0
#define ZWP_POINTER_GESTURES_V1_GET_PINCH_GESTURE 1
#define ZWP_POINTER_GESTURES_V1_RELEASE 2
#define ZWP_POINTER_GESTURES_V1_GET_HOLD_GESTURE 3
/**
* @ingroup iface_zwp_pointer_gestures_v1
*/
#define ZWP_POINTER_GESTURES_V1_GET_SWIPE_GESTURE_SINCE_VERSION 1
/**
* @ingroup iface_zwp_pointer_gestures_v1
*/
#define ZWP_POINTER_GESTURES_V1_GET_PINCH_GESTURE_SINCE_VERSION 1
/**
* @ingroup iface_zwp_pointer_gestures_v1
*/
#define ZWP_POINTER_GESTURES_V1_RELEASE_SINCE_VERSION 2
/**
* @ingroup iface_zwp_pointer_gestures_v1
*/
#define ZWP_POINTER_GESTURES_V1_GET_HOLD_GESTURE_SINCE_VERSION 3
/** @ingroup iface_zwp_pointer_gestures_v1 */
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);
}
/** @ingroup iface_zwp_pointer_gestures_v1 */
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 uint32_t zwp_pointer_gestures_v1_get_version(
struct zwp_pointer_gestures_v1* zwp_pointer_gestures_v1) {
return wl_proxy_get_version((struct wl_proxy*)zwp_pointer_gestures_v1);
}
/** @ingroup iface_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);
}
/**
* @ingroup iface_zwp_pointer_gestures_v1
*
* Create a swipe gesture object. See the
* wl_pointer_gesture_swipe interface for details.
*/
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_flags(
(struct wl_proxy*)zwp_pointer_gestures_v1,
ZWP_POINTER_GESTURES_V1_GET_SWIPE_GESTURE,
&zwp_pointer_gesture_swipe_v1_interface,
wl_proxy_get_version((struct wl_proxy*)zwp_pointer_gestures_v1), 0, NULL,
pointer);
return (struct zwp_pointer_gesture_swipe_v1*)id;
}
/**
* @ingroup iface_zwp_pointer_gestures_v1
*
* Create a pinch gesture object. See the
* wl_pointer_gesture_pinch interface for details.
*/
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_flags(
(struct wl_proxy*)zwp_pointer_gestures_v1,
ZWP_POINTER_GESTURES_V1_GET_PINCH_GESTURE,
&zwp_pointer_gesture_pinch_v1_interface,
wl_proxy_get_version((struct wl_proxy*)zwp_pointer_gestures_v1), 0, NULL,
pointer);
return (struct zwp_pointer_gesture_pinch_v1*)id;
}
/**
* @ingroup iface_zwp_pointer_gestures_v1
*
* Destroy the pointer gesture object. Swipe, pinch and hold objects
* created via this gesture object remain valid.
*/
static inline void zwp_pointer_gestures_v1_release(
struct zwp_pointer_gestures_v1* zwp_pointer_gestures_v1) {
wl_proxy_marshal_flags(
(struct wl_proxy*)zwp_pointer_gestures_v1,
ZWP_POINTER_GESTURES_V1_RELEASE, NULL,
wl_proxy_get_version((struct wl_proxy*)zwp_pointer_gestures_v1),
WL_MARSHAL_FLAG_DESTROY);
}
/**
* @ingroup iface_zwp_pointer_gestures_v1
*
* Create a hold gesture object. See the
* wl_pointer_gesture_hold interface for details.
*/
static inline struct zwp_pointer_gesture_hold_v1*
zwp_pointer_gestures_v1_get_hold_gesture(
struct zwp_pointer_gestures_v1* zwp_pointer_gestures_v1,
struct wl_pointer* pointer) {
struct wl_proxy* id;
id = wl_proxy_marshal_flags(
(struct wl_proxy*)zwp_pointer_gestures_v1,
ZWP_POINTER_GESTURES_V1_GET_HOLD_GESTURE,
&zwp_pointer_gesture_hold_v1_interface,
wl_proxy_get_version((struct wl_proxy*)zwp_pointer_gestures_v1), 0, NULL,
pointer);
return (struct zwp_pointer_gesture_hold_v1*)id;
}
/**
* @ingroup iface_zwp_pointer_gesture_swipe_v1
* @struct zwp_pointer_gesture_swipe_v1_listener
*/
struct zwp_pointer_gesture_swipe_v1_listener {
/**
* multi-finger swipe begin
*
* This event is sent when a multi-finger swipe gesture is
* detected on the device.
* @param time timestamp with millisecond granularity
* @param fingers number of fingers
*/
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);
/**
* multi-finger swipe motion
*
* 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.
* @param time timestamp with millisecond granularity
* @param dx delta x coordinate in surface coordinate space
* @param dy delta y coordinate in surface coordinate space
*/
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);
/**
* multi-finger swipe end
*
* 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.
* @param time timestamp with millisecond granularity
* @param cancelled 1 if the gesture was cancelled, 0 otherwise
*/
void (*end)(void* data,
struct zwp_pointer_gesture_swipe_v1* zwp_pointer_gesture_swipe_v1,
uint32_t serial, uint32_t time, int32_t cancelled);
};
/**
* @ingroup iface_zwp_pointer_gesture_swipe_v1
*/
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
/**
* @ingroup iface_zwp_pointer_gesture_swipe_v1
*/
#define ZWP_POINTER_GESTURE_SWIPE_V1_BEGIN_SINCE_VERSION 1
/**
* @ingroup iface_zwp_pointer_gesture_swipe_v1
*/
#define ZWP_POINTER_GESTURE_SWIPE_V1_UPDATE_SINCE_VERSION 1
/**
* @ingroup iface_zwp_pointer_gesture_swipe_v1
*/
#define ZWP_POINTER_GESTURE_SWIPE_V1_END_SINCE_VERSION 1
/**
* @ingroup iface_zwp_pointer_gesture_swipe_v1
*/
#define ZWP_POINTER_GESTURE_SWIPE_V1_DESTROY_SINCE_VERSION 1
/** @ingroup iface_zwp_pointer_gesture_swipe_v1 */
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);
}
/** @ingroup iface_zwp_pointer_gesture_swipe_v1 */
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 uint32_t zwp_pointer_gesture_swipe_v1_get_version(
struct zwp_pointer_gesture_swipe_v1* zwp_pointer_gesture_swipe_v1) {
return wl_proxy_get_version((struct wl_proxy*)zwp_pointer_gesture_swipe_v1);
}
/**
* @ingroup iface_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_flags(
(struct wl_proxy*)zwp_pointer_gesture_swipe_v1,
ZWP_POINTER_GESTURE_SWIPE_V1_DESTROY, NULL,
wl_proxy_get_version((struct wl_proxy*)zwp_pointer_gesture_swipe_v1),
WL_MARSHAL_FLAG_DESTROY);
}
/**
* @ingroup iface_zwp_pointer_gesture_pinch_v1
* @struct zwp_pointer_gesture_pinch_v1_listener
*/
struct zwp_pointer_gesture_pinch_v1_listener {
/**
* multi-finger pinch begin
*
* This event is sent when a multi-finger pinch gesture is
* detected on the device.
* @param time timestamp with millisecond granularity
* @param fingers number of fingers
*/
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);
/**
* multi-finger pinch motion
*
* 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.
* @param time timestamp with millisecond granularity
* @param dx delta x coordinate in surface coordinate space
* @param dy delta y coordinate in surface coordinate space
* @param scale scale relative to the initial finger position
* @param rotation angle in degrees cw relative to the previous 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);
/**
* multi-finger pinch end
*
* 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.
* @param time timestamp with millisecond granularity
* @param cancelled 1 if the gesture was cancelled, 0 otherwise
*/
void (*end)(void* data,
struct zwp_pointer_gesture_pinch_v1* zwp_pointer_gesture_pinch_v1,
uint32_t serial, uint32_t time, int32_t cancelled);
};
/**
* @ingroup iface_zwp_pointer_gesture_pinch_v1
*/
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
/**
* @ingroup iface_zwp_pointer_gesture_pinch_v1
*/
#define ZWP_POINTER_GESTURE_PINCH_V1_BEGIN_SINCE_VERSION 1
/**
* @ingroup iface_zwp_pointer_gesture_pinch_v1
*/
#define ZWP_POINTER_GESTURE_PINCH_V1_UPDATE_SINCE_VERSION 1
/**
* @ingroup iface_zwp_pointer_gesture_pinch_v1
*/
#define ZWP_POINTER_GESTURE_PINCH_V1_END_SINCE_VERSION 1
/**
* @ingroup iface_zwp_pointer_gesture_pinch_v1
*/
#define ZWP_POINTER_GESTURE_PINCH_V1_DESTROY_SINCE_VERSION 1
/** @ingroup iface_zwp_pointer_gesture_pinch_v1 */
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);
}
/** @ingroup iface_zwp_pointer_gesture_pinch_v1 */
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 uint32_t zwp_pointer_gesture_pinch_v1_get_version(
struct zwp_pointer_gesture_pinch_v1* zwp_pointer_gesture_pinch_v1) {
return wl_proxy_get_version((struct wl_proxy*)zwp_pointer_gesture_pinch_v1);
}
/**
* @ingroup iface_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_flags(
(struct wl_proxy*)zwp_pointer_gesture_pinch_v1,
ZWP_POINTER_GESTURE_PINCH_V1_DESTROY, NULL,
wl_proxy_get_version((struct wl_proxy*)zwp_pointer_gesture_pinch_v1),
WL_MARSHAL_FLAG_DESTROY);
}
/**
* @ingroup iface_zwp_pointer_gesture_hold_v1
* @struct zwp_pointer_gesture_hold_v1_listener
*/
struct zwp_pointer_gesture_hold_v1_listener {
/**
* multi-finger hold begin
*
* This event is sent when a hold gesture is detected on the
* device.
* @param time timestamp with millisecond granularity
* @param fingers number of fingers
* @since 3
*/
void (*begin)(void* data,
struct zwp_pointer_gesture_hold_v1* zwp_pointer_gesture_hold_v1,
uint32_t serial, uint32_t time, struct wl_surface* surface,
uint32_t fingers);
/**
* multi-finger hold end
*
* This event is sent when a hold gesture ceases to be valid.
* This may happen when the holding fingers are lifted or the
* gesture is cancelled, for example if the fingers move past an
* implementation-defined threshold, the finger count changes or
* the hold gesture changes into a different type of gesture.
*
* When a gesture is cancelled, the client may need to undo state
* changes caused by this gesture. What causes a gesture to be
* cancelled is implementation-dependent.
* @param time timestamp with millisecond granularity
* @param cancelled 1 if the gesture was cancelled, 0 otherwise
* @since 3
*/
void (*end)(void* data,
struct zwp_pointer_gesture_hold_v1* zwp_pointer_gesture_hold_v1,
uint32_t serial, uint32_t time, int32_t cancelled);
};
/**
* @ingroup iface_zwp_pointer_gesture_hold_v1
*/
static inline int zwp_pointer_gesture_hold_v1_add_listener(
struct zwp_pointer_gesture_hold_v1* zwp_pointer_gesture_hold_v1,
const struct zwp_pointer_gesture_hold_v1_listener* listener, void* data) {
return wl_proxy_add_listener((struct wl_proxy*)zwp_pointer_gesture_hold_v1,
(void (**)(void))listener, data);
}
#define ZWP_POINTER_GESTURE_HOLD_V1_DESTROY 0
/**
* @ingroup iface_zwp_pointer_gesture_hold_v1
*/
#define ZWP_POINTER_GESTURE_HOLD_V1_BEGIN_SINCE_VERSION 3
/**
* @ingroup iface_zwp_pointer_gesture_hold_v1
*/
#define ZWP_POINTER_GESTURE_HOLD_V1_END_SINCE_VERSION 3
/**
* @ingroup iface_zwp_pointer_gesture_hold_v1
*/
#define ZWP_POINTER_GESTURE_HOLD_V1_DESTROY_SINCE_VERSION 3
/** @ingroup iface_zwp_pointer_gesture_hold_v1 */
static inline void zwp_pointer_gesture_hold_v1_set_user_data(
struct zwp_pointer_gesture_hold_v1* zwp_pointer_gesture_hold_v1,
void* user_data) {
wl_proxy_set_user_data((struct wl_proxy*)zwp_pointer_gesture_hold_v1,
user_data);
}
/** @ingroup iface_zwp_pointer_gesture_hold_v1 */
static inline void* zwp_pointer_gesture_hold_v1_get_user_data(
struct zwp_pointer_gesture_hold_v1* zwp_pointer_gesture_hold_v1) {
return wl_proxy_get_user_data((struct wl_proxy*)zwp_pointer_gesture_hold_v1);
}
static inline uint32_t zwp_pointer_gesture_hold_v1_get_version(
struct zwp_pointer_gesture_hold_v1* zwp_pointer_gesture_hold_v1) {
return wl_proxy_get_version((struct wl_proxy*)zwp_pointer_gesture_hold_v1);
}
/**
* @ingroup iface_zwp_pointer_gesture_hold_v1
*/
static inline void zwp_pointer_gesture_hold_v1_destroy(
struct zwp_pointer_gesture_hold_v1* zwp_pointer_gesture_hold_v1) {
wl_proxy_marshal_flags(
(struct wl_proxy*)zwp_pointer_gesture_hold_v1,
ZWP_POINTER_GESTURE_HOLD_V1_DESTROY, NULL,
wl_proxy_get_version((struct wl_proxy*)zwp_pointer_gesture_hold_v1),
WL_MARSHAL_FLAG_DESTROY);
}
#ifdef __cplusplus
}
#endif
#endif

Просмотреть файл

@ -0,0 +1,112 @@
/* Generated by wayland-scanner 1.22.0 */
#include <stdlib.h>
#include <stdint.h>
#include "wayland-util.h"
#ifndef __has_attribute
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
#endif
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
# define WL_PRIVATE __attribute__((visibility("hidden")))
#else
# define WL_PRIVATE
#endif
#pragma GCC visibility push(default)
extern const struct wl_interface wl_pointer_interface;
extern const struct wl_interface wl_surface_interface;
#pragma GCC visibility pop
extern const struct wl_interface zwp_pointer_gesture_hold_v1_interface;
extern const struct wl_interface zwp_pointer_gesture_pinch_v1_interface;
extern const struct wl_interface zwp_pointer_gesture_swipe_v1_interface;
static const struct wl_interface* pointer_gestures_unstable_v1_types[] = {
NULL,
NULL,
NULL,
NULL,
NULL,
&zwp_pointer_gesture_swipe_v1_interface,
&wl_pointer_interface,
&zwp_pointer_gesture_pinch_v1_interface,
&wl_pointer_interface,
&zwp_pointer_gesture_hold_v1_interface,
&wl_pointer_interface,
NULL,
NULL,
&wl_surface_interface,
NULL,
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", pointer_gestures_unstable_v1_types + 5},
{"get_pinch_gesture", "no", pointer_gestures_unstable_v1_types + 7},
{"release", "2", pointer_gestures_unstable_v1_types + 0},
{"get_hold_gesture", "3no", pointer_gestures_unstable_v1_types + 9},
};
WL_PRIVATE const struct wl_interface zwp_pointer_gestures_v1_interface = {
"zwp_pointer_gestures_v1", 3, 4, zwp_pointer_gestures_v1_requests, 0, NULL,
};
static const struct wl_message zwp_pointer_gesture_swipe_v1_requests[] = {
{"destroy", "", pointer_gestures_unstable_v1_types + 0},
};
static const struct wl_message zwp_pointer_gesture_swipe_v1_events[] = {
{"begin", "uuou", pointer_gestures_unstable_v1_types + 11},
{"update", "uff", pointer_gestures_unstable_v1_types + 0},
{"end", "uui", pointer_gestures_unstable_v1_types + 0},
};
WL_PRIVATE const struct wl_interface zwp_pointer_gesture_swipe_v1_interface = {
"zwp_pointer_gesture_swipe_v1",
2,
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", "", pointer_gestures_unstable_v1_types + 0},
};
static const struct wl_message zwp_pointer_gesture_pinch_v1_events[] = {
{"begin", "uuou", pointer_gestures_unstable_v1_types + 15},
{"update", "uffff", pointer_gestures_unstable_v1_types + 0},
{"end", "uui", pointer_gestures_unstable_v1_types + 0},
};
WL_PRIVATE const struct wl_interface zwp_pointer_gesture_pinch_v1_interface = {
"zwp_pointer_gesture_pinch_v1",
2,
1,
zwp_pointer_gesture_pinch_v1_requests,
3,
zwp_pointer_gesture_pinch_v1_events,
};
static const struct wl_message zwp_pointer_gesture_hold_v1_requests[] = {
{"destroy", "3", pointer_gestures_unstable_v1_types + 0},
};
static const struct wl_message zwp_pointer_gesture_hold_v1_events[] = {
{"begin", "3uuou", pointer_gestures_unstable_v1_types + 19},
{"end", "3uui", pointer_gestures_unstable_v1_types + 0},
};
WL_PRIVATE const struct wl_interface zwp_pointer_gesture_hold_v1_interface = {
"zwp_pointer_gesture_hold_v1", 3, 1,
zwp_pointer_gesture_hold_v1_requests, 2, zwp_pointer_gesture_hold_v1_events,
};