virtual-input-device/native: Emit added/removed events

Without these devices, things that depend on the existance of input
device classes won't know about the existance of e.g. pointer devices,
if the only pointer device is from a virtual one.

This requires handling situations where e.g. a device doesn't have a
device node thus can't be matched against a udev device.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1688>
This commit is contained in:
Jonas Ådahl 2021-01-26 22:42:27 +01:00 committed by Marge Bot
parent 5e34ae2154
commit 671bda2509
2 changed files with 13 additions and 0 deletions

View File

@ -386,6 +386,9 @@ input_device_get_physical_size (MetaInputMapper *mapper,
const char *node;
node = clutter_input_device_get_device_node (device);
if (!node)
return FALSE;
udev_device = g_udev_client_query_by_device_file (mapper->udev_client, node);
if (udev_device &&

View File

@ -162,6 +162,7 @@ release_device_in_impl (GTask *task)
MetaSeatImpl *seat_impl;
int code;
uint64_t time_us;
ClutterEvent *device_event;
device_native = META_INPUT_DEVICE_NATIVE (impl_state->device);
seat_impl = meta_input_device_native_get_seat_impl (device_native);
@ -198,6 +199,10 @@ release_device_in_impl (GTask *task)
}
}
device_event = clutter_event_new (CLUTTER_DEVICE_REMOVED);
clutter_event_set_device (device_event, impl_state->device);
_clutter_event_push (device_event, FALSE);
g_clear_object (&impl_state->device);
g_task_return_boolean (task, TRUE);
@ -1006,6 +1011,7 @@ meta_virtual_input_device_native_constructed (GObject *object)
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (object);
ClutterInputDeviceType device_type;
ClutterEvent *device_event = NULL;
device_type = clutter_virtual_input_device_get_device_type (virtual_device);
@ -1018,6 +1024,10 @@ meta_virtual_input_device_native_constructed (GObject *object)
meta_input_device_native_new_virtual (virtual_evdev->seat->impl,
device_type,
CLUTTER_INPUT_MODE_PHYSICAL);
device_event = clutter_event_new (CLUTTER_DEVICE_ADDED);
clutter_event_set_device (device_event, virtual_evdev->impl_state->device);
_clutter_event_push (device_event, FALSE);
}
static void