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).
This commit is contained in:
committed by
Kristian Høgsberg
parent
4451aa5d95
commit
66bd9f5baf
@@ -1728,6 +1728,25 @@ parse_transform(const char *transform, const char *output_name)
|
|||||||
return WL_OUTPUT_TRANSFORM_NORMAL;
|
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
|
static int
|
||||||
create_output_for_connector(struct drm_compositor *ec,
|
create_output_for_connector(struct drm_compositor *ec,
|
||||||
drmModeRes *resources,
|
drmModeRes *resources,
|
||||||
@@ -1796,6 +1815,10 @@ create_output_for_connector(struct drm_compositor *ec,
|
|||||||
transform = parse_transform(s, output->base.name);
|
transform = parse_transform(s, output->base.name);
|
||||||
free(s);
|
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->crtc_id = resources->crtcs[i];
|
||||||
output->pipe = i;
|
output->pipe = i;
|
||||||
ec->crtc_allocator |= (1 << output->crtc_id);
|
ec->crtc_allocator |= (1 << output->crtc_id);
|
||||||
|
|||||||
@@ -437,6 +437,8 @@ struct weston_seat {
|
|||||||
struct weston_keyboard *keyboard;
|
struct weston_keyboard *keyboard;
|
||||||
struct weston_touch *touch;
|
struct weston_touch *touch;
|
||||||
|
|
||||||
|
struct weston_output *output; /* constraint */
|
||||||
|
|
||||||
struct wl_signal destroy_signal;
|
struct wl_signal destroy_signal;
|
||||||
|
|
||||||
struct weston_compositor *compositor;
|
struct weston_compositor *compositor;
|
||||||
|
|||||||
+6
-1
@@ -574,6 +574,8 @@ weston_pointer_clamp(struct weston_pointer *pointer, wl_fixed_t *fx, wl_fixed_t
|
|||||||
old_y = wl_fixed_to_int(pointer->y);
|
old_y = wl_fixed_to_int(pointer->y);
|
||||||
|
|
||||||
wl_list_for_each(output, &ec->output_list, link) {
|
wl_list_for_each(output, &ec->output_list, link) {
|
||||||
|
if (pointer->seat->output && pointer->seat->output != output)
|
||||||
|
continue;
|
||||||
if (pixman_region32_contains_point(&output->region,
|
if (pixman_region32_contains_point(&output->region,
|
||||||
x, y, NULL))
|
x, y, NULL))
|
||||||
valid = 1;
|
valid = 1;
|
||||||
@@ -582,7 +584,10 @@ weston_pointer_clamp(struct weston_pointer *pointer, wl_fixed_t *fx, wl_fixed_t
|
|||||||
prev = output;
|
prev = output;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!valid) {
|
if (!prev)
|
||||||
|
prev = pointer->seat->output;
|
||||||
|
|
||||||
|
if (prev && !valid) {
|
||||||
if (x < prev->x)
|
if (x < prev->x)
|
||||||
*fx = wl_fixed_from_int(prev->x);
|
*fx = wl_fixed_from_int(prev->x);
|
||||||
else if (x >= prev->x + prev->width)
|
else if (x >= prev->x + prev->width)
|
||||||
|
|||||||
@@ -115,6 +115,11 @@ device_added(struct udev_device *udev_device, struct udev_input *input)
|
|||||||
|
|
||||||
wl_list_insert(seat->devices_list.prev, &device->link);
|
wl_list_insert(seat->devices_list.prev, &device->link);
|
||||||
|
|
||||||
|
if (seat->base.output && seat->base.pointer)
|
||||||
|
weston_pointer_clamp(seat->base.pointer,
|
||||||
|
&seat->base.pointer->x,
|
||||||
|
&seat->base.pointer->y);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user