backends/input-mapper: Synchronize device enabled state when adding device

When device is added to the mapper, the device may not be in a
desirable state. This changeset updates the device state when
the device is added to the input-mapper.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3834
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4188>
This commit is contained in:
Yao Wei (魏銘廷) 2024-12-17 16:36:08 +08:00 committed by Yao Wei
parent c9d8b0b5a9
commit 78c621aa1a

View File

@ -991,6 +991,9 @@ meta_input_mapper_add_device (MetaInputMapper *mapper,
ClutterInputDevice *device) ClutterInputDevice *device)
{ {
MetaMapperInputInfo *info; MetaMapperInputInfo *info;
ClutterInputDeviceType type;
MetaPowerSave power_save_mode;
gboolean on;
g_return_if_fail (mapper != NULL); g_return_if_fail (mapper != NULL);
g_return_if_fail (device != NULL); g_return_if_fail (device != NULL);
@ -1001,6 +1004,15 @@ meta_input_mapper_add_device (MetaInputMapper *mapper,
info = mapper_input_info_new (device, mapper); info = mapper_input_info_new (device, mapper);
g_hash_table_insert (mapper->input_devices, device, info); g_hash_table_insert (mapper->input_devices, device, info);
mapper_recalculate_input (mapper, info); mapper_recalculate_input (mapper, info);
type = clutter_input_device_get_device_type (device);
if (type == CLUTTER_TOUCHSCREEN_DEVICE)
{
power_save_mode =
meta_monitor_manager_get_power_save_mode (mapper->monitor_manager);
on = power_save_mode == META_POWER_SAVE_ON;
g_signal_emit (mapper, signals[DEVICE_ENABLED], 0, device, on);
}
} }
void void