input/tablet: fix up updated axes after rotation
In the case that only one axis received an event, rotating the input can cause the change to actually happen on the other axis, as far as clients are concerned. This commit updates the axes flags to be consistent post-rotation. Fixes swaywm/sway#4776.
This commit is contained in:
parent
e51d507799
commit
ad28f57533
|
@ -539,11 +539,33 @@ static void handle_tablet_tool_axis(struct wl_listener *listener, void *data) {
|
||||||
struct wlr_cursor_device *device;
|
struct wlr_cursor_device *device;
|
||||||
device = wl_container_of(listener, device, tablet_tool_axis);
|
device = wl_container_of(listener, device, tablet_tool_axis);
|
||||||
|
|
||||||
struct wlr_output *output =
|
struct wlr_output *output = get_mapped_output(device);
|
||||||
get_mapped_output(device);
|
|
||||||
if (output) {
|
if (output) {
|
||||||
apply_output_transform(&event->x, &event->y, output->transform);
|
// In the case that only one axis received an event, rotating the input can
|
||||||
|
// cause the change to actually happen on the other axis, as far as clients
|
||||||
|
// are concerned.
|
||||||
|
//
|
||||||
|
// Here, we feed apply_output_transform NAN on the axis that didn't change,
|
||||||
|
// and remap the axes flags based on whether it returns NAN itself.
|
||||||
|
double x = event->updated_axes & WLR_TABLET_TOOL_AXIS_X ? event->x : NAN;
|
||||||
|
double y = event->updated_axes & WLR_TABLET_TOOL_AXIS_Y ? event->y : NAN;
|
||||||
|
|
||||||
|
apply_output_transform(&x, &y, output->transform);
|
||||||
|
|
||||||
|
event->updated_axes &= ~(WLR_TABLET_TOOL_AXIS_X | WLR_TABLET_TOOL_AXIS_Y);
|
||||||
|
event->x = event->y = 0;
|
||||||
|
|
||||||
|
if (!isnan(x)) {
|
||||||
|
event->updated_axes |= WLR_TABLET_TOOL_AXIS_X;
|
||||||
|
event->x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isnan(y)) {
|
||||||
|
event->updated_axes |= WLR_TABLET_TOOL_AXIS_Y;
|
||||||
|
event->y = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wlr_signal_emit_safe(&device->cursor->events.tablet_tool_axis, event);
|
wlr_signal_emit_safe(&device->cursor->events.tablet_tool_axis, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue