mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
backends: Delegate on MetaInputMapper for unmapped display devices
If a display device (touchscreen, tablet with libwacom integration flags) does not receive a monitor through settings. Delegate on the MetaInputMapper so it receives a mapping through heuristics.
This commit is contained in:
parent
08a5e660d3
commit
87858a4e01
@ -32,6 +32,7 @@
|
||||
|
||||
#include "backends/meta-backend-private.h"
|
||||
#include "backends/meta-input-settings-private.h"
|
||||
#include "backends/meta-input-mapper-private.h"
|
||||
#include "backends/meta-logical-monitor.h"
|
||||
#include "backends/meta-monitor.h"
|
||||
#include "core/display-private.h"
|
||||
@ -96,6 +97,9 @@ struct _MetaInputSettingsPrivate
|
||||
guint number;
|
||||
gdouble value;
|
||||
} last_pad_action_info;
|
||||
|
||||
/* For absolute devices with no mapping in settings */
|
||||
MetaInputMapper *input_mapper;
|
||||
};
|
||||
|
||||
typedef void (*ConfigBoolFunc) (MetaInputSettings *input_settings,
|
||||
@ -157,6 +161,7 @@ meta_input_settings_dispose (GObject *object)
|
||||
g_clear_object (&priv->keyboard_settings);
|
||||
g_clear_object (&priv->gsd_settings);
|
||||
g_clear_object (&priv->a11y_settings);
|
||||
g_clear_object (&priv->input_mapper);
|
||||
g_clear_pointer (&priv->mappable_devices, g_hash_table_unref);
|
||||
g_clear_pointer (&priv->current_tools, g_hash_table_unref);
|
||||
|
||||
@ -846,6 +851,42 @@ out:
|
||||
g_strfreev (edid);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_input_settings_delegate_on_mapper (MetaInputSettings *input_settings,
|
||||
ClutterInputDevice *device)
|
||||
{
|
||||
MetaInputSettingsPrivate *priv;
|
||||
gboolean builtin = FALSE;
|
||||
|
||||
priv = meta_input_settings_get_instance_private (input_settings);
|
||||
|
||||
#ifdef HAVE_LIBWACOM
|
||||
if (clutter_input_device_get_device_type (device) != CLUTTER_TOUCHSCREEN_DEVICE)
|
||||
{
|
||||
WacomDevice *wacom_device;
|
||||
WacomIntegrationFlags flags = 0;
|
||||
|
||||
wacom_device =
|
||||
meta_input_settings_get_tablet_wacom_device (input_settings,
|
||||
device);
|
||||
|
||||
if (wacom_device)
|
||||
{
|
||||
flags = libwacom_get_integration_flags (wacom_device);
|
||||
|
||||
if ((flags & (WACOM_DEVICE_INTEGRATED_SYSTEM |
|
||||
WACOM_DEVICE_INTEGRATED_DISPLAY)) == 0)
|
||||
return FALSE;
|
||||
|
||||
builtin = (flags & WACOM_DEVICE_INTEGRATED_SYSTEM) != 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
meta_input_mapper_add_device (priv->input_mapper, device, builtin);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
update_tablet_keep_aspect (MetaInputSettings *input_settings,
|
||||
GSettings *settings,
|
||||
@ -915,12 +956,21 @@ update_device_display (MetaInputSettings *input_settings,
|
||||
if (clutter_input_device_get_device_type (device) == CLUTTER_TOUCHSCREEN_DEVICE ||
|
||||
clutter_input_device_get_mapping_mode (device) ==
|
||||
CLUTTER_INPUT_DEVICE_MAPPING_ABSOLUTE)
|
||||
meta_input_settings_find_monitor (input_settings, settings, device,
|
||||
&monitor, &logical_monitor);
|
||||
|
||||
if (monitor)
|
||||
meta_monitor_manager_get_monitor_matrix (priv->monitor_manager,
|
||||
monitor, logical_monitor, matrix);
|
||||
{
|
||||
meta_input_settings_find_monitor (input_settings, settings, device,
|
||||
&monitor, &logical_monitor);
|
||||
if (monitor)
|
||||
{
|
||||
meta_input_mapper_remove_device (priv->input_mapper, device);
|
||||
meta_monitor_manager_get_monitor_matrix (priv->monitor_manager,
|
||||
monitor, logical_monitor, matrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (meta_input_settings_delegate_on_mapper (input_settings, device))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
input_settings_class->set_matrix (input_settings, device, matrix);
|
||||
|
||||
@ -1371,6 +1421,29 @@ monitors_changed_cb (MetaMonitorManager *monitor_manager,
|
||||
update_device_display (input_settings, info->settings, device);
|
||||
}
|
||||
|
||||
static void
|
||||
input_mapper_device_mapped_cb (MetaInputMapper *mapper,
|
||||
ClutterInputDevice *device,
|
||||
MetaLogicalMonitor *logical_monitor,
|
||||
MetaMonitor *monitor,
|
||||
MetaInputSettings *input_settings)
|
||||
{
|
||||
MetaInputSettingsPrivate *priv;
|
||||
float matrix[6] = { 1, 0, 0, 0, 1, 0 };
|
||||
|
||||
priv = meta_input_settings_get_instance_private (input_settings);
|
||||
|
||||
if (monitor && logical_monitor)
|
||||
{
|
||||
meta_monitor_manager_get_monitor_matrix (priv->monitor_manager,
|
||||
monitor, logical_monitor,
|
||||
matrix);
|
||||
}
|
||||
|
||||
META_INPUT_SETTINGS_GET_CLASS (input_settings)->set_matrix (input_settings,
|
||||
device, matrix);
|
||||
}
|
||||
|
||||
static void
|
||||
device_mapping_info_free (DeviceMappingInfo *info)
|
||||
{
|
||||
@ -1593,6 +1666,7 @@ meta_input_settings_device_removed (ClutterDeviceManager *device_manager,
|
||||
MetaInputSettingsPrivate *priv;
|
||||
|
||||
priv = meta_input_settings_get_instance_private (input_settings);
|
||||
meta_input_mapper_remove_device (priv->input_mapper, device);
|
||||
g_hash_table_remove (priv->mappable_devices, device);
|
||||
g_hash_table_remove (priv->current_tools, device);
|
||||
|
||||
@ -1772,6 +1846,10 @@ meta_input_settings_init (MetaInputSettings *settings)
|
||||
#endif
|
||||
|
||||
priv->two_finger_devices = g_hash_table_new (NULL, NULL);
|
||||
|
||||
priv->input_mapper = meta_input_mapper_new ();
|
||||
g_signal_connect (priv->input_mapper, "device-mapped",
|
||||
G_CALLBACK (input_mapper_device_mapped_cb), settings);
|
||||
}
|
||||
|
||||
GSettings *
|
||||
|
Loading…
Reference in New Issue
Block a user