wlroots/include/wlr/types/wlr_seat.h

327 lines
10 KiB
C
Raw Normal View History

#ifndef WLR_TYPES_WLR_SEAT_H
#define WLR_TYPES_WLR_SEAT_H
2017-09-20 11:32:28 +00:00
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_keyboard.h>
2017-08-16 12:50:43 +00:00
#include <wayland-server.h>
/**
* Contains state for a single client's bound wl_seat resource and can be used
* to issue input events to that client. The lifetime of these objects is
* managed by wlr_seat; some may be NULL.
*/
struct wlr_seat_handle {
struct wl_resource *wl_resource;
struct wlr_seat *wlr_seat;
struct wlr_seat_keyboard *seat_keyboard;
2017-08-16 12:50:43 +00:00
struct wl_resource *pointer;
struct wl_resource *keyboard;
struct wl_resource *touch;
struct wl_resource *data_device;
2017-08-16 12:50:43 +00:00
struct wl_list link;
};
2017-10-05 17:28:26 +00:00
struct wlr_seat_pointer_grab;
struct wlr_pointer_grab_interface {
void (*enter)(struct wlr_seat_pointer_grab *grab,
struct wlr_surface *surface, double sx, double sy);
void (*motion)(struct wlr_seat_pointer_grab *grab, uint32_t time,
double sx, double sy);
uint32_t (*button)(struct wlr_seat_pointer_grab *grab, uint32_t time,
uint32_t button, uint32_t state);
void (*axis)(struct wlr_seat_pointer_grab *grab, uint32_t time,
enum wlr_axis_orientation orientation, double value);
void (*cancel)(struct wlr_seat_pointer_grab *grab);
};
2017-10-07 15:02:11 +00:00
struct wlr_seat_keyboard_grab;
struct wlr_keyboard_grab_interface {
void (*enter)(struct wlr_seat_keyboard_grab *grab, struct wlr_surface *surface);
void (*key)(struct wlr_seat_keyboard_grab *grab, uint32_t time,
uint32_t key, uint32_t state);
void (*modifiers)(struct wlr_seat_keyboard_grab *grab,
uint32_t mods_depressed, uint32_t mods_latched,
uint32_t mods_locked, uint32_t group);
void (*cancel)(struct wlr_seat_keyboard_grab *grab);
};
/**
* Passed to `wlr_seat_keyboard_start_grab()` to start a grab of the keyboard.
* The grabber is responsible for handling keyboard events for the seat.
*/
struct wlr_seat_keyboard_grab {
const struct wlr_keyboard_grab_interface *interface;
struct wlr_seat *seat;
void *data;
};
2017-10-05 17:28:26 +00:00
/**
* Passed to `wlr_seat_pointer_start_grab()` to start a grab of the pointer. The
* grabber is responsible for handling pointer events for the seat.
*/
struct wlr_seat_pointer_grab {
const struct wlr_pointer_grab_interface *interface;
struct wlr_seat *seat;
void *data;
};
2017-09-20 11:32:28 +00:00
struct wlr_seat_pointer_state {
struct wlr_seat *wlr_seat;
struct wlr_seat_handle *focused_handle;
struct wlr_surface *focused_surface;
struct wl_listener surface_destroy;
struct wl_listener resource_destroy;
2017-10-05 17:28:26 +00:00
struct wlr_seat_pointer_grab *grab;
struct wlr_seat_pointer_grab *default_grab;
2017-09-20 11:32:28 +00:00
};
struct wlr_seat_keyboard {
struct wlr_seat *seat;
struct wlr_keyboard *keyboard;
struct wl_listener key;
struct wl_listener modifiers;
struct wl_listener keymap;
struct wl_listener destroy;
struct wl_list link;
};
2017-09-22 20:07:00 +00:00
struct wlr_seat_keyboard_state {
struct wlr_seat *wlr_seat;
struct wlr_seat_handle *focused_handle;
struct wlr_surface *focused_surface;
2017-09-25 12:29:35 +00:00
struct wl_listener surface_destroy;
struct wl_listener resource_destroy;
2017-10-07 15:02:11 +00:00
struct wlr_seat_keyboard_grab *grab;
struct wlr_seat_keyboard_grab *default_grab;
2017-09-22 20:07:00 +00:00
};
2017-08-16 12:50:43 +00:00
struct wlr_seat {
struct wl_global *wl_global;
2017-09-20 11:32:28 +00:00
struct wl_display *display;
2017-08-16 12:50:43 +00:00
struct wl_list handles;
struct wl_list keyboards;
2017-08-16 12:50:43 +00:00
char *name;
uint32_t capabilities;
2017-10-11 19:48:40 +00:00
struct wlr_data_device *data_device; // TODO needed?
struct wlr_data_source *selection_source;
uint32_t selection_serial;
2017-08-16 12:50:43 +00:00
2017-09-20 11:32:28 +00:00
struct wlr_seat_pointer_state pointer_state;
2017-09-22 20:07:00 +00:00
struct wlr_seat_keyboard_state keyboard_state;
2017-09-20 11:32:28 +00:00
2017-08-16 12:50:43 +00:00
struct {
struct wl_signal client_bound;
struct wl_signal client_unbound;
2017-10-06 11:32:59 +00:00
struct wl_signal pointer_grab_begin;
struct wl_signal pointer_grab_end;
2017-10-07 15:02:11 +00:00
struct wl_signal keyboard_grab_begin;
struct wl_signal keyboard_grab_end;
2017-10-05 11:11:51 +00:00
struct wl_signal request_set_cursor;
2017-08-16 12:50:43 +00:00
} events;
void *data;
};
2017-10-05 11:11:51 +00:00
struct wlr_seat_pointer_request_set_cursor_event {
struct wl_client *client;
struct wlr_seat_handle *seat_handle;
struct wlr_surface *surface;
int32_t hotspot_x, hotspot_y;
};
2017-08-16 12:50:43 +00:00
/**
* Allocates a new wlr_seat and adds a wl_seat global to the display.
*/
struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name);
/**
* Destroys a wlr_seat and removes its wl_seat global.
*/
void wlr_seat_destroy(struct wlr_seat *wlr_seat);
/**
* Gets a wlr_seat_handle for the specified client, or returns NULL if no
* handle is bound for that client.
*/
struct wlr_seat_handle *wlr_seat_handle_for_client(struct wlr_seat *wlr_seat,
struct wl_client *client);
/**
* Updates the capabilities available on this seat.
* Will automatically send them to all clients.
2017-08-16 12:50:43 +00:00
*/
2017-09-19 19:38:06 +00:00
void wlr_seat_set_capabilities(struct wlr_seat *wlr_seat,
uint32_t capabilities);
2017-08-16 12:50:43 +00:00
/**
* Updates the name of this seat.
* Will automatically send it to all clients.
2017-08-16 12:50:43 +00:00
*/
void wlr_seat_set_name(struct wlr_seat *wlr_seat, const char *name);
2017-09-20 11:32:28 +00:00
/**
* Whether or not the surface has pointer focus
*/
bool wlr_seat_pointer_surface_has_focus(struct wlr_seat *wlr_seat,
struct wlr_surface *surface);
/**
* Send a pointer enter event to the given surface and consider it to be the
* focused surface for the pointer. This will send a leave event to the last
* surface that was entered. Coordinates for the enter event are surface-local.
2017-10-05 17:28:26 +00:00
* Compositor should use `wlr_seat_pointer_notify_enter()` to change pointer
* focus to respect pointer grabs.
2017-09-20 11:32:28 +00:00
*/
void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
2017-09-21 15:38:04 +00:00
struct wlr_surface *surface, double sx, double sy);
2017-09-20 11:32:28 +00:00
/**
* Clear the focused surface for the pointer and leave all entered surfaces.
*/
void wlr_seat_pointer_clear_focus(struct wlr_seat *wlr_seat);
/**
* Send a motion event to the surface with pointer focus. Coordinates for the
2017-10-05 17:28:26 +00:00
* motion event are surface-local. Compositors should use
* `wlr_seat_pointer_notify_motion()` to send motion events to respect pointer
* grabs.
2017-09-20 11:32:28 +00:00
*/
void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
2017-09-21 15:38:04 +00:00
double sx, double sy);
2017-09-20 11:32:28 +00:00
/**
* Send a button event to the surface with pointer focus. Coordinates for the
2017-10-05 17:28:26 +00:00
* button event are surface-local. Returns the serial. Compositors should use
* `wlr_seat_pointer_notify_button()` to send button events to respect pointer
* grabs.
2017-09-20 11:32:28 +00:00
*/
2017-09-22 15:11:11 +00:00
uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
uint32_t button, uint32_t state);
2017-09-20 11:32:28 +00:00
2017-10-05 17:28:26 +00:00
/**
* Send an axis event to the surface with pointer focus. Compositors should use
* `wlr_seat_pointer_notify_axis()` to send axis events to respect pointer
* grabs.
**/
void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time,
enum wlr_axis_orientation orientation, double value);
2017-10-05 17:28:26 +00:00
/**
* Start a grab of the pointer of this seat. The grabber is responsible for
* handling all pointer events until the grab ends.
*/
void wlr_seat_pointer_start_grab(struct wlr_seat *wlr_seat,
struct wlr_seat_pointer_grab *grab);
/**
* End the grab of the pointer of this seat. This reverts the grab back to the
* default grab for the pointer.
*/
void wlr_seat_pointer_end_grab(struct wlr_seat *wlr_seat);
/**
* Notify the seat of a pointer enter event to the given surface and request it to be the
* focused surface for the pointer. Pass surface-local coordinates where the
* enter occurred.
*/
void wlr_seat_pointer_notify_enter(struct wlr_seat *wlr_seat,
struct wlr_surface *surface, double sx, double sy);
/**
* Notify the seat of motion over the given surface. Pass surface-local
* coordinates where the pointer motion occurred.
*/
void wlr_seat_pointer_notify_motion(struct wlr_seat *wlr_seat, uint32_t time,
double sx, double sy);
/**
* Notify the seat that a button has been pressed. Returns the serial of the
* button press or zero if no button press was sent.
*/
uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat,
uint32_t time, uint32_t button, uint32_t state);
/**
* Notify the seat of an axis event.
*/
void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time,
enum wlr_axis_orientation orientation, double value);
/**
* Attaches this keyboard to the seat. Key events from this keyboard will be
* propegated to the focused client.
*/
void wlr_seat_attach_keyboard(struct wlr_seat *seat,
struct wlr_input_device *dev);
/**
* Detaches this keyboard from the seat. This is done automatically when the
* keyboard is destroyed; you only need to use this if you want to remove it for
* some other reason.
*/
void wlr_seat_detach_keyboard(struct wlr_seat *seat, struct wlr_keyboard *kb);
2017-10-07 15:02:11 +00:00
/**
* Start a grab of the keyboard of this seat. The grabber is responsible for
* handling all keyboard events until the grab ends.
*/
void wlr_seat_keyboard_start_grab(struct wlr_seat *wlr_seat,
struct wlr_seat_keyboard_grab *grab);
/**
* End the grab of the keyboard of this seat. This reverts the grab back to the
* default grab for the keyboard.
*/
void wlr_seat_keyboard_end_grab(struct wlr_seat *wlr_seat);
/**
* Send the keyboard key to focused keyboard resources. Compositors should use
* `wlr_seat_attach_keyboard()` to automatically handle keyboard events.
*/
void wlr_seat_keyboard_send_key(struct wlr_seat *seat, uint32_t time,
uint32_t key, uint32_t state);
/**
* Send the modifier state to focused keyboard resources. Compositors should use
* `wlr_seat_attach_keyboard()` to automatically handle keyboard events.
*/
void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat,
uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked,
uint32_t group);
/**
* Notify the seat that the keyboard focus has changed and request it to be the
* focused surface for this keyboard. Defers to any current grab of the seat's
* keyboard.
*/
void wlr_seat_keyboard_notify_enter(struct wlr_seat *wlr_seat,
struct wlr_surface *surface);
2017-09-22 20:07:00 +00:00
/**
2017-09-25 12:29:35 +00:00
* Send a keyboard enter event to the given surface and consider it to be the
* focused surface for the keyboard. This will send a leave event to the last
2017-10-07 15:02:11 +00:00
* surface that was entered. Compositors should use
* `wlr_seat_keyboard_notify_enter()` to change keyboard focus to respect
* keyboard grabs.
2017-09-22 20:07:00 +00:00
*/
2017-09-25 12:29:35 +00:00
void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat,
struct wlr_surface *surface);
2017-09-22 20:07:00 +00:00
2017-09-22 21:09:47 +00:00
/**
2017-09-25 12:29:35 +00:00
* Clear the focused surface for the keyboard and leave all entered surfaces.
2017-09-22 21:09:47 +00:00
*/
2017-09-25 12:29:35 +00:00
void wlr_seat_keyboard_clear_focus(struct wlr_seat *wlr_seat);
2017-09-22 21:09:47 +00:00
2017-09-25 12:29:35 +00:00
// TODO: May be useful to be able to simulate keyboard input events
2017-09-23 17:21:57 +00:00
2017-08-16 12:50:43 +00:00
#endif