2017-09-23 10:26:01 +02:00
|
|
|
#ifndef WLR_TYPES_WLR_CURSOR_H
|
|
|
|
#define WLR_TYPES_WLR_CURSOR_H
|
|
|
|
|
2017-08-20 22:02:39 +02:00
|
|
|
#include <wayland-server.h>
|
|
|
|
#include <wlr/types/wlr_output.h>
|
|
|
|
#include <wlr/types/wlr_output_layout.h>
|
|
|
|
#include <wlr/types/wlr_input_device.h>
|
2017-08-29 18:08:49 +02:00
|
|
|
#include <wlr/types/wlr_box.h>
|
2017-08-20 22:02:39 +02:00
|
|
|
|
|
|
|
struct wlr_cursor_state;
|
|
|
|
|
|
|
|
struct wlr_cursor {
|
2017-08-29 16:31:39 +02:00
|
|
|
struct wlr_cursor_state *state;
|
2017-09-21 17:38:04 +02:00
|
|
|
double x, y;
|
2017-08-20 22:02:39 +02:00
|
|
|
|
2017-08-29 16:31:39 +02:00
|
|
|
struct {
|
|
|
|
struct wl_signal motion;
|
2017-08-20 22:02:39 +02:00
|
|
|
struct wl_signal motion_absolute;
|
|
|
|
struct wl_signal button;
|
|
|
|
struct wl_signal axis;
|
2017-08-27 17:34:25 +02:00
|
|
|
|
|
|
|
struct wl_signal touch_up;
|
|
|
|
struct wl_signal touch_down;
|
|
|
|
struct wl_signal touch_motion;
|
|
|
|
struct wl_signal touch_cancel;
|
2017-08-28 14:42:39 +02: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 16:31:39 +02:00
|
|
|
} events;
|
2017-08-20 22:02:39 +02:00
|
|
|
};
|
|
|
|
|
2017-08-29 16:42:23 +02:00
|
|
|
struct wlr_cursor *wlr_cursor_create();
|
2017-08-20 22:02:39 +02:00
|
|
|
|
|
|
|
void wlr_cursor_destroy(struct wlr_cursor *cur);
|
|
|
|
|
2017-08-24 16:42:05 +02: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 20:35:55 +02:00
|
|
|
* `dev` may be passed to respect device mapping constraints. If `dev` is NULL,
|
|
|
|
* device mapping constraints will be ignored.
|
|
|
|
*
|
2017-08-24 16:42:05 +02:00
|
|
|
* Returns true when the mouse warp was successful.
|
|
|
|
*/
|
2017-08-24 20:35:55 +02:00
|
|
|
bool wlr_cursor_warp(struct wlr_cursor *cur, struct wlr_input_device *dev,
|
2017-10-29 09:09:21 +01:00
|
|
|
double x, double y);
|
2017-08-20 22:02:39 +02:00
|
|
|
|
2017-08-27 23:35:12 +02:00
|
|
|
void wlr_cursor_warp_absolute(struct wlr_cursor *cur,
|
2017-10-29 09:09:21 +01:00
|
|
|
struct wlr_input_device *dev, double x_mm, double y_mm);
|
2017-08-27 23:35:12 +02:00
|
|
|
|
2017-08-24 16:42:05 +02:00
|
|
|
/**
|
|
|
|
* Move the cursor in the direction of the given x and y coordinates.
|
2017-08-24 20:35:55 +02:00
|
|
|
*
|
|
|
|
* `dev` may be passed to respect device mapping constraints. If `dev` is NULL,
|
|
|
|
* device mapping constraints will be ignored.
|
2017-08-24 16:42:05 +02:00
|
|
|
*/
|
2017-08-24 20:35:55 +02:00
|
|
|
void wlr_cursor_move(struct wlr_cursor *cur, struct wlr_input_device *dev,
|
2017-10-29 09:09:21 +01:00
|
|
|
double delta_x, double delta_y);
|
|
|
|
|
2017-11-11 17:27:44 +01: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 09:09:21 +01: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 01:00:03 +01:00
|
|
|
int32_t hotspot_y, float scale);
|
2017-11-11 17:27:44 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the cursor surface. The surface can be committed to update the cursor
|
|
|
|
* image. The surface position is substracted from the hotspot. A NULL surface
|
|
|
|
* commit hides the cursor.
|
|
|
|
*/
|
2017-10-29 09:09:21 +01: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 22:02:39 +02: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 16:31:39 +02:00
|
|
|
struct wlr_input_device *dev);
|
2017-08-20 22:02:39 +02:00
|
|
|
|
|
|
|
void wlr_cursor_detach_input_device(struct wlr_cursor *cur,
|
2017-08-29 16:31:39 +02:00
|
|
|
struct wlr_input_device *dev);
|
2017-08-20 22:02:39 +02: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 09:09:21 +01:00
|
|
|
struct wlr_output_layout *l);
|
2017-08-20 22:02:39 +02: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 16:31:39 +02:00
|
|
|
void wlr_cursor_map_to_output(struct wlr_cursor *cur,
|
2017-10-29 09:09:21 +01:00
|
|
|
struct wlr_output *output);
|
2017-08-20 22:02:39 +02: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 09:09:21 +01:00
|
|
|
struct wlr_input_device *dev, struct wlr_output *output);
|
2017-08-20 22:02:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps this cursor to an arbitrary region on the associated wlr_output_layout.
|
|
|
|
*/
|
2017-08-29 18:08:49 +02:00
|
|
|
void wlr_cursor_map_to_region(struct wlr_cursor *cur, struct wlr_box *box);
|
2017-08-20 22:02:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps inputs from this input device to an arbitrary region on the associated
|
|
|
|
* wlr_output_layout.
|
|
|
|
*/
|
2017-08-25 19:26:13 +02:00
|
|
|
void wlr_cursor_map_input_to_region(struct wlr_cursor *cur,
|
2017-10-29 09:09:21 +01:00
|
|
|
struct wlr_input_device *dev, struct wlr_box *box);
|
2017-08-20 22:02:39 +02:00
|
|
|
|
2017-11-12 17:43:50 +01:00
|
|
|
/**
|
|
|
|
* Convert absolute coordinates to layout coordinates for the device.
|
|
|
|
*/
|
|
|
|
bool wlr_cursor_absolute_to_layout_coords(struct wlr_cursor *cur,
|
|
|
|
struct wlr_input_device *device, double x_mm, double y_mm,
|
|
|
|
double width_mm, double height_mm, double *lx, double *ly);
|
|
|
|
|
2017-08-20 22:02:39 +02:00
|
|
|
#endif
|