summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2018-02-19 16:50:52 +0100
committerCarlos Garnacho <carlosg@gnome.org>2018-02-19 17:15:26 +0100
commit54dcff3aa2ebdf8e8d9a416f4fa4f505252cac0a (patch)
treed374cf720e3b5f77041a1f6b19c9f1be21bd352e
parentbcd58820811901ed913d5970d32e8b3d3a280a2b (diff)
downloadmutter-54dcff3aa2ebdf8e8d9a416f4fa4f505252cac0a.tar.gz
backends: Monitor changes in active tools' settings
So the changes can be instantly applied while the tool is in proximity. Before we would just do it on proximity-in, which doesn't provide a good look&feel while modifying the tool settings in g-c-c. https://gitlab.gnome.org/GNOME/mutter/issues/38 Closes: #38
-rw-r--r--src/backends/meta-input-settings.c71
1 files changed, 68 insertions, 3 deletions
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
index 93f8ec051..10d7a8cd2 100644
--- a/src/backends/meta-input-settings.c
+++ b/src/backends/meta-input-settings.c
@@ -41,6 +41,16 @@ static GQuark quark_tool_settings = 0;
typedef struct _MetaInputSettingsPrivate MetaInputSettingsPrivate;
typedef struct _DeviceMappingInfo DeviceMappingInfo;
+typedef struct _CurrentToolInfo CurrentToolInfo;
+
+struct _CurrentToolInfo
+{
+ MetaInputSettings *input_settings;
+ ClutterInputDevice *device;
+ ClutterInputDeviceTool *tool;
+ GSettings *settings;
+ guint changed_id;
+};
struct _DeviceMappingInfo
{
@@ -69,6 +79,8 @@ struct _MetaInputSettingsPrivate
GHashTable *mappable_devices;
+ GHashTable *current_tools;
+
ClutterVirtualInputDevice *virtual_pad_keyboard;
#ifdef HAVE_LIBWACOM
@@ -146,6 +158,7 @@ meta_input_settings_dispose (GObject *object)
g_clear_object (&priv->gsd_settings);
g_clear_object (&priv->a11y_settings);
g_clear_pointer (&priv->mappable_devices, g_hash_table_unref);
+ g_clear_pointer (&priv->current_tools, g_hash_table_unref);
if (priv->monitors_changed_id && priv->monitor_manager)
{
@@ -1596,6 +1609,7 @@ meta_input_settings_device_removed (ClutterDeviceManager *device_manager,
priv = meta_input_settings_get_instance_private (input_settings);
g_hash_table_remove (priv->mappable_devices, device);
+ g_hash_table_remove (priv->current_tools, device);
if (g_hash_table_remove (priv->two_finger_devices, device) &&
g_hash_table_size (priv->two_finger_devices) == 0)
@@ -1603,15 +1617,63 @@ meta_input_settings_device_removed (ClutterDeviceManager *device_manager,
}
static void
+current_tool_changed_cb (GSettings *settings,
+ const char *key,
+ gpointer user_data)
+{
+ CurrentToolInfo *info = user_data;
+
+ apply_stylus_settings (info->input_settings, info->device, info->tool);
+}
+
+static CurrentToolInfo *
+current_tool_info_new (MetaInputSettings *input_settings,
+ ClutterInputDevice *device,
+ ClutterInputDeviceTool *tool)
+{
+ CurrentToolInfo *info;
+
+ info = g_new0 (CurrentToolInfo, 1);
+ info->input_settings = input_settings;
+ info->device = device;
+ info->tool = tool;
+ info->settings = lookup_tool_settings (tool, device);
+ info->changed_id =
+ g_signal_connect (info->settings, "changed",
+ G_CALLBACK (current_tool_changed_cb),
+ info);
+ return info;
+}
+
+static void
+current_tool_info_free (CurrentToolInfo *info)
+{
+ g_signal_handler_disconnect (info->settings, info->changed_id);
+ g_free (info);
+}
+
+static void
meta_input_settings_tool_changed (ClutterDeviceManager *device_manager,
ClutterInputDevice *device,
ClutterInputDeviceTool *tool,
MetaInputSettings *input_settings)
{
- if (!tool)
- return;
+ MetaInputSettingsPrivate *priv;
- apply_stylus_settings (input_settings, device, tool);
+ priv = meta_input_settings_get_instance_private (input_settings);
+
+ if (tool)
+ {
+ CurrentToolInfo *current_tool;
+
+ current_tool = current_tool_info_new (input_settings, device, tool);
+ g_hash_table_insert (priv->current_tools, device, current_tool);
+ apply_stylus_settings (input_settings, device, tool);
+ }
+ else
+ {
+ g_hash_table_remove (priv->current_tools, device);
+ }
}
static void
@@ -1708,6 +1770,9 @@ meta_input_settings_init (MetaInputSettings *settings)
priv->mappable_devices =
g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) device_mapping_info_free);
+ priv->current_tools =
+ g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) current_tool_info_free);
+
priv->monitor_manager = g_object_ref (meta_monitor_manager_get ());
g_signal_connect (priv->monitor_manager, "monitors-changed-internal",
G_CALLBACK (monitors_changed_cb), settings);