aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/rootston/cursor.h41
-rw-r--r--include/rootston/desktop.h2
-rw-r--r--include/rootston/input.h2
-rw-r--r--include/rootston/output.h3
-rw-r--r--include/rootston/seat.h8
-rw-r--r--include/wlr/types/wlr_box.h3
-rw-r--r--include/wlr/types/wlr_cursor.h12
-rw-r--r--include/wlr/types/wlr_pointer_constraints_v1.h102
-rw-r--r--include/wlr/types/wlr_region.h3
-rw-r--r--include/wlr/types/wlr_seat.h15
-rw-r--r--include/wlr/types/wlr_surface.h5
-rw-r--r--include/wlr/util/region.h5
12 files changed, 185 insertions, 16 deletions
diff --git a/include/rootston/cursor.h b/include/rootston/cursor.h
index 2c687a39..b5bb682f 100644
--- a/include/rootston/cursor.h
+++ b/include/rootston/cursor.h
@@ -1,6 +1,7 @@
#ifndef ROOTSTON_CURSOR_H
#define ROOTSTON_CURSOR_H
+#include <wlr/types/wlr_pointer_constraints_v1.h>
#include "rootston/seat.h"
enum roots_cursor_mode {
@@ -14,6 +15,9 @@ struct roots_cursor {
struct roots_seat *seat;
struct wlr_cursor *cursor;
+ struct wlr_pointer_constraint_v1 *active_constraint;
+ pixman_region32_t confine; // invalid if active_constraint == NULL
+
const char *default_xcursor;
enum roots_cursor_mode mode;
@@ -28,6 +32,7 @@ struct roots_cursor {
uint32_t resize_edges;
struct roots_seat_view *pointer_view;
+ struct wlr_surface *wlr_surface;
struct wl_listener motion;
struct wl_listener motion_absolute;
@@ -44,6 +49,10 @@ struct roots_cursor {
struct wl_listener tool_button;
struct wl_listener request_set_cursor;
+
+ struct wl_listener focus_change;
+
+ struct wl_listener constraint_commit;
};
struct roots_cursor *roots_cursor_create(struct roots_seat *seat);
@@ -51,36 +60,46 @@ struct roots_cursor *roots_cursor_create(struct roots_seat *seat);
void roots_cursor_destroy(struct roots_cursor *cursor);
void roots_cursor_handle_motion(struct roots_cursor *cursor,
- struct wlr_event_pointer_motion *event);
+ struct wlr_event_pointer_motion *event);
void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor,
- struct wlr_event_pointer_motion_absolute *event);
+ struct wlr_event_pointer_motion_absolute *event);
void roots_cursor_handle_button(struct roots_cursor *cursor,
- struct wlr_event_pointer_button *event);
+ struct wlr_event_pointer_button *event);
void roots_cursor_handle_axis(struct roots_cursor *cursor,
- struct wlr_event_pointer_axis *event);
+ struct wlr_event_pointer_axis *event);
void roots_cursor_handle_touch_down(struct roots_cursor *cursor,
- struct wlr_event_touch_down *event);
+ struct wlr_event_touch_down *event);
void roots_cursor_handle_touch_up(struct roots_cursor *cursor,
- struct wlr_event_touch_up *event);
+ struct wlr_event_touch_up *event);
void roots_cursor_handle_touch_motion(struct roots_cursor *cursor,
- struct wlr_event_touch_motion *event);
+ struct wlr_event_touch_motion *event);
void roots_cursor_handle_tool_axis(struct roots_cursor *cursor,
- struct wlr_event_tablet_tool_axis *event);
+ struct wlr_event_tablet_tool_axis *event);
void roots_cursor_handle_tool_tip(struct roots_cursor *cursor,
- struct wlr_event_tablet_tool_tip *event);
+ struct wlr_event_tablet_tool_tip *event);
void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor,
- struct wlr_seat_pointer_request_set_cursor_event *event);
+ struct wlr_seat_pointer_request_set_cursor_event *event);
+
+void roots_cursor_handle_focus_change(struct roots_cursor *cursor,
+ struct wlr_seat_pointer_focus_change_event *event);
+
+void roots_cursor_handle_constraint_commit(struct roots_cursor *cursor);
void roots_cursor_update_position(struct roots_cursor *cursor,
- uint32_t time);
+ uint32_t time);
+
+void roots_cursor_update_focus(struct roots_cursor *cursor);
+
+void roots_cursor_constrain(struct roots_cursor *cursor,
+ struct wlr_pointer_constraint_v1 *constraint, double sx, double sy);
#endif
diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h
index 89d8af4a..90851a17 100644
--- a/include/rootston/desktop.h
+++ b/include/rootston/desktop.h
@@ -56,6 +56,7 @@ struct roots_desktop {
struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard;
struct wlr_screencopy_manager_v1 *screencopy;
struct wlr_tablet_manager_v2 *tablet_v2;
+ struct wlr_pointer_constraints_v1 *pointer_constraints;
struct wl_listener new_output;
struct wl_listener layout_change;
@@ -67,6 +68,7 @@ struct roots_desktop {
struct wl_listener input_inhibit_activate;
struct wl_listener input_inhibit_deactivate;
struct wl_listener virtual_keyboard_new;
+ struct wl_listener pointer_constraint;
#ifdef WLR_HAS_XWAYLAND
struct wlr_xwayland *xwayland;
diff --git a/include/rootston/input.h b/include/rootston/input.h
index 2cdb13e6..31810b4d 100644
--- a/include/rootston/input.h
+++ b/include/rootston/input.h
@@ -16,7 +16,7 @@ struct roots_input {
struct wl_listener new_input;
- struct wl_list seats;
+ struct wl_list seats; // roots_seat::link
};
struct roots_input *input_create(struct roots_server *server,
diff --git a/include/rootston/output.h b/include/rootston/output.h
index f78ee81d..69bc5126 100644
--- a/include/rootston/output.h
+++ b/include/rootston/output.h
@@ -28,6 +28,9 @@ struct roots_output {
struct wl_listener damage_destroy;
};
+void rotate_child_position(double *sx, double *sy, double sw, double sh,
+ double pw, double ph, float rotation);
+
void handle_new_output(struct wl_listener *listener, void *data);
struct roots_view;
diff --git a/include/rootston/seat.h b/include/rootston/seat.h
index 8b04e892..7e7ee3e9 100644
--- a/include/rootston/seat.h
+++ b/include/rootston/seat.h
@@ -10,7 +10,7 @@ struct roots_seat {
struct roots_input *input;
struct wlr_seat *seat;
struct roots_cursor *cursor;
- struct wl_list link;
+ struct wl_list link; // roots_input::seats
// coordinates of the first touch point if it exists
int32_t touch_id;
@@ -123,6 +123,12 @@ struct roots_tablet_tool {
struct wl_listener tablet_destroy;
};
+struct roots_pointer_constraint {
+ struct wlr_pointer_constraint_v1 *constraint;
+
+ struct wl_listener destroy;
+};
+
struct roots_seat *roots_seat_create(struct roots_input *input, char *name);
void roots_seat_destroy(struct roots_seat *seat);
diff --git a/include/wlr/types/wlr_box.h b/include/wlr/types/wlr_box.h
index 11a53b56..8e25918b 100644
--- a/include/wlr/types/wlr_box.h
+++ b/include/wlr/types/wlr_box.h
@@ -9,6 +9,7 @@
#ifndef WLR_TYPES_WLR_BOX_H
#define WLR_TYPES_WLR_BOX_H
+#include <pixman.h>
#include <stdbool.h>
#include <wayland-server.h>
@@ -40,4 +41,6 @@ void wlr_box_transform(const struct wlr_box *box,
void wlr_box_rotated_bounds(const struct wlr_box *box, float rotation,
struct wlr_box *dest);
+void wlr_box_from_pixman_box32(const pixman_box32_t box, struct wlr_box *dest);
+
#endif
diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h
index ba582be9..44ced1f0 100644
--- a/include/wlr/types/wlr_cursor.h
+++ b/include/wlr/types/wlr_cursor.h
@@ -91,6 +91,18 @@ bool wlr_cursor_warp(struct wlr_cursor *cur, struct wlr_input_device *dev,
void wlr_cursor_absolute_to_layout_coords(struct wlr_cursor *cur,
struct wlr_input_device *dev, double x, double y, double *lx, double *ly);
+
+/**
+ * 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);
+
/**
* 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
diff --git a/include/wlr/types/wlr_pointer_constraints_v1.h b/include/wlr/types/wlr_pointer_constraints_v1.h
new file mode 100644
index 00000000..fef8c2e9
--- /dev/null
+++ b/include/wlr/types/wlr_pointer_constraints_v1.h
@@ -0,0 +1,102 @@
+/*
+ * 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
+
+#ifndef WLR_TYPES_WLR_POINTER_CONSTRAINTS_V1_H
+#define WLR_TYPES_WLR_POINTER_CONSTRAINTS_V1_H
+
+#include <stdint.h>
+#include <wayland-server.h>
+#include <pixman.h>
+#include <wlr/types/wlr_box.h>
+#include <wlr/types/wlr_seat.h>
+#include "pointer-constraints-unstable-v1-protocol.h"
+
+struct wlr_seat;
+
+enum wlr_pointer_constraint_v1_type {
+ WLR_POINTER_CONSTRAINT_V1_LOCKED,
+ WLR_POINTER_CONSTRAINT_V1_CONFINED,
+};
+
+enum wlr_pointer_constraint_v1_state_field {
+ WLR_POINTER_CONSTRAINT_V1_STATE_REGION = 1 << 0,
+ WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT = 1 << 1,
+};
+
+struct wlr_pointer_constraint_v1_state {
+ uint32_t committed; // enum wlr_pointer_constraint_v1_state_field
+ pixman_region32_t region;
+
+ // only valid for locked_pointer
+ struct {
+ double x, y;
+ } cursor_hint;
+};
+
+struct wlr_pointer_constraint_v1 {
+ struct wlr_pointer_constraints_v1 *pointer_constraints;
+
+ struct wl_resource *resource;
+ struct wlr_surface *surface;
+ struct wlr_seat *seat;
+ enum zwp_pointer_constraints_v1_lifetime lifetime;
+ enum wlr_pointer_constraint_v1_type type;
+ pixman_region32_t region;
+
+ struct wlr_pointer_constraint_v1_state current, pending;
+
+ struct wl_listener surface_commit;
+ struct wl_listener surface_destroy;
+ struct wl_listener seat_destroy;
+
+ struct wl_list link; // wlr_pointer_constraints_v1::constraints
+
+ struct {
+ struct wl_signal destroy;
+ } events;
+
+ void *data;
+};
+
+struct wlr_pointer_constraints_v1 {
+ struct wl_list resources; // wl_resource_get_link
+ struct wl_global *global;
+
+ struct {
+ /**
+ * Called when a new pointer constraint is created.
+ *
+ * data: struct wlr_pointer_constraint_v1 *
+ */
+ struct wl_signal new_constraint;
+ } events;
+
+ struct wl_list constraints; // wlr_pointer_constraint_v1::link
+
+ void *data;
+};
+
+struct wlr_pointer_constraints_v1 *wlr_pointer_constraints_v1_create(
+ struct wl_display *display);
+void wlr_pointer_constraints_v1_destroy(
+ struct wlr_pointer_constraints_v1 *pointer_constraints);
+
+struct wlr_pointer_constraint_v1 *
+ wlr_pointer_constraints_v1_constraint_for_surface(
+ struct wlr_pointer_constraints_v1 *pointer_constraints,
+ struct wlr_surface *surface, struct wlr_seat *seat);
+
+void wlr_pointer_constraint_v1_send_activated(
+ struct wlr_pointer_constraint_v1 *constraint);
+/**
+ * Deactivate the constraint. May destroy the constraint.
+ */
+void wlr_pointer_constraint_v1_send_deactivated(
+ struct wlr_pointer_constraint_v1 *constraint);
+
+#endif
diff --git a/include/wlr/types/wlr_region.h b/include/wlr/types/wlr_region.h
index 3c4a0532..ec7f73aa 100644
--- a/include/wlr/types/wlr_region.h
+++ b/include/wlr/types/wlr_region.h
@@ -10,8 +10,7 @@
#define WLR_TYPES_WLR_REGION_H
#include <pixman.h>
-
-struct wl_resource;
+#include <wayland-server-protocol.h>
/*
* Creates a new region resource with the provided new ID. If `resource_list` is
diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h
index b3c02cf2..59de8207 100644
--- a/include/wlr/types/wlr_seat.h
+++ b/include/wlr/types/wlr_seat.h
@@ -146,6 +146,10 @@ struct wlr_seat_pointer_state {
uint32_t grab_time;
struct wl_listener surface_destroy;
+
+ struct {
+ struct wl_signal focus_change; // wlr_seat_pointer_focus_change_event
+ } events;
};
// TODO: May be useful to be able to simulate keyboard input events
@@ -238,6 +242,12 @@ struct wlr_seat_pointer_request_set_cursor_event {
int32_t hotspot_x, hotspot_y;
};
+struct wlr_seat_pointer_focus_change_event {
+ struct wlr_seat *seat;
+ struct wlr_surface *old_surface, *new_surface;
+ double sx, sy;
+};
+
/**
* Allocates a new wlr_seat and adds a wl_seat global to the display.
*/
@@ -546,6 +556,9 @@ bool wlr_seat_touch_has_grab(struct wlr_seat *seat);
bool wlr_seat_validate_grab_serial(struct wlr_seat *seat, uint32_t serial);
struct wlr_seat_client *wlr_seat_client_from_resource(
- struct wl_resource *resource);
+ struct wl_resource *resource);
+
+struct wlr_seat_client *wlr_seat_client_from_pointer_resource(
+ struct wl_resource *resource);
#endif
diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h
index 063f9e26..bfbfbcc8 100644
--- a/include/wlr/types/wlr_surface.h
+++ b/include/wlr/types/wlr_surface.h
@@ -82,6 +82,11 @@ struct wlr_surface {
*/
pixman_region32_t opaque_region;
/**
+ * The current input region, in surface-local coordinates. It is clipped to
+ * the surface bounds.
+ */
+ pixman_region32_t input_region;
+ /**
* `current` contains the current, committed surface state. `pending`
* accumulates state changes from the client between commits and shouldn't
* be accessed by the compositor directly. `previous` contains the state of
diff --git a/include/wlr/util/region.h b/include/wlr/util/region.h
index 32387bfb..4aca07e1 100644
--- a/include/wlr/util/region.h
+++ b/include/wlr/util/region.h
@@ -16,6 +16,8 @@
#ifndef WLR_UTIL_REGION_H
#define WLR_UTIL_REGION_H
+
+#include <stdbool.h>
#include <pixman.h>
#include <wayland-server.h>
@@ -48,4 +50,7 @@ void wlr_region_expand(pixman_region32_t *dst, pixman_region32_t *src,
void wlr_region_rotated_bounds(pixman_region32_t *dst, pixman_region32_t *src,
float rotation, int ox, int oy);
+bool wlr_region_confine(pixman_region32_t *region, double x1, double y1, double x2,
+ double y2, double *x2_out, double *y2_out);
+
#endif