compositor-drm: Enable seat constraining when configured in weston.ini
This change tweaks weston_pointer_clamp to take into consideration if a
seat is constrained to a particular output by only considering the
pointer position valid if it is within the output we a constrained to.
This function is also used for the initial warping of the pointer when a
constraint is first established.
The other two changes are the application of the constraint when either
a new device added or a new output created and therefore outputs and
input devices can be brought up in either order.
v2: the code in create_output_for_connector has been spun off into a
new function setup_output_seat_constraint (Ander). The inappropriate
warping behaviour has been resolved by using weston_pointer_clamp
(Pekka).
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index e704c9f..45e7e9b 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1728,6 +1728,25 @@
return WL_OUTPUT_TRANSFORM_NORMAL;
}
+static void
+setup_output_seat_constraint(struct drm_compositor *ec,
+ struct weston_output *output,
+ const char *s)
+{
+ if (strcmp(s, "") != 0) {
+ struct udev_seat *seat;
+
+ seat = udev_seat_get_named(&ec->base, s);
+ if (seat)
+ seat->base.output = output;
+
+ if (seat && seat->base.pointer)
+ weston_pointer_clamp(seat->base.pointer,
+ &seat->base.pointer->x,
+ &seat->base.pointer->y);
+ }
+}
+
static int
create_output_for_connector(struct drm_compositor *ec,
drmModeRes *resources,
@@ -1796,6 +1815,10 @@
transform = parse_transform(s, output->base.name);
free(s);
+ weston_config_section_get_string(section, "seat", &s, "");
+ setup_output_seat_constraint(ec, &output->base, s);
+ free(s);
+
output->crtc_id = resources->crtcs[i];
output->pipe = i;
ec->crtc_allocator |= (1 << output->crtc_id);