mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
commit
6daf9e9ab2
30 changed files with 1957 additions and 281 deletions
20
include/wlr/types/wlr_box.h
Normal file
20
include/wlr/types/wlr_box.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef _WLR_TYPES_GEOMETRY_H
|
||||
#define _WLR_TYPES_GEOMETRY_H
|
||||
#include <stdbool.h>
|
||||
|
||||
struct wlr_box {
|
||||
int x, y;
|
||||
int width, height;
|
||||
};
|
||||
|
||||
void wlr_box_closest_point(struct wlr_box *box, double x, double y,
|
||||
double *dest_x, double *dest_y);
|
||||
|
||||
bool wlr_box_intersection(struct wlr_box *box_a,
|
||||
struct wlr_box *box_b, struct wlr_box **dest);
|
||||
|
||||
bool wlr_box_contains_point(struct wlr_box *box, double x, double y);
|
||||
|
||||
bool wlr_box_empty(struct wlr_box *box);
|
||||
|
||||
#endif
|
||||
112
include/wlr/types/wlr_cursor.h
Normal file
112
include/wlr/types/wlr_cursor.h
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
#ifndef _WLR_TYPES_CURSOR_H
|
||||
#define _WLR_TYPES_CURSOR_H
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/types/wlr_box.h>
|
||||
#include <wlr/xcursor.h>
|
||||
|
||||
struct wlr_cursor_state;
|
||||
|
||||
struct wlr_cursor {
|
||||
struct wlr_cursor_state *state;
|
||||
int x, y;
|
||||
|
||||
struct {
|
||||
struct wl_signal motion;
|
||||
struct wl_signal motion_absolute;
|
||||
struct wl_signal button;
|
||||
struct wl_signal axis;
|
||||
|
||||
struct wl_signal touch_up;
|
||||
struct wl_signal touch_down;
|
||||
struct wl_signal touch_motion;
|
||||
struct wl_signal touch_cancel;
|
||||
|
||||
struct wl_signal tablet_tool_axis;
|
||||
struct wl_signal tablet_tool_proximity;
|
||||
struct wl_signal tablet_tool_tip;
|
||||
struct wl_signal tablet_tool_button;
|
||||
} events;
|
||||
};
|
||||
|
||||
struct wlr_cursor *wlr_cursor_create();
|
||||
|
||||
void wlr_cursor_destroy(struct wlr_cursor *cur);
|
||||
|
||||
void wlr_cursor_set_xcursor(struct wlr_cursor *cur, struct wlr_xcursor *xcur);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* `dev` may be passed to respect device mapping constraints. If `dev` is NULL,
|
||||
* device mapping constraints will be ignored.
|
||||
*
|
||||
* 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);
|
||||
|
||||
void wlr_cursor_warp_absolute(struct wlr_cursor *cur,
|
||||
struct wlr_input_device *dev, double x_mm, double y_mm);
|
||||
|
||||
/**
|
||||
* Move the cursor in the direction of the given x and y coordinates.
|
||||
*
|
||||
* `dev` may be passed to respect device mapping constraints. If `dev` is NULL,
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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,
|
||||
struct wlr_input_device *dev);
|
||||
|
||||
void wlr_cursor_detach_input_device(struct wlr_cursor *cur,
|
||||
struct wlr_input_device *dev);
|
||||
/**
|
||||
* 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,
|
||||
struct wlr_output_layout *l);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void wlr_cursor_map_to_output(struct wlr_cursor *cur,
|
||||
struct wlr_output *output);
|
||||
|
||||
/**
|
||||
* 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,
|
||||
struct wlr_input_device *dev, struct wlr_output *output);
|
||||
|
||||
/**
|
||||
* Maps this cursor to an arbitrary region on the associated wlr_output_layout.
|
||||
*/
|
||||
void wlr_cursor_map_to_region(struct wlr_cursor *cur, struct wlr_box *box);
|
||||
|
||||
/**
|
||||
* Maps inputs from this input device to an arbitrary region on the associated
|
||||
* wlr_output_layout.
|
||||
*/
|
||||
void wlr_cursor_map_input_to_region(struct wlr_cursor *cur,
|
||||
struct wlr_input_device *dev, struct wlr_box *box);
|
||||
|
||||
#endif
|
||||
|
|
@ -40,6 +40,10 @@ struct wlr_input_device {
|
|||
struct wlr_tablet_pad *tablet_pad;
|
||||
};
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
void *data;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,20 @@
|
|||
#include <wayland-util.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
struct wlr_output_layout_state;
|
||||
|
||||
struct wlr_output_layout {
|
||||
struct wl_list outputs;
|
||||
struct wl_list outputs;
|
||||
struct wlr_output_layout_state *state;
|
||||
};
|
||||
|
||||
struct wlr_output_layout_output_state;
|
||||
|
||||
struct wlr_output_layout_output {
|
||||
struct wlr_output *output;
|
||||
int x, y;
|
||||
struct wl_list link;
|
||||
struct wlr_output *output;
|
||||
int x, y;
|
||||
struct wl_list link;
|
||||
struct wlr_output_layout_output_state *state;
|
||||
};
|
||||
|
||||
struct wlr_output_layout *wlr_output_layout_init();
|
||||
|
|
@ -38,7 +44,7 @@ void wlr_output_layout_remove(struct wlr_output_layout *layout,
|
|||
* coordinates relative to the given reference output.
|
||||
*/
|
||||
void wlr_output_layout_output_coords(struct wlr_output_layout *layout,
|
||||
struct wlr_output *reference, int *x, int *y);
|
||||
struct wlr_output *reference, double *x, double *y);
|
||||
|
||||
bool wlr_output_layout_contains_point(struct wlr_output_layout *layout,
|
||||
struct wlr_output *reference, int x, int y);
|
||||
|
|
@ -46,4 +52,19 @@ bool wlr_output_layout_contains_point(struct wlr_output_layout *layout,
|
|||
bool wlr_output_layout_intersects(struct wlr_output_layout *layout,
|
||||
struct wlr_output *reference, int x1, int y1, int x2, int y2);
|
||||
|
||||
/**
|
||||
* Get the closest point on this layout from the given point from the reference
|
||||
* output. If reference is NULL, gets the closest point from the entire layout.
|
||||
*/
|
||||
void wlr_output_layout_closest_point(struct wlr_output_layout *layout,
|
||||
struct wlr_output *reference, double x, double y, double *dest_x,
|
||||
double *dest_y);
|
||||
|
||||
/**
|
||||
* Get the box of the layout for the given reference output. If `reference`
|
||||
* is NULL, the box will be for the extents of the entire layout.
|
||||
*/
|
||||
struct wlr_box *wlr_output_layout_get_box(
|
||||
struct wlr_output_layout *layout, struct wlr_output *reference);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -20,12 +20,14 @@ struct wlr_pointer {
|
|||
};
|
||||
|
||||
struct wlr_event_pointer_motion {
|
||||
struct wlr_input_device *device;
|
||||
uint32_t time_sec;
|
||||
uint64_t time_usec;
|
||||
double delta_x, delta_y;
|
||||
};
|
||||
|
||||
struct wlr_event_pointer_motion_absolute {
|
||||
struct wlr_input_device *device;
|
||||
uint32_t time_sec;
|
||||
uint64_t time_usec;
|
||||
double x_mm, y_mm;
|
||||
|
|
@ -33,6 +35,7 @@ struct wlr_event_pointer_motion_absolute {
|
|||
};
|
||||
|
||||
struct wlr_event_pointer_button {
|
||||
struct wlr_input_device *device;
|
||||
uint32_t time_sec;
|
||||
uint64_t time_usec;
|
||||
uint32_t button;
|
||||
|
|
@ -52,6 +55,7 @@ enum wlr_axis_orientation {
|
|||
};
|
||||
|
||||
struct wlr_event_pointer_axis {
|
||||
struct wlr_input_device *device;
|
||||
uint32_t time_sec;
|
||||
uint64_t time_usec;
|
||||
enum wlr_axis_source source;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ enum wlr_tablet_tool_axes {
|
|||
};
|
||||
|
||||
struct wlr_event_tablet_tool_axis {
|
||||
struct wlr_input_device *device;
|
||||
uint32_t time_sec;
|
||||
uint64_t time_usec;
|
||||
uint32_t updated_axes;
|
||||
|
|
@ -51,9 +52,10 @@ enum wlr_tablet_tool_proximity_state {
|
|||
};
|
||||
|
||||
struct wlr_event_tablet_tool_proximity {
|
||||
struct wlr_input_device *device;
|
||||
uint32_t time_sec;
|
||||
uint64_t time_usec;
|
||||
double x, y;
|
||||
double x_mm, y_mm;
|
||||
double width_mm, height_mm;
|
||||
enum wlr_tablet_tool_proximity_state state;
|
||||
};
|
||||
|
|
@ -64,14 +66,16 @@ enum wlr_tablet_tool_tip_state {
|
|||
};
|
||||
|
||||
struct wlr_event_tablet_tool_tip {
|
||||
struct wlr_input_device *device;
|
||||
uint32_t time_sec;
|
||||
uint64_t time_usec;
|
||||
double x, y;
|
||||
double x_mm, y_mm;
|
||||
double width_mm, height_mm;
|
||||
enum wlr_tablet_tool_tip_state state;
|
||||
};
|
||||
|
||||
struct wlr_event_tablet_tool_button {
|
||||
struct wlr_input_device *device;
|
||||
uint32_t time_sec;
|
||||
uint64_t time_usec;
|
||||
uint32_t button;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ struct wlr_touch {
|
|||
};
|
||||
|
||||
struct wlr_event_touch_down {
|
||||
struct wlr_input_device *device;
|
||||
uint32_t time_sec;
|
||||
uint64_t time_usec;
|
||||
int32_t slot;
|
||||
|
|
@ -27,12 +28,14 @@ struct wlr_event_touch_down {
|
|||
};
|
||||
|
||||
struct wlr_event_touch_up {
|
||||
struct wlr_input_device *device;
|
||||
uint32_t time_sec;
|
||||
uint64_t time_usec;
|
||||
int32_t slot;
|
||||
};
|
||||
|
||||
struct wlr_event_touch_motion {
|
||||
struct wlr_input_device *device;
|
||||
uint32_t time_sec;
|
||||
uint64_t time_usec;
|
||||
int32_t slot;
|
||||
|
|
@ -41,6 +44,7 @@ struct wlr_event_touch_motion {
|
|||
};
|
||||
|
||||
struct wlr_event_touch_cancel {
|
||||
struct wlr_input_device *device;
|
||||
uint32_t time_sec;
|
||||
uint64_t time_usec;
|
||||
int32_t slot;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue