From 1b6c7293608717943a296675b1ab228fed72277c Mon Sep 17 00:00:00 2001 From: emersion Date: Sun, 29 Oct 2017 09:09:21 +0100 Subject: Add wlr_output_cursor --- include/wlr/types/wlr_cursor.h | 20 ++++++++++++------- include/wlr/types/wlr_output.h | 45 ++++++++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 26 deletions(-) (limited to 'include') diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h index e8c13b1d..be4f322f 100644 --- a/include/wlr/types/wlr_cursor.h +++ b/include/wlr/types/wlr_cursor.h @@ -48,10 +48,10 @@ void wlr_cursor_set_xcursor(struct wlr_cursor *cur, struct wlr_xcursor *xcur); * Returns true when the mouse warp was successful. */ bool wlr_cursor_warp(struct wlr_cursor *cur, struct wlr_input_device *dev, - double x, double y); + double x, double y); void wlr_cursor_warp_absolute(struct wlr_cursor *cur, - struct wlr_input_device *dev, double x_mm, double y_mm); + struct wlr_input_device *dev, double x_mm, double y_mm); /** * Move the cursor in the direction of the given x and y coordinates. @@ -60,7 +60,13 @@ void wlr_cursor_warp_absolute(struct wlr_cursor *cur, * device mapping constraints will be ignored. */ void wlr_cursor_move(struct wlr_cursor *cur, struct wlr_input_device *dev, - double delta_x, double delta_y); + double delta_x, double delta_y); + +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, + int32_t hotspot_y); +void wlr_cursor_set_surface(struct wlr_cursor *cur, struct wlr_surface *surface, + int32_t hotspot_x, int32_t hotspot_y); /** * Attaches this input device to this cursor. The input device must be one of: @@ -80,7 +86,7 @@ void wlr_cursor_detach_input_device(struct wlr_cursor *cur, * direction and do not support absolute input events. */ void wlr_cursor_attach_output_layout(struct wlr_cursor *cur, - struct wlr_output_layout *l); + struct wlr_output_layout *l); /** * Attaches this cursor to the given output, which must be among the outputs in @@ -88,7 +94,7 @@ void wlr_cursor_attach_output_layout(struct wlr_cursor *cur, * without an associated output layout. */ void wlr_cursor_map_to_output(struct wlr_cursor *cur, - struct wlr_output *output); + struct wlr_output *output); /** * Maps all input from a specific input device to a given output. The input @@ -96,7 +102,7 @@ void wlr_cursor_map_to_output(struct wlr_cursor *cur, * outputs in the attached output layout. */ void wlr_cursor_map_input_to_output(struct wlr_cursor *cur, - struct wlr_input_device *dev, struct wlr_output *output); + struct wlr_input_device *dev, struct wlr_output *output); /** * Maps this cursor to an arbitrary region on the associated wlr_output_layout. @@ -108,6 +114,6 @@ void wlr_cursor_map_to_region(struct wlr_cursor *cur, struct wlr_box *box); * wlr_output_layout. */ void wlr_cursor_map_input_to_region(struct wlr_cursor *cur, - struct wlr_input_device *dev, struct wlr_box *box); + struct wlr_input_device *dev, struct wlr_box *box); #endif diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 74eb15ed..b6ea3a47 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -12,6 +12,21 @@ struct wlr_output_mode { struct wl_list link; }; +struct wlr_output_cursor { + struct wlr_output *output; + int32_t x, y; + int32_t hotspot_x, hotspot_y; + struct wl_list link; + + struct wlr_renderer *renderer; + struct wlr_texture *texture; + + // only when using a cursor surface + struct wlr_surface *surface; + struct wl_listener surface_commit; + struct wl_listener surface_destroy; +}; + struct wlr_output_impl; struct wlr_output { @@ -44,19 +59,8 @@ struct wlr_output { struct wl_signal destroy; } events; - struct { - bool is_sw; - int32_t x, y; - uint32_t width, height; - int32_t hotspot_x, hotspot_y; - struct wlr_renderer *renderer; - struct wlr_texture *texture; - - // only when using a cursor surface - struct wlr_surface *surface; - struct wl_listener surface_commit; - struct wl_listener surface_destroy; - } cursor; + struct wl_list cursors; // wlr_output_cursor::link + struct wlr_output_cursor *hardware_cursor; // the output position in layout space reported to clients int32_t lx, ly; @@ -72,12 +76,6 @@ bool wlr_output_set_mode(struct wlr_output *output, void wlr_output_transform(struct wlr_output *output, enum wl_output_transform transform); void wlr_output_set_position(struct wlr_output *output, int32_t lx, int32_t ly); -bool wlr_output_set_cursor(struct wlr_output *output, - const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height, - int32_t hotspot_x, int32_t hotspot_y); -void wlr_output_set_cursor_surface(struct wlr_output *output, - struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y); -bool wlr_output_move_cursor(struct wlr_output *output, int x, int y); void wlr_output_destroy(struct wlr_output *output); void wlr_output_effective_resolution(struct wlr_output *output, int *width, int *height); @@ -87,4 +85,13 @@ void wlr_output_set_gamma(struct wlr_output *output, uint32_t size, uint16_t *r, uint16_t *g, uint16_t *b); uint32_t wlr_output_get_gamma_size(struct wlr_output *output); +struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output); +bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor, + const uint8_t *pixels, int32_t stride, uint32_t width, uint32_t height, + int32_t hotspot_x, int32_t hotspot_y); +void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor, + struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y); +bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, int x, int y); +void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor); + #endif -- cgit v1.2.3