mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-19 06:47:02 -04:00
Merge branch 'input-router' into 'master'
Add input router See merge request wlroots/wlroots!4950
This commit is contained in:
commit
5d3fd61b9c
27 changed files with 4048 additions and 0 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <sys/types.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/types/wlr_input_router.h>
|
||||
|
||||
struct libseat;
|
||||
|
||||
|
|
@ -88,6 +89,27 @@ struct wlr_device_change_event {
|
|||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* A session input router layer which handles key presses for keysyms from
|
||||
* XKB_KEY_XF86Switch_VT_1 to XKB_KEY_XF86Switch_VT_12 inclusive and calls
|
||||
* wlr_session_change_vt() accordingly.
|
||||
*/
|
||||
struct wlr_session_input_router_layer {
|
||||
struct wlr_input_router *router;
|
||||
struct wlr_session *session;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
struct {
|
||||
struct wlr_input_router_keyboard keyboard;
|
||||
|
||||
struct wl_listener router_destroy;
|
||||
struct wl_listener session_destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/*
|
||||
* Opens a session, taking control of the current virtual terminal.
|
||||
* This should not be called if another program is already in control
|
||||
|
|
@ -143,4 +165,12 @@ bool wlr_session_change_vt(struct wlr_session *session, unsigned vt);
|
|||
ssize_t wlr_session_find_gpus(struct wlr_session *session,
|
||||
size_t ret_len, struct wlr_device **ret);
|
||||
|
||||
bool wlr_session_input_router_layer_register(int32_t priority);
|
||||
|
||||
struct wlr_session_input_router_layer *wlr_session_input_router_layer_create(
|
||||
struct wlr_input_router *router, struct wlr_session *session);
|
||||
|
||||
void wlr_session_input_router_layer_destroy(
|
||||
struct wlr_session_input_router_layer *layer);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#define WLR_TYPES_WLR_DATA_DEVICE_H
|
||||
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/types/wlr_input_router.h>
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
|
||||
struct wlr_data_device_manager {
|
||||
|
|
@ -151,6 +152,50 @@ struct wlr_drag_drop_event {
|
|||
uint32_t time;
|
||||
};
|
||||
|
||||
enum wlr_drag_input_router_layer_type {
|
||||
WLR_DRAG_INPUT_ROUTER_LAYER_POINTER,
|
||||
WLR_DRAG_INPUT_ROUTER_LAYER_TOUCH,
|
||||
};
|
||||
|
||||
/**
|
||||
* A data device drag input router layer which sends wl_data_device events based
|
||||
* on the pointer or a touch point position and focus. It is automatically
|
||||
* destroyed when the originating action (e.g. a button press) is reverted.
|
||||
*/
|
||||
struct wlr_drag_input_router_layer {
|
||||
struct wlr_input_router *router;
|
||||
struct wlr_input_router_implicit_grab *implicit_grab;
|
||||
struct wlr_drag *drag;
|
||||
|
||||
enum wlr_drag_input_router_layer_type type;
|
||||
|
||||
struct {
|
||||
// Global position, hotspot is not included
|
||||
double x, y;
|
||||
} icon_position;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
struct wl_signal set_icon_position;
|
||||
} events;
|
||||
|
||||
struct {
|
||||
union {
|
||||
struct {
|
||||
struct wlr_input_router_pointer pointer;
|
||||
uint32_t pointer_button;
|
||||
};
|
||||
struct {
|
||||
struct wlr_input_router_touch touch;
|
||||
int32_t touch_id;
|
||||
};
|
||||
};
|
||||
|
||||
struct wl_listener router_destroy;
|
||||
struct wl_listener drag_destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a wl_data_device_manager global for this display.
|
||||
*/
|
||||
|
|
@ -210,6 +255,20 @@ void wlr_seat_start_pointer_drag(struct wlr_seat *seat, struct wlr_drag *drag,
|
|||
void wlr_seat_start_touch_drag(struct wlr_seat *seat, struct wlr_drag *drag,
|
||||
uint32_t serial, struct wlr_touch_point *point);
|
||||
|
||||
void wlr_drag_start(struct wlr_drag *drag);
|
||||
|
||||
void wlr_drag_enter(struct wlr_drag *drag, struct wlr_surface *surface,
|
||||
double sx, double sy);
|
||||
|
||||
void wlr_drag_clear_focus(struct wlr_drag *drag);
|
||||
|
||||
void wlr_drag_send_motion(struct wlr_drag *drag, uint32_t time_msec,
|
||||
double sx, double sy);
|
||||
|
||||
void wlr_drag_drop_and_destroy(struct wlr_drag *drag, uint32_t time_msec);
|
||||
|
||||
void wlr_drag_destroy(struct wlr_drag *drag);
|
||||
|
||||
/**
|
||||
* Initializes the data source with the provided implementation.
|
||||
*/
|
||||
|
|
@ -261,4 +320,14 @@ void wlr_data_source_dnd_finish(struct wlr_data_source *source);
|
|||
void wlr_data_source_dnd_action(struct wlr_data_source *source,
|
||||
enum wl_data_device_manager_dnd_action action);
|
||||
|
||||
bool wlr_drag_input_router_layer_register(int32_t priority);
|
||||
|
||||
struct wlr_drag_input_router_layer *wlr_drag_input_router_layer_create_pointer(
|
||||
struct wlr_input_router *router, struct wlr_drag *drag, uint32_t button);
|
||||
|
||||
struct wlr_drag_input_router_layer *wlr_drag_input_router_layer_create_touch(
|
||||
struct wlr_input_router *router, struct wlr_drag *drag, int32_t id);
|
||||
|
||||
void wlr_drag_input_router_layer_destroy(struct wlr_drag_input_router_layer *layer);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
#include <wlr/types/wlr_seat.h>
|
||||
#include <wlr/util/box.h>
|
||||
|
||||
struct wlr_text_input_v3;
|
||||
|
||||
struct wlr_input_method_v2_preedit_string {
|
||||
char *text;
|
||||
int32_t cursor_begin;
|
||||
|
|
@ -104,6 +106,43 @@ struct wlr_input_method_manager_v2 {
|
|||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/**
|
||||
* A zwp_input_method_v2 input router layer which redirects keyboard events to
|
||||
* an active zwp_input_method_keyboard_grab_v2 object, if one exists. This layer
|
||||
* detects virtual keyboard devices belonging to the input method client and
|
||||
* does not process events from them.
|
||||
*/
|
||||
struct wlr_input_method_v2_input_router_layer {
|
||||
struct wlr_input_router *router;
|
||||
struct wlr_input_method_v2 *input_method;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
struct {
|
||||
struct wlr_input_router_keyboard keyboard;
|
||||
|
||||
struct wlr_input_method_keyboard_grab_v2 *grab;
|
||||
bool device_grabbed;
|
||||
|
||||
uint32_t forwarded_keys[WLR_KEYBOARD_KEYS_CAP];
|
||||
size_t n_forwarded_keys;
|
||||
|
||||
struct wlr_text_input_v3 *active_text_input;
|
||||
|
||||
struct wl_listener active_text_input_destroy;
|
||||
struct wl_listener active_text_input_commit;
|
||||
|
||||
struct wl_listener input_method_destroy;
|
||||
struct wl_listener input_method_commit;
|
||||
struct wl_listener input_method_grab_keyboard;
|
||||
|
||||
struct wl_listener router_destroy;
|
||||
struct wl_listener grab_destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
struct wlr_input_method_manager_v2 *wlr_input_method_manager_v2_create(
|
||||
struct wl_display *display);
|
||||
|
||||
|
|
@ -147,4 +186,18 @@ void wlr_input_method_keyboard_grab_v2_set_keyboard(
|
|||
void wlr_input_method_keyboard_grab_v2_destroy(
|
||||
struct wlr_input_method_keyboard_grab_v2 *keyboard_grab);
|
||||
|
||||
bool wlr_input_method_v2_input_router_layer_register(int32_t priority);
|
||||
|
||||
struct wlr_input_method_v2_input_router_layer *wlr_input_method_v2_input_router_layer_create(
|
||||
struct wlr_input_router *router);
|
||||
void wlr_input_method_v2_input_router_layer_destroy(
|
||||
struct wlr_input_method_v2_input_router_layer *layer);
|
||||
|
||||
void wlr_input_method_v2_input_router_layer_set_input_method(
|
||||
struct wlr_input_method_v2_input_router_layer *layer,
|
||||
struct wlr_input_method_v2 *input_method);
|
||||
void wlr_input_method_v2_input_router_layer_set_active_text_input(
|
||||
struct wlr_input_method_v2_input_router_layer *layer,
|
||||
struct wlr_text_input_v3 *text_input);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
551
include/wlr/types/wlr_input_router.h
Normal file
551
include/wlr/types/wlr_input_router.h
Normal file
|
|
@ -0,0 +1,551 @@
|
|||
/*
|
||||
* This an unstable interface of wlroots. No guarantees are made regarding the
|
||||
* future consistency of this API.
|
||||
*/
|
||||
#ifndef WLR_USE_UNSTABLE
|
||||
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
||||
#endif
|
||||
|
||||
#ifndef WLR_TYPES_WLR_INPUT_ROUTER_H
|
||||
#define WLR_TYPES_WLR_INPUT_ROUTER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <wayland-server-protocol.h>
|
||||
|
||||
#include <wlr/types/wlr_keyboard.h>
|
||||
#include <wlr/types/wlr_pointer.h>
|
||||
#include <wlr/util/addon.h>
|
||||
|
||||
#define WLR_INPUT_ROUTER_MAX_POINTER_BUTTONS 32
|
||||
#define WLR_INPUT_ROUTER_MAX_TOUCH_POINTS 16
|
||||
|
||||
struct wlr_input_router_handler {
|
||||
struct {
|
||||
int32_t priority;
|
||||
struct wlr_input_router_handler *head;
|
||||
struct wlr_input_router_handler *next;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
struct wlr_input_router_handler_interface {
|
||||
const char *name;
|
||||
};
|
||||
|
||||
/**
|
||||
* A registry of input event handler interface priorities.
|
||||
*/
|
||||
struct wlr_input_router_handler_priority_list {
|
||||
struct {
|
||||
struct wl_array entries; // struct wlr_input_router_handler_priority_entry
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
enum wlr_input_router_focus_type {
|
||||
WLR_INPUT_ROUTER_FOCUS_NONE,
|
||||
WLR_INPUT_ROUTER_FOCUS_SURFACE,
|
||||
WLR_INPUT_ROUTER_FOCUS_USER,
|
||||
};
|
||||
|
||||
/**
|
||||
* A helper object to store focus information. When the underlying object is
|
||||
* destroyed, the focus is automatically reset.
|
||||
*
|
||||
* Input router focus readers accept NULL, which is treated the same way as an
|
||||
* empty focus.
|
||||
*/
|
||||
struct wlr_input_router_focus {
|
||||
enum wlr_input_router_focus_type type;
|
||||
union {
|
||||
struct wlr_surface *surface;
|
||||
struct {
|
||||
void *user;
|
||||
struct wl_signal *destroy_signal;
|
||||
};
|
||||
};
|
||||
|
||||
struct {
|
||||
struct wl_listener destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
struct wlr_input_router;
|
||||
|
||||
struct wlr_input_router_interface {
|
||||
const char *name;
|
||||
|
||||
void (*at)(struct wlr_input_router *router, double x, double y,
|
||||
struct wlr_input_router_focus *focus, double *local_x, double *local_y);
|
||||
bool (*get_surface_position)(struct wlr_input_router *router,
|
||||
struct wlr_surface *surface, double *x, double *y);
|
||||
};
|
||||
|
||||
struct wlr_input_router_keyboard;
|
||||
|
||||
/**
|
||||
* Event notifying of a new keyboard focus. It is not guaranteed that the focus
|
||||
* has actually changed.
|
||||
*/
|
||||
struct wlr_input_router_keyboard_focus_event {
|
||||
const struct wlr_input_router_focus *focus;
|
||||
};
|
||||
|
||||
/**
|
||||
* Event notifying of a new active keyboard device.
|
||||
*/
|
||||
struct wlr_input_router_keyboard_device_event {
|
||||
// May be NULL
|
||||
struct wlr_keyboard *device;
|
||||
};
|
||||
|
||||
/**
|
||||
* Event notifying of a key press or release. It is guaranteed that the current
|
||||
* keyboard device is not NULL.
|
||||
*/
|
||||
struct wlr_input_router_keyboard_key_event {
|
||||
uint32_t time_msec;
|
||||
uint32_t key;
|
||||
enum wl_keyboard_key_state state;
|
||||
|
||||
// If true, this event has already been consumed and should only be used for
|
||||
// bookkeeping.
|
||||
bool intercepted;
|
||||
};
|
||||
|
||||
/**
|
||||
* Event notifying that the keyboard device modifiers have changed. It is
|
||||
* guaranteed that the current keyboard device is not NULL.
|
||||
*/
|
||||
struct wlr_input_router_keyboard_modifiers_event {
|
||||
struct {
|
||||
char unused;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
struct wlr_input_router_keyboard_interface {
|
||||
struct wlr_input_router_handler_interface base;
|
||||
|
||||
uint32_t (*focus)(struct wlr_input_router_keyboard *keyboard,
|
||||
const struct wlr_input_router_keyboard_focus_event *event);
|
||||
void (*device)(struct wlr_input_router_keyboard *keyboard,
|
||||
const struct wlr_input_router_keyboard_device_event *event);
|
||||
uint32_t (*key)(struct wlr_input_router_keyboard *keyboard,
|
||||
const struct wlr_input_router_keyboard_key_event *event);
|
||||
void (*modifiers)(struct wlr_input_router_keyboard *keyboard,
|
||||
const struct wlr_input_router_keyboard_modifiers_event *event);
|
||||
};
|
||||
|
||||
struct wlr_input_router_keyboard {
|
||||
struct wlr_input_router_handler base;
|
||||
const struct wlr_input_router_keyboard_interface *impl;
|
||||
|
||||
struct wlr_input_router_focus focus;
|
||||
struct wlr_keyboard *device;
|
||||
|
||||
struct {
|
||||
struct wl_listener device_destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/**
|
||||
* Event notifying of a pointer position. The position is not guaranteed to
|
||||
* be different from the previous one.
|
||||
*/
|
||||
struct wlr_input_router_pointer_position_event {
|
||||
uint32_t time_msec;
|
||||
|
||||
double x, y;
|
||||
const struct wlr_input_router_focus *focus;
|
||||
/**
|
||||
* If true, the focus provided with this event should be prioritized over
|
||||
* focus determined by the handler implementation.
|
||||
*/
|
||||
bool explicit_focus;
|
||||
|
||||
/**
|
||||
* If true, this event has not been caused by a physical action.
|
||||
*/
|
||||
bool synthetic;
|
||||
|
||||
/**
|
||||
* Components of pointer motion vectors. It is not guaranteed that (x - dx,
|
||||
* y - dy) is equal to the previous position.
|
||||
*/
|
||||
double dx, dy;
|
||||
double unaccel_dx, unaccel_dy;
|
||||
};
|
||||
|
||||
/**
|
||||
* Event notifying of a pointer button press or release.
|
||||
*/
|
||||
struct wlr_input_router_pointer_button_event {
|
||||
uint32_t time_msec;
|
||||
|
||||
uint32_t button;
|
||||
enum wl_pointer_button_state state;
|
||||
|
||||
// The index of the button in the input router pointer, set automatically.
|
||||
size_t index;
|
||||
};
|
||||
|
||||
struct wlr_input_router_pointer_axis_event {
|
||||
uint32_t time_msec;
|
||||
|
||||
enum wl_pointer_axis_source source;
|
||||
enum wl_pointer_axis orientation;
|
||||
enum wl_pointer_axis_relative_direction relative_direction;
|
||||
double delta;
|
||||
int32_t delta_discrete;
|
||||
};
|
||||
|
||||
struct wlr_input_router_pointer_frame_event {
|
||||
struct {
|
||||
char unused;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
struct wlr_input_router_pointer;
|
||||
|
||||
struct wlr_input_router_pointer_interface {
|
||||
struct wlr_input_router_handler_interface base;
|
||||
|
||||
uint32_t (*position)(struct wlr_input_router_pointer *pointer,
|
||||
const struct wlr_input_router_pointer_position_event *event);
|
||||
uint32_t (*button)(struct wlr_input_router_pointer *pointer,
|
||||
const struct wlr_input_router_pointer_button_event *event);
|
||||
void (*axis)(struct wlr_input_router_pointer *pointer,
|
||||
const struct wlr_input_router_pointer_axis_event *event);
|
||||
void (*frame)(struct wlr_input_router_pointer *pointer,
|
||||
const struct wlr_input_router_pointer_frame_event *event);
|
||||
};
|
||||
|
||||
struct wlr_input_router_pointer_button {
|
||||
uint32_t button;
|
||||
// The number of times the button has been pressed.
|
||||
uint32_t count;
|
||||
};
|
||||
|
||||
struct wlr_input_router_pointer {
|
||||
struct wlr_input_router_handler base;
|
||||
const struct wlr_input_router_pointer_interface *impl;
|
||||
|
||||
double x, y;
|
||||
struct wlr_input_router_focus focus;
|
||||
|
||||
struct wlr_input_router_pointer_button buttons[WLR_INPUT_ROUTER_MAX_POINTER_BUTTONS];
|
||||
uint32_t n_buttons;
|
||||
};
|
||||
|
||||
/**
|
||||
* Event notifying of a touch point position. The position is not guaranteed to
|
||||
* be different from the previous one. id is guaranteed to abe a valid touch
|
||||
* point ID.
|
||||
*/
|
||||
struct wlr_input_router_touch_position_event {
|
||||
uint32_t time_msec;
|
||||
int32_t id;
|
||||
|
||||
double x, y;
|
||||
const struct wlr_input_router_focus *focus;
|
||||
|
||||
// The index of the touch point in the input router touch, set
|
||||
// automatically.
|
||||
size_t index;
|
||||
};
|
||||
|
||||
/**
|
||||
* Event notifying of a new touch point. id is guaranteed to be unique among
|
||||
* all touch points. This event adds a touch point.
|
||||
*/
|
||||
struct wlr_input_router_touch_down_event {
|
||||
uint32_t time_msec;
|
||||
int32_t id;
|
||||
|
||||
double x, y;
|
||||
const struct wlr_input_router_focus *focus;
|
||||
|
||||
// The index of the touch point in the input router touch, set
|
||||
// automatically.
|
||||
size_t index;
|
||||
};
|
||||
|
||||
/**
|
||||
* Event notifying that a touch point has disappeared. id is guaranteed to be
|
||||
* a valid touch point ID. This event removes the touch point.
|
||||
*/
|
||||
struct wlr_input_router_touch_up_event {
|
||||
uint32_t time_msec;
|
||||
int32_t id;
|
||||
|
||||
// The index of the touch point in the input router touch, set
|
||||
// automatically.
|
||||
size_t index;
|
||||
};
|
||||
|
||||
/**
|
||||
* Event notifying that a touch point has been cancelled. id is guaranteed to be
|
||||
* a valid touch point ID. This event removes the touch point.
|
||||
*/
|
||||
struct wlr_input_router_touch_cancel_event {
|
||||
int32_t id;
|
||||
|
||||
// The index of the touch point in the input router touch, set
|
||||
// automatically.
|
||||
size_t index;
|
||||
};
|
||||
|
||||
struct wlr_input_router_touch_frame_event {
|
||||
struct {
|
||||
char unused;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
struct wlr_input_router_touch;
|
||||
|
||||
struct wlr_input_router_touch_interface {
|
||||
struct wlr_input_router_handler_interface base;
|
||||
|
||||
void (*position)(struct wlr_input_router_touch *touch,
|
||||
const struct wlr_input_router_touch_position_event *event);
|
||||
uint32_t (*down)(struct wlr_input_router_touch *touch,
|
||||
const struct wlr_input_router_touch_down_event *event);
|
||||
uint32_t (*up)(struct wlr_input_router_touch *touch,
|
||||
const struct wlr_input_router_touch_up_event *event);
|
||||
void (*cancel)(struct wlr_input_router_touch *touch,
|
||||
const struct wlr_input_router_touch_cancel_event *event);
|
||||
void (*frame)(struct wlr_input_router_touch *touch,
|
||||
const struct wlr_input_router_touch_frame_event *event);
|
||||
};
|
||||
|
||||
struct wlr_input_router_touch_point {
|
||||
int32_t id;
|
||||
|
||||
double x, y;
|
||||
struct wlr_input_router_focus focus;
|
||||
};
|
||||
|
||||
struct wlr_input_router_touch {
|
||||
struct wlr_input_router_handler base;
|
||||
const struct wlr_input_router_touch_interface *impl;
|
||||
|
||||
struct wlr_input_router_touch_point points[WLR_INPUT_ROUTER_MAX_TOUCH_POINTS];
|
||||
size_t n_points;
|
||||
};
|
||||
|
||||
/**
|
||||
* An input router is an object which has keyboard, pointer, and touch event
|
||||
* handler chains.
|
||||
*
|
||||
* Each handler can receive events and send events to the next handler in the
|
||||
* chain. If the function in the handler interface responsible for handling
|
||||
* events of a specific type is NULL, events of that type are automatically
|
||||
* passed along to the next handler.
|
||||
*
|
||||
* When an input event handler is added, it's placed accordingly to its
|
||||
* priority, which must be registered beforehand. The newly added handler copies
|
||||
* the state from the next handler in the chain, if one exists.
|
||||
*/
|
||||
struct wlr_input_router {
|
||||
struct wlr_input_router_keyboard keyboard;
|
||||
struct wlr_input_router_pointer pointer;
|
||||
struct wlr_input_router_touch touch;
|
||||
|
||||
const struct wlr_input_router_interface *impl;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
struct wlr_addon_set addons;
|
||||
|
||||
void *data;
|
||||
};
|
||||
|
||||
/**
|
||||
* An input router focus layer which assigns focus for revelant pointer and
|
||||
* touch events based on position.
|
||||
*/
|
||||
struct wlr_input_router_focus_layer {
|
||||
struct wlr_input_router *router;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
struct {
|
||||
struct wlr_input_router_pointer pointer;
|
||||
struct wlr_input_router_touch touch;
|
||||
|
||||
struct wlr_input_router_focus focus;
|
||||
|
||||
struct wl_listener router_destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
struct wlr_input_router_implicit_grab_layer_touch_point {
|
||||
struct {
|
||||
uint32_t serial;
|
||||
struct wlr_input_router_focus focus;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/**
|
||||
* An input router implicit grab layer which implements implicit grab semantics.
|
||||
* For pointer, it means that the focus is locked if at least one button is
|
||||
* pressed. For touch, it means the focus received with a new touch point always
|
||||
* stays the same.
|
||||
*/
|
||||
struct wlr_input_router_implicit_grab_layer {
|
||||
struct wlr_input_router *router;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
struct {
|
||||
struct wlr_input_router_pointer pointer;
|
||||
struct wlr_input_router_focus pointer_focus;
|
||||
uint32_t pointer_init_button;
|
||||
uint32_t pointer_init_serial;
|
||||
bool pointer_grabbed;
|
||||
|
||||
struct wlr_input_router_touch touch;
|
||||
struct wlr_input_router_implicit_grab_layer_touch_point
|
||||
touch_points[WLR_INPUT_ROUTER_MAX_TOUCH_POINTS];
|
||||
|
||||
struct wl_listener router_destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
void wlr_input_router_init(struct wlr_input_router *router,
|
||||
const struct wlr_input_router_interface *impl);
|
||||
void wlr_input_router_finish(struct wlr_input_router *router);
|
||||
|
||||
void wlr_input_router_focus_init(struct wlr_input_router_focus *focus);
|
||||
void wlr_input_router_focus_finish(struct wlr_input_router_focus *focus);
|
||||
|
||||
bool wlr_input_router_focus_is_none(const struct wlr_input_router_focus *focus);
|
||||
struct wlr_surface *wlr_input_router_focus_get_surface(
|
||||
const struct wlr_input_router_focus *focus);
|
||||
void *wlr_input_router_focus_get_user(const struct wlr_input_router_focus *focus);
|
||||
|
||||
void wlr_input_router_focus_clear(struct wlr_input_router_focus *focus);
|
||||
void wlr_input_router_focus_set_surface(struct wlr_input_router_focus *focus,
|
||||
struct wlr_surface *surface);
|
||||
void wlr_input_router_focus_set_user(struct wlr_input_router_focus *focus,
|
||||
void *user, struct wl_signal *destroy_signal);
|
||||
|
||||
void wlr_input_router_focus_copy(struct wlr_input_router_focus *dst,
|
||||
const struct wlr_input_router_focus *src);
|
||||
|
||||
// TODO: this is only required by the focus layer, remove?
|
||||
void wlr_input_router_at(struct wlr_input_router *router, double x, double y,
|
||||
struct wlr_input_router_focus *focus, double *local_x, double *local_y);
|
||||
|
||||
bool wlr_input_router_get_surface_position(struct wlr_input_router *router,
|
||||
struct wlr_surface *surface, double *x, double *y);
|
||||
|
||||
bool wlr_input_router_register_handler_interface(
|
||||
const struct wlr_input_router_handler_interface *iface,
|
||||
int32_t priority, struct wlr_input_router_handler_priority_list *priority_list);
|
||||
|
||||
void wlr_input_router_handler_init(struct wlr_input_router_handler *handler,
|
||||
struct wlr_input_router_handler *head,
|
||||
const struct wlr_input_router_handler_interface *impl,
|
||||
const struct wlr_input_router_handler_priority_list *priority_list);
|
||||
|
||||
void wlr_input_router_handler_finish(struct wlr_input_router_handler *handler);
|
||||
|
||||
uint32_t wlr_input_router_keyboard_notify_focus(
|
||||
struct wlr_input_router_keyboard *keyboard,
|
||||
const struct wlr_input_router_keyboard_focus_event *event);
|
||||
|
||||
void wlr_input_router_keyboard_notify_device(
|
||||
struct wlr_input_router_keyboard *keyboard,
|
||||
const struct wlr_input_router_keyboard_device_event *event);
|
||||
|
||||
uint32_t wlr_input_router_keyboard_notify_key(
|
||||
struct wlr_input_router_keyboard *keyboard,
|
||||
const struct wlr_input_router_keyboard_key_event *event);
|
||||
|
||||
void wlr_input_router_keyboard_notify_modifiers(
|
||||
struct wlr_input_router_keyboard *keyboard,
|
||||
const struct wlr_input_router_keyboard_modifiers_event *event);
|
||||
|
||||
bool wlr_input_router_keyboard_register_interface(
|
||||
const struct wlr_input_router_keyboard_interface *iface, int32_t priority);
|
||||
|
||||
void wlr_input_router_keyboard_init(
|
||||
struct wlr_input_router_keyboard *handler, struct wlr_input_router *router,
|
||||
const struct wlr_input_router_keyboard_interface *impl);
|
||||
|
||||
void wlr_input_router_keyboard_finish(struct wlr_input_router_keyboard *handler);
|
||||
|
||||
uint32_t wlr_input_router_pointer_notify_position(
|
||||
struct wlr_input_router_pointer *pointer,
|
||||
const struct wlr_input_router_pointer_position_event *event);
|
||||
|
||||
uint32_t wlr_input_router_pointer_notify_button(
|
||||
struct wlr_input_router_pointer *pointer,
|
||||
const struct wlr_input_router_pointer_button_event *event);
|
||||
|
||||
void wlr_input_router_pointer_notify_axis(struct wlr_input_router_pointer *pointer,
|
||||
const struct wlr_input_router_pointer_axis_event *event);
|
||||
|
||||
void wlr_input_router_pointer_notify_frame(struct wlr_input_router_pointer *pointer,
|
||||
const struct wlr_input_router_pointer_frame_event *event);
|
||||
|
||||
uint32_t wlr_input_router_pointer_refresh_position(struct wlr_input_router_pointer *pointer);
|
||||
|
||||
uint32_t wlr_input_router_pointer_clear_focus(struct wlr_input_router_pointer *pointer);
|
||||
|
||||
bool wlr_input_router_pointer_register_interface(
|
||||
const struct wlr_input_router_pointer_interface *iface, int32_t priority);
|
||||
|
||||
void wlr_input_router_pointer_init(struct wlr_input_router_pointer *pointer,
|
||||
struct wlr_input_router *router, const struct wlr_input_router_pointer_interface *impl);
|
||||
void wlr_input_router_pointer_finish(struct wlr_input_router_pointer *pointer);
|
||||
|
||||
void wlr_input_router_touch_notify_position(struct wlr_input_router_touch *touch,
|
||||
const struct wlr_input_router_touch_position_event *event);
|
||||
|
||||
uint32_t wlr_input_router_touch_notify_down(struct wlr_input_router_touch *touch,
|
||||
const struct wlr_input_router_touch_down_event *event);
|
||||
|
||||
uint32_t wlr_input_router_touch_notify_up(struct wlr_input_router_touch *touch,
|
||||
const struct wlr_input_router_touch_up_event *event);
|
||||
|
||||
void wlr_input_router_touch_notify_cancel(struct wlr_input_router_touch *touch,
|
||||
const struct wlr_input_router_touch_cancel_event *event);
|
||||
|
||||
void wlr_input_router_touch_notify_frame(struct wlr_input_router_touch *touch,
|
||||
const struct wlr_input_router_touch_frame_event *event);
|
||||
|
||||
bool wlr_input_router_touch_register_interface(
|
||||
const struct wlr_input_router_touch_interface *iface, int32_t priority);
|
||||
|
||||
void wlr_input_router_touch_init(struct wlr_input_router_touch *touch,
|
||||
struct wlr_input_router *router, const struct wlr_input_router_touch_interface *impl);
|
||||
void wlr_input_router_touch_finish(struct wlr_input_router_touch *touch);
|
||||
|
||||
bool wlr_input_router_focus_layer_register(int32_t priority);
|
||||
|
||||
struct wlr_input_router_focus_layer *wlr_input_router_focus_layer_create(
|
||||
struct wlr_input_router *router);
|
||||
void wlr_input_router_focus_layer_destroy(struct wlr_input_router_focus_layer *layer);
|
||||
|
||||
bool wlr_input_router_implicit_grab_layer_register(int32_t priority);
|
||||
|
||||
struct wlr_input_router_implicit_grab_layer *wlr_input_router_implicit_grab_layer_create(
|
||||
struct wlr_input_router *router);
|
||||
void wlr_input_router_implicit_grab_layer_destroy(
|
||||
struct wlr_input_router_implicit_grab_layer *layer);
|
||||
|
||||
bool wlr_input_router_implicit_grab_layer_validate_pointer_serial(
|
||||
struct wlr_input_router_implicit_grab_layer *layer, struct wlr_surface *origin,
|
||||
uint32_t serial, uint32_t *button);
|
||||
|
||||
bool wlr_input_router_implicit_grab_layer_validate_touch_serial(
|
||||
struct wlr_input_router_implicit_grab_layer *layer, struct wlr_surface *origin,
|
||||
uint32_t serial, int32_t *id);
|
||||
|
||||
#endif
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
#include <wayland-server-core.h>
|
||||
#include <pixman.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_input_router.h>
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
#include "pointer-constraints-unstable-v1-protocol.h"
|
||||
|
||||
|
|
@ -89,6 +90,53 @@ struct wlr_pointer_constraints_v1 {
|
|||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/**
|
||||
* A zwp_pointer_constraints_v1 input router layer which modifiers pointer
|
||||
* position based on the constraint of an active surface.
|
||||
*/
|
||||
struct wlr_pointer_constraints_v1_input_router_layer {
|
||||
struct wlr_input_router *router;
|
||||
struct wlr_pointer_constraints_v1 *constraints;
|
||||
struct wlr_seat *seat;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
|
||||
/**
|
||||
* Emitted when a pointer lock with a cursor hint is unlocked. The
|
||||
* compositor should then warp the pointer to the specified position.
|
||||
*/
|
||||
struct wl_signal cursor_hint;
|
||||
} events;
|
||||
|
||||
struct {
|
||||
struct wlr_input_router_pointer pointer;
|
||||
|
||||
struct wlr_surface *active_surface;
|
||||
struct wlr_pointer_constraint_v1 *active;
|
||||
|
||||
double last_x, last_y;
|
||||
double lock_sx, lock_sy;
|
||||
bool lock_applied;
|
||||
|
||||
struct wl_listener active_surface_destroy;
|
||||
|
||||
struct wl_listener active_destroy;
|
||||
struct wl_listener active_set_region;
|
||||
|
||||
struct wl_listener constraints_destroy;
|
||||
struct wl_listener constraints_new_constraint;
|
||||
|
||||
struct wl_listener router_destroy;
|
||||
struct wl_listener seat_destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
struct wlr_pointer_constraints_v1_input_router_layer_cursor_hint_event {
|
||||
// Global position to warp the pointer to
|
||||
double x, y;
|
||||
};
|
||||
|
||||
struct wlr_pointer_constraints_v1 *wlr_pointer_constraints_v1_create(
|
||||
struct wl_display *display);
|
||||
|
||||
|
|
@ -105,4 +153,17 @@ void wlr_pointer_constraint_v1_send_activated(
|
|||
void wlr_pointer_constraint_v1_send_deactivated(
|
||||
struct wlr_pointer_constraint_v1 *constraint);
|
||||
|
||||
bool wlr_pointer_constraints_v1_input_router_layer_register(int32_t priority);
|
||||
|
||||
struct wlr_pointer_constraints_v1_input_router_layer *
|
||||
wlr_pointer_constraints_v1_input_router_layer_create(
|
||||
struct wlr_input_router *router, struct wlr_pointer_constraints_v1 *constraints,
|
||||
struct wlr_seat *seat);
|
||||
void wlr_pointer_constraints_v1_input_router_layer_destroy(
|
||||
struct wlr_pointer_constraints_v1_input_router_layer *layer);
|
||||
|
||||
void wlr_pointer_constraints_v1_input_router_layer_set_active_surface(
|
||||
struct wlr_pointer_constraints_v1_input_router_layer *layer,
|
||||
struct wlr_surface *surface);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#define WLR_TYPES_WLR_RELATIVE_POINTER_V1_H
|
||||
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/types/wlr_input_router.h>
|
||||
|
||||
/**
|
||||
* This protocol specifies a set of interfaces used for making clients able to
|
||||
|
|
@ -61,6 +62,29 @@ struct wlr_relative_pointer_v1 {
|
|||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/**
|
||||
* A zwp_relative_pointer_v1 input router layer which
|
||||
* zwp_relative_pointer_v1.relative_motion events based on pointer position
|
||||
* events.
|
||||
*/
|
||||
struct wlr_relative_pointer_v1_input_router_layer {
|
||||
struct wlr_input_router *router;
|
||||
struct wlr_relative_pointer_manager_v1 *manager;
|
||||
struct wlr_seat *seat;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
struct {
|
||||
struct wlr_input_router_pointer pointer;
|
||||
|
||||
struct wl_listener router_destroy;
|
||||
struct wl_listener manager_destroy;
|
||||
struct wl_listener seat_destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_manager_v1_create(
|
||||
struct wl_display *display);
|
||||
|
||||
|
|
@ -79,4 +103,13 @@ void wlr_relative_pointer_manager_v1_send_relative_motion(
|
|||
struct wlr_relative_pointer_v1 *wlr_relative_pointer_v1_from_resource(
|
||||
struct wl_resource *resource);
|
||||
|
||||
bool wlr_relative_pointer_v1_input_router_layer_register(int32_t priority);
|
||||
|
||||
struct wlr_relative_pointer_v1_input_router_layer *
|
||||
wlr_relative_pointer_v1_input_router_layer_create(
|
||||
struct wlr_input_router *router, struct wlr_relative_pointer_manager_v1 *manager,
|
||||
struct wlr_seat *seat);
|
||||
void wlr_relative_pointer_v1_input_router_layer_destroy(
|
||||
struct wlr_relative_pointer_v1_input_router_layer *layer);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <time.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/types/wlr_input_router.h>
|
||||
#include <wlr/types/wlr_keyboard.h>
|
||||
#include <wlr/types/wlr_pointer.h>
|
||||
|
||||
|
|
@ -346,6 +347,39 @@ struct wlr_seat_keyboard_focus_change_event {
|
|||
struct wlr_surface *old_surface, *new_surface;
|
||||
};
|
||||
|
||||
struct wlr_seat_input_router_layer_touch_point {
|
||||
struct {
|
||||
struct wlr_seat_client *seat_client;
|
||||
struct wl_listener seat_client_destroy;
|
||||
wl_fixed_t sx, sy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/**
|
||||
* A wl_seat input router layer which sends wl_keyboard, wl_pointer, and
|
||||
* wl_touch events.
|
||||
*/
|
||||
struct wlr_seat_input_router_layer {
|
||||
struct wlr_input_router *router;
|
||||
struct wlr_seat *seat;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
struct {
|
||||
struct wlr_input_router_keyboard keyboard;
|
||||
struct wlr_input_router_pointer pointer;
|
||||
|
||||
struct wlr_input_router_touch touch;
|
||||
struct wlr_seat_input_router_layer_touch_point
|
||||
touch_points[WLR_INPUT_ROUTER_MAX_TOUCH_POINTS];
|
||||
|
||||
struct wl_listener router_destroy;
|
||||
struct wl_listener seat_destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/**
|
||||
* Allocates a new struct wlr_seat and adds a wl_seat global to the display.
|
||||
*/
|
||||
|
|
@ -762,4 +796,11 @@ struct wlr_seat_client *wlr_seat_client_from_pointer_resource(
|
|||
*/
|
||||
bool wlr_surface_accepts_touch(struct wlr_surface *surface, struct wlr_seat *wlr_seat);
|
||||
|
||||
bool wlr_seat_input_router_layer_register(int32_t priority);
|
||||
|
||||
struct wlr_seat_input_router_layer *wlr_seat_input_router_layer_create(
|
||||
struct wlr_input_router *router, struct wlr_seat *seat);
|
||||
void wlr_seat_input_router_layer_destroy(struct wlr_seat_input_router_layer *layer);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#define WLR_TYPES_WLR_TEXT_INPUT_V3_H
|
||||
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/types/wlr_input_router.h>
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
#include <wlr/util/box.h>
|
||||
|
||||
|
|
@ -83,6 +84,40 @@ struct wlr_text_input_manager_v3 {
|
|||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/**
|
||||
* A zwp_text_input_v3 input router layer which synchronizes focuses of text
|
||||
* inputs to the keyboard focus and tracks the currently active text input.
|
||||
*/
|
||||
struct wlr_text_input_v3_input_router_layer {
|
||||
struct wlr_input_router *router;
|
||||
struct wlr_text_input_manager_v3 *manager;
|
||||
struct wlr_seat *seat;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
|
||||
// struct wlr_text_input_v3_input_router_layer_set_active_event
|
||||
struct wl_signal set_active_text_input;
|
||||
} events;
|
||||
|
||||
struct {
|
||||
struct wlr_input_router_keyboard keyboard;
|
||||
|
||||
struct wl_list text_inputs;
|
||||
struct wlr_text_input_v3 *active_text_input;
|
||||
|
||||
struct wl_listener manager_destroy;
|
||||
struct wl_listener manager_text_input;
|
||||
|
||||
struct wl_listener router_destroy;
|
||||
struct wl_listener seat_destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
struct wlr_text_input_v3_input_router_layer_set_active_event {
|
||||
struct wlr_text_input_v3 *active_text_input;
|
||||
};
|
||||
|
||||
struct wlr_text_input_manager_v3 *wlr_text_input_manager_v3_create(
|
||||
struct wl_display *wl_display);
|
||||
|
||||
|
|
@ -100,4 +135,12 @@ void wlr_text_input_v3_send_delete_surrounding_text(
|
|||
uint32_t after_length);
|
||||
void wlr_text_input_v3_send_done(struct wlr_text_input_v3 *text_input);
|
||||
|
||||
bool wlr_text_input_v3_input_router_layer_register(int32_t priority);
|
||||
|
||||
struct wlr_text_input_v3_input_router_layer *wlr_text_input_v3_input_router_layer_create(
|
||||
struct wlr_input_router *router, struct wlr_text_input_manager_v3 *manager,
|
||||
struct wlr_seat *seat);
|
||||
void wlr_text_input_v3_input_router_layer_destroy(
|
||||
struct wlr_text_input_v3_input_router_layer *layer);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ struct wlr_xdg_shell {
|
|||
struct wl_signal new_surface; // struct wlr_xdg_surface
|
||||
struct wl_signal new_toplevel; // struct wlr_xdg_toplevel
|
||||
struct wl_signal new_popup; // struct wlr_xdg_popup
|
||||
struct wl_signal popup_grab; // struct wlr_xdg_shell_popup_grab_event
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
|
|
@ -36,6 +37,12 @@ struct wlr_xdg_shell {
|
|||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
struct wlr_xdg_shell_popup_grab_event {
|
||||
struct wlr_xdg_popup *popup;
|
||||
struct wlr_seat_client *seat_client;
|
||||
uint32_t serial;
|
||||
};
|
||||
|
||||
struct wlr_xdg_client {
|
||||
struct wlr_xdg_shell *shell;
|
||||
struct wl_resource *resource;
|
||||
|
|
@ -340,6 +347,32 @@ struct wlr_xdg_toplevel_show_window_menu_event {
|
|||
int32_t x, y;
|
||||
};
|
||||
|
||||
/**
|
||||
* A input router layer which implements xdg_popup.grab semantics. It is
|
||||
* destroyed automatically when the grab is dismissed.
|
||||
*/
|
||||
struct wlr_xdg_popup_grab_input_router_layer {
|
||||
struct wlr_input_router *router;
|
||||
struct wlr_xdg_popup *popup;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
struct {
|
||||
struct wlr_input_router_keyboard keyboard;
|
||||
struct wlr_input_router_focus keyboard_focus;
|
||||
|
||||
struct wlr_input_router_pointer pointer;
|
||||
|
||||
struct wlr_input_router_touch touch;
|
||||
|
||||
struct wlr_addon router_addon;
|
||||
|
||||
struct wl_listener popup_destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create the xdg_wm_base global with the specified version.
|
||||
*/
|
||||
|
|
@ -580,4 +613,12 @@ void wlr_xdg_surface_for_each_popup_surface(struct wlr_xdg_surface *surface,
|
|||
*/
|
||||
uint32_t wlr_xdg_surface_schedule_configure(struct wlr_xdg_surface *surface);
|
||||
|
||||
bool wlr_xdg_popup_grab_input_router_layer_register(int32_t priority);
|
||||
|
||||
struct wlr_xdg_popup_grab_input_router_layer *wlr_xdg_popup_grab_input_router_layer_get_or_create(
|
||||
struct wlr_input_router *router, struct wlr_xdg_popup *popup);
|
||||
|
||||
void wlr_xdg_popup_grab_input_router_layer_destroy(
|
||||
struct wlr_xdg_popup_grab_input_router_layer *layer);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue