wlroots/include/wlr/types/wlr_seat.h

113 lines
3.1 KiB
C
Raw Normal View History

2017-08-16 12:50:43 +00:00
#ifndef _WLR_TYPES_SEAT_H
#define _WLR_TYPES_SEAT_H
2017-09-20 11:32:28 +00:00
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_input_device.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 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-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 focus_surface_destroy_listener;
struct wl_listener focus_resource_destroy_listener;
};
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;
char *name;
uint32_t capabilities;
struct wlr_data_device *data_device;
2017-08-16 12:50:43 +00:00
2017-09-20 11:32:28 +00:00
struct wlr_seat_pointer_state pointer_state;
2017-08-16 12:50:43 +00:00
struct {
struct wl_signal client_bound;
struct wl_signal client_unbound;
struct wl_signal keyboard_bound;
2017-08-16 12:50:43 +00:00
} events;
void *data;
};
/**
* 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.
*/
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
* motion event are surface-local.
*/
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
* button event are surface-local.
*/
void wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
uint32_t button, enum wlr_button_state state);
2017-08-16 12:50:43 +00:00
#endif