aboutsummaryrefslogtreecommitdiff
path: root/include/wlr
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-08-29 12:12:18 -0500
committerGitHub <noreply@github.com>2017-08-29 12:12:18 -0500
commit6daf9e9ab2bb6e11987d3b2562fc053fd0f489c1 (patch)
tree11b9bbe78deff0e4baa76bd00e1c13d16340ceb9 /include/wlr
parentc46168cf9acd360ae37b4d2a54ed1778f0b89c72 (diff)
parentd9ab631f5d540d67d927e9d0975e2adb782e2e87 (diff)
Merge pull request #120 from acrisci/feature/wlr-cursor
wlr_cursor
Diffstat (limited to 'include/wlr')
-rw-r--r--include/wlr/types/wlr_box.h20
-rw-r--r--include/wlr/types/wlr_cursor.h112
-rw-r--r--include/wlr/types/wlr_input_device.h4
-rw-r--r--include/wlr/types/wlr_output_layout.h31
-rw-r--r--include/wlr/types/wlr_pointer.h4
-rw-r--r--include/wlr/types/wlr_tablet_tool.h8
-rw-r--r--include/wlr/types/wlr_touch.h4
7 files changed, 176 insertions, 7 deletions
diff --git a/include/wlr/types/wlr_box.h b/include/wlr/types/wlr_box.h
new file mode 100644
index 00000000..e2b1ab4e
--- /dev/null
+++ b/include/wlr/types/wlr_box.h
@@ -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
diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h
new file mode 100644
index 00000000..5fc0ec76
--- /dev/null
+++ b/include/wlr/types/wlr_cursor.h
@@ -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
diff --git a/include/wlr/types/wlr_input_device.h b/include/wlr/types/wlr_input_device.h
index 642892ff..5a41ce9d 100644
--- a/include/wlr/types/wlr_input_device.h
+++ b/include/wlr/types/wlr_input_device.h
@@ -40,6 +40,10 @@ struct wlr_input_device {
struct wlr_tablet_pad *tablet_pad;
};
+ struct {
+ struct wl_signal destroy;
+ } events;
+
void *data;
};
diff --git a/include/wlr/types/wlr_output_layout.h b/include/wlr/types/wlr_output_layout.h
index f6a1efdd..b1253eb1 100644
--- a/include/wlr/types/wlr_output_layout.h
+++ b/include/wlr/types/wlr_output_layout.h
@@ -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
diff --git a/include/wlr/types/wlr_pointer.h b/include/wlr/types/wlr_pointer.h
index 13a2d045..9153963a 100644
--- a/include/wlr/types/wlr_pointer.h
+++ b/include/wlr/types/wlr_pointer.h
@@ -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;
diff --git a/include/wlr/types/wlr_tablet_tool.h b/include/wlr/types/wlr_tablet_tool.h
index dcb9c191..9090828a 100644
--- a/include/wlr/types/wlr_tablet_tool.h
+++ b/include/wlr/types/wlr_tablet_tool.h
@@ -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;
diff --git a/include/wlr/types/wlr_touch.h b/include/wlr/types/wlr_touch.h
index 93069fcb..1a27cad3 100644
--- a/include/wlr/types/wlr_touch.h
+++ b/include/wlr/types/wlr_touch.h
@@ -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;