2018-07-13 12:40:56 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2017-09-23 08:26:01 +00:00
|
|
|
#ifndef WLR_TYPES_WLR_CURSOR_H
|
|
|
|
#define WLR_TYPES_WLR_CURSOR_H
|
|
|
|
|
2019-07-27 08:53:54 +00:00
|
|
|
#include <wayland-server-core.h>
|
2018-02-12 20:29:23 +00:00
|
|
|
#include <wlr/types/wlr_input_device.h>
|
|
|
|
#include <wlr/types/wlr_output_layout.h>
|
|
|
|
#include <wlr/types/wlr_output.h>
|
2017-08-20 20:02:39 +00:00
|
|
|
|
2018-03-27 13:24:13 +00:00
|
|
|
/**
|
|
|
|
* wlr_cursor implements the behavior of the "cursor", that is, the image on the
|
|
|
|
* screen typically moved about with a mouse or so. It provides tracking for
|
|
|
|
* this in global coordinates, and integrates with wlr_output,
|
|
|
|
* wlr_output_layout, and wlr_input_device. You can use it to abstract multiple
|
|
|
|
* input devices over a single cursor, constrain cursor movement to the usable
|
|
|
|
* area of a wlr_output_layout and communicate position updates to the hardware
|
|
|
|
* cursor, constrain specific input devices to specific outputs or regions of
|
|
|
|
* the screen, and so on.
|
|
|
|
*/
|
|
|
|
|
2021-07-01 20:36:01 +00:00
|
|
|
struct wlr_box;
|
2017-08-20 20:02:39 +00:00
|
|
|
struct wlr_cursor_state;
|
|
|
|
|
|
|
|
struct wlr_cursor {
|
2017-08-29 14:31:39 +00:00
|
|
|
struct wlr_cursor_state *state;
|
2017-09-21 15:38:04 +00:00
|
|
|
double x, y;
|
2017-08-20 20:02:39 +00:00
|
|
|
|
2018-03-27 13:24:13 +00:00
|
|
|
/**
|
|
|
|
* The interpretation of these signals is the responsibility of the
|
|
|
|
* compositor, but some helpers are provided for your benefit. If you
|
|
|
|
* receive a relative motion event, for example, you may want to call
|
|
|
|
* wlr_cursor_move. If you receive an absolute event, call
|
|
|
|
* wlr_cursor_warp_absolute. If you pass an input device into these
|
|
|
|
* functions, it will apply the region/output constraints associated with
|
|
|
|
* that device to the resulting cursor motion. If an output layout is
|
|
|
|
* attached, these functions will constrain the resulting cursor motion to
|
|
|
|
* within the usable space of the output layout.
|
|
|
|
*
|
|
|
|
* Re-broadcasting these signals to, for example, a wlr_seat, is also your
|
|
|
|
* responsibility.
|
|
|
|
*/
|
2017-08-29 14:31:39 +00:00
|
|
|
struct {
|
|
|
|
struct wl_signal motion;
|
2017-08-20 20:02:39 +00:00
|
|
|
struct wl_signal motion_absolute;
|
|
|
|
struct wl_signal button;
|
|
|
|
struct wl_signal axis;
|
2019-01-26 10:04:05 +00:00
|
|
|
struct wl_signal frame;
|
2019-01-25 22:51:38 +00:00
|
|
|
struct wl_signal swipe_begin;
|
|
|
|
struct wl_signal swipe_update;
|
|
|
|
struct wl_signal swipe_end;
|
|
|
|
struct wl_signal pinch_begin;
|
|
|
|
struct wl_signal pinch_update;
|
|
|
|
struct wl_signal pinch_end;
|
2021-07-12 17:51:40 +00:00
|
|
|
struct wl_signal hold_begin;
|
|
|
|
struct wl_signal hold_end;
|
2017-08-27 15:34:25 +00:00
|
|
|
|
|
|
|
struct wl_signal touch_up;
|
|
|
|
struct wl_signal touch_down;
|
|
|
|
struct wl_signal touch_motion;
|
|
|
|
struct wl_signal touch_cancel;
|
2021-06-30 09:40:15 +00:00
|
|
|
struct wl_signal touch_frame;
|
2017-08-28 12:42:39 +00:00
|
|
|
|
|
|
|
struct wl_signal tablet_tool_axis;
|
|
|
|
struct wl_signal tablet_tool_proximity;
|
|
|
|
struct wl_signal tablet_tool_tip;
|
|
|
|
struct wl_signal tablet_tool_button;
|
2017-08-29 14:31:39 +00:00
|
|
|
} events;
|
2018-04-03 19:23:37 +00:00
|
|
|
|
|
|
|
void *data;
|
2017-08-20 20:02:39 +00:00
|
|
|
};
|
|
|
|
|
2019-02-28 15:28:18 +00:00
|
|
|
struct wlr_cursor *wlr_cursor_create(void);
|
2017-08-20 20:02:39 +00:00
|
|
|
|
|
|
|
void wlr_cursor_destroy(struct wlr_cursor *cur);
|
|
|
|
|
2017-08-24 14:42:05 +00:00
|
|
|
/**
|
|
|
|
* Warp the cursor to the given x and y in layout coordinates. If x and y are
|
|
|
|
* out of the layout boundaries or constraints, no warp will happen.
|
|
|
|
*
|
2017-08-24 18:35:55 +00:00
|
|
|
* `dev` may be passed to respect device mapping constraints. If `dev` is NULL,
|
|
|
|
* device mapping constraints will be ignored.
|
|
|
|
*
|
2018-04-27 16:26:33 +00:00
|
|
|
* Returns true when the cursor warp was successful.
|
2017-08-24 14:42:05 +00:00
|
|
|
*/
|
2017-08-24 18:35:55 +00:00
|
|
|
bool wlr_cursor_warp(struct wlr_cursor *cur, struct wlr_input_device *dev,
|
2018-04-27 16:26:33 +00:00
|
|
|
double lx, double ly);
|
2017-08-20 20:02:39 +00:00
|
|
|
|
2018-04-27 16:26:33 +00:00
|
|
|
/**
|
|
|
|
* Convert absolute 0..1 coordinates to layout coordinates.
|
|
|
|
*
|
|
|
|
* `dev` may be passed to respect device mapping constraints. If `dev` is NULL,
|
|
|
|
* device mapping constraints will be ignored.
|
|
|
|
*/
|
|
|
|
void wlr_cursor_absolute_to_layout_coords(struct wlr_cursor *cur,
|
|
|
|
struct wlr_input_device *dev, double x, double y, double *lx, double *ly);
|
|
|
|
|
2018-08-10 16:19:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Warp the cursor to the given x and y coordinates. If the given point is out
|
|
|
|
* of the layout boundaries or constraints, the closest point will be used.
|
|
|
|
* If one coordinate is NAN, it will be ignored.
|
|
|
|
*
|
|
|
|
* `dev` may be passed to respect device mapping constraints. If `dev` is NULL,
|
|
|
|
* device mapping constraints will be ignored.
|
|
|
|
*/
|
|
|
|
void wlr_cursor_warp_closest(struct wlr_cursor *cur,
|
|
|
|
struct wlr_input_device *dev, double x, double y);
|
|
|
|
|
2018-04-27 16:26:33 +00:00
|
|
|
/**
|
|
|
|
* Warp the cursor to the given x and y in absolute 0..1 coordinates. If the
|
|
|
|
* given point is out of the layout boundaries or constraints, the closest point
|
|
|
|
* will be used. If one coordinate is NAN, it will be ignored.
|
|
|
|
*
|
|
|
|
* `dev` may be passed to respect device mapping constraints. If `dev` is NULL,
|
|
|
|
* device mapping constraints will be ignored.
|
|
|
|
*/
|
2017-08-27 21:35:12 +00:00
|
|
|
void wlr_cursor_warp_absolute(struct wlr_cursor *cur,
|
2018-03-28 14:46:50 +00:00
|
|
|
struct wlr_input_device *dev, double x, double y);
|
2017-08-27 21:35:12 +00:00
|
|
|
|
2017-08-24 14:42:05 +00:00
|
|
|
/**
|
2018-04-27 16:26:33 +00:00
|
|
|
* Move the cursor in the direction of the given x and y layout coordinates. If
|
|
|
|
* one coordinate is NAN, it will be ignored.
|
2017-08-24 18:35:55 +00:00
|
|
|
*
|
|
|
|
* `dev` may be passed to respect device mapping constraints. If `dev` is NULL,
|
|
|
|
* device mapping constraints will be ignored.
|
2017-08-24 14:42:05 +00:00
|
|
|
*/
|
2017-08-24 18:35:55 +00:00
|
|
|
void wlr_cursor_move(struct wlr_cursor *cur, struct wlr_input_device *dev,
|
2017-10-29 08:09:21 +00:00
|
|
|
double delta_x, double delta_y);
|
|
|
|
|
2017-11-11 16:27:44 +00:00
|
|
|
/**
|
|
|
|
* Set the cursor image. stride is given in bytes. If pixels is NULL, hides the
|
|
|
|
* cursor.
|
|
|
|
*
|
|
|
|
* If scale isn't zero, the image is only set on outputs having the provided
|
|
|
|
* scale.
|
|
|
|
*/
|
2017-10-29 08:09:21 +00:00
|
|
|
void wlr_cursor_set_image(struct wlr_cursor *cur, const uint8_t *pixels,
|
|
|
|
int32_t stride, uint32_t width, uint32_t height, int32_t hotspot_x,
|
2017-12-15 00:00:03 +00:00
|
|
|
int32_t hotspot_y, float scale);
|
2017-11-11 16:27:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the cursor surface. The surface can be committed to update the cursor
|
2018-05-03 20:59:43 +00:00
|
|
|
* image. The surface position is subtracted from the hotspot. A NULL surface
|
2017-11-11 16:27:44 +00:00
|
|
|
* commit hides the cursor.
|
|
|
|
*/
|
2017-10-29 08:09:21 +00:00
|
|
|
void wlr_cursor_set_surface(struct wlr_cursor *cur, struct wlr_surface *surface,
|
|
|
|
int32_t hotspot_x, int32_t hotspot_y);
|
2017-08-20 20:02:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Attaches this input device to this cursor. The input device must be one of:
|
|
|
|
*
|
|
|
|
* - WLR_INPUT_DEVICE_POINTER
|
|
|
|
* - WLR_INPUT_DEVICE_TOUCH
|
|
|
|
* - WLR_INPUT_DEVICE_TABLET_TOOL
|
|
|
|
*/
|
|
|
|
void wlr_cursor_attach_input_device(struct wlr_cursor *cur,
|
2017-08-29 14:31:39 +00:00
|
|
|
struct wlr_input_device *dev);
|
2017-08-20 20:02:39 +00:00
|
|
|
|
|
|
|
void wlr_cursor_detach_input_device(struct wlr_cursor *cur,
|
2017-08-29 14:31:39 +00:00
|
|
|
struct wlr_input_device *dev);
|
2017-08-20 20:02:39 +00:00
|
|
|
/**
|
|
|
|
* Uses the given layout to establish the boundaries and movement semantics of
|
|
|
|
* this cursor. Cursors without an output layout allow infinite movement in any
|
|
|
|
* direction and do not support absolute input events.
|
|
|
|
*/
|
|
|
|
void wlr_cursor_attach_output_layout(struct wlr_cursor *cur,
|
2017-10-29 08:09:21 +00:00
|
|
|
struct wlr_output_layout *l);
|
2017-08-20 20:02:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Attaches this cursor to the given output, which must be among the outputs in
|
|
|
|
* the current output_layout for this cursor. This call is invalid for a cursor
|
|
|
|
* without an associated output layout.
|
|
|
|
*/
|
2017-08-29 14:31:39 +00:00
|
|
|
void wlr_cursor_map_to_output(struct wlr_cursor *cur,
|
2017-10-29 08:09:21 +00:00
|
|
|
struct wlr_output *output);
|
2017-08-20 20:02:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps all input from a specific input device to a given output. The input
|
|
|
|
* device must be attached to this cursor and the output must be among the
|
|
|
|
* outputs in the attached output layout.
|
|
|
|
*/
|
|
|
|
void wlr_cursor_map_input_to_output(struct wlr_cursor *cur,
|
2017-10-29 08:09:21 +00:00
|
|
|
struct wlr_input_device *dev, struct wlr_output *output);
|
2017-08-20 20:02:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps this cursor to an arbitrary region on the associated wlr_output_layout.
|
|
|
|
*/
|
2017-08-29 16:08:49 +00:00
|
|
|
void wlr_cursor_map_to_region(struct wlr_cursor *cur, struct wlr_box *box);
|
2017-08-20 20:02:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps inputs from this input device to an arbitrary region on the associated
|
|
|
|
* wlr_output_layout.
|
|
|
|
*/
|
2017-08-25 17:26:13 +00:00
|
|
|
void wlr_cursor_map_input_to_region(struct wlr_cursor *cur,
|
2017-10-29 08:09:21 +00:00
|
|
|
struct wlr_input_device *dev, struct wlr_box *box);
|
2017-08-20 20:02:39 +00:00
|
|
|
|
|
|
|
#endif
|