Add mouseEmulation parameter to touch devices

This commit is contained in:
Simon Long 2024-10-20 11:51:43 +01:00
parent 1dadb12807
commit 1fa320cb99
6 changed files with 22 additions and 3 deletions

View file

@ -622,7 +622,7 @@ extending outward from the snapped edge.
## TOUCH
```
<touch deviceName="" mapToOutput="" />
<touch deviceName="" mapToOutput="" mouseEmulation="no"/>
```
*<touch deviceName="" />*
@ -636,6 +636,10 @@ extending outward from the snapped edge.
Direct cursor movement to a specified output. If the compositor is
running in nested mode, this does not take effect.
*<touch mouseEmulation="" />*
If mouseEmulation is enabled, all touch up/down/motion events are
translated to mouse button and motion events.
## TABLET
```

View file

@ -484,8 +484,11 @@
Direct cursor movement to a specified output. If the compositor is
running in nested mode, this does not take effect.
If mouseEmulation is enabled, all touch up/down/motion events are
translated to mouse button and motion events.
-->
<touch deviceName="" mapToOutput="" />
<touch deviceName="" mapToOutput="" mouseEmulation="no"/>
<!--
The tablet cursor movement can be restricted to a single output.

View file

@ -8,6 +8,7 @@
struct touch_config_entry {
char *device_name;
char *output_name;
bool force_mouse_emulation;
struct wl_list link; /* struct rcxml.touch_configs */
};

View file

@ -491,6 +491,8 @@ fill_touch(char *nodename, char *content)
current_touch->device_name = xstrdup(content);
} else if (!strcasecmp(nodename, "mapToOutput.touch")) {
current_touch->output_name = xstrdup(content);
} else if (!strcasecmp(nodename, "mouseEmulation.touch")) {
set_bool(content, &current_touch->force_mouse_emulation);
} else {
wlr_log(WLR_ERROR, "Unexpected data in touch parser: %s=\"%s\"",
nodename, content);

View file

@ -1237,6 +1237,7 @@ cursor_emulate_button(struct seat *seat, uint32_t button,
cursor_finish_button_release(seat);
break;
}
wlr_seat_pointer_notify_frame (seat->seat);
}
static int

View file

@ -389,6 +389,7 @@ static void
seat_update_capabilities(struct seat *seat)
{
struct input *input = NULL;
struct touch_config_entry *config_entry;
uint32_t caps = 0;
wl_list_for_each(input, &seat->inputs, link) {
@ -401,7 +402,14 @@ seat_update_capabilities(struct seat *seat)
caps |= WL_SEAT_CAPABILITY_POINTER;
break;
case WLR_INPUT_DEVICE_TOUCH:
caps |= WL_SEAT_CAPABILITY_TOUCH;
config_entry =
touch_find_config_for_device(input->wlr_input_device->name);
if (config_entry->force_mouse_emulation) {
caps |= WL_SEAT_CAPABILITY_POINTER;
}
else {
caps |= WL_SEAT_CAPABILITY_TOUCH;
}
break;
default:
break;