|
|
e47e58 |
From 62f0fb12b1fa946779f0efa406159a355811fdc5 Mon Sep 17 00:00:00 2001
|
|
|
e47e58 |
From: Carlos Garnacho <carlosg@gnome.org>
|
|
|
e47e58 |
Date: Mon, 19 Feb 2018 16:50:52 +0100
|
|
|
e47e58 |
Subject: [PATCH] backends: Monitor changes in active tools' settings
|
|
|
e47e58 |
|
|
|
e47e58 |
So the changes can be instantly applied while the tool is in proximity.
|
|
|
e47e58 |
Before we would just do it on proximity-in, which doesn't provide a
|
|
|
e47e58 |
good look&feel while modifying the tool settings in g-c-c.
|
|
|
e47e58 |
|
|
|
e47e58 |
https://gitlab.gnome.org/GNOME/mutter/issues/38
|
|
|
e47e58 |
|
|
|
e47e58 |
Closes: #38
|
|
|
e47e58 |
---
|
|
|
e47e58 |
src/backends/meta-input-settings.c | 71 ++++++++++++++++++++++++++++++++++++--
|
|
|
e47e58 |
1 file changed, 68 insertions(+), 3 deletions(-)
|
|
|
e47e58 |
|
|
|
e47e58 |
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
|
|
|
e47e58 |
index 0658755..ec0fc9f 100644
|
|
|
e47e58 |
--- a/src/backends/meta-input-settings.c
|
|
|
e47e58 |
+++ b/src/backends/meta-input-settings.c
|
|
|
e47e58 |
@@ -41,6 +41,16 @@ static GQuark quark_tool_settings = 0;
|
|
|
e47e58 |
|
|
|
e47e58 |
typedef struct _MetaInputSettingsPrivate MetaInputSettingsPrivate;
|
|
|
e47e58 |
typedef struct _DeviceMappingInfo DeviceMappingInfo;
|
|
|
e47e58 |
+typedef struct _CurrentToolInfo CurrentToolInfo;
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+struct _CurrentToolInfo
|
|
|
e47e58 |
+{
|
|
|
e47e58 |
+ MetaInputSettings *input_settings;
|
|
|
e47e58 |
+ ClutterInputDevice *device;
|
|
|
e47e58 |
+ ClutterInputDeviceTool *tool;
|
|
|
e47e58 |
+ GSettings *settings;
|
|
|
e47e58 |
+ guint changed_id;
|
|
|
e47e58 |
+};
|
|
|
e47e58 |
|
|
|
e47e58 |
struct _DeviceMappingInfo
|
|
|
e47e58 |
{
|
|
|
e47e58 |
@@ -68,6 +78,8 @@ struct _MetaInputSettingsPrivate
|
|
|
e47e58 |
|
|
|
e47e58 |
GHashTable *mappable_devices;
|
|
|
e47e58 |
|
|
|
e47e58 |
+ GHashTable *current_tools;
|
|
|
e47e58 |
+
|
|
|
e47e58 |
ClutterVirtualInputDevice *virtual_pad_keyboard;
|
|
|
e47e58 |
|
|
|
e47e58 |
#ifdef HAVE_LIBWACOM
|
|
|
e47e58 |
@@ -144,6 +156,7 @@ meta_input_settings_dispose (GObject *object)
|
|
|
e47e58 |
g_clear_object (&priv->keyboard_settings);
|
|
|
e47e58 |
g_clear_object (&priv->gsd_settings);
|
|
|
e47e58 |
g_clear_pointer (&priv->mappable_devices, g_hash_table_unref);
|
|
|
e47e58 |
+ g_clear_pointer (&priv->current_tools, g_hash_table_unref);
|
|
|
e47e58 |
|
|
|
e47e58 |
if (priv->monitors_changed_id && priv->monitor_manager)
|
|
|
e47e58 |
{
|
|
|
e47e58 |
@@ -1510,22 +1523,71 @@ meta_input_settings_device_removed (ClutterDeviceManager *device_manager,
|
|
|
e47e58 |
|
|
|
e47e58 |
priv = meta_input_settings_get_instance_private (input_settings);
|
|
|
e47e58 |
g_hash_table_remove (priv->mappable_devices, device);
|
|
|
e47e58 |
+ g_hash_table_remove (priv->current_tools, device);
|
|
|
e47e58 |
|
|
|
e47e58 |
if (g_hash_table_remove (priv->two_finger_devices, device) &&
|
|
|
e47e58 |
g_hash_table_size (priv->two_finger_devices) == 0)
|
|
|
e47e58 |
apply_device_settings (input_settings, NULL);
|
|
|
e47e58 |
}
|
|
|
e47e58 |
|
|
|
e47e58 |
+static void
|
|
|
e47e58 |
+current_tool_changed_cb (GSettings *settings,
|
|
|
e47e58 |
+ const char *key,
|
|
|
e47e58 |
+ gpointer user_data)
|
|
|
e47e58 |
+{
|
|
|
e47e58 |
+ CurrentToolInfo *info = user_data;
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ apply_stylus_settings (info->input_settings, info->device, info->tool);
|
|
|
e47e58 |
+}
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+static CurrentToolInfo *
|
|
|
e47e58 |
+current_tool_info_new (MetaInputSettings *input_settings,
|
|
|
e47e58 |
+ ClutterInputDevice *device,
|
|
|
e47e58 |
+ ClutterInputDeviceTool *tool)
|
|
|
e47e58 |
+{
|
|
|
e47e58 |
+ CurrentToolInfo *info;
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ info = g_new0 (CurrentToolInfo, 1);
|
|
|
e47e58 |
+ info->input_settings = input_settings;
|
|
|
e47e58 |
+ info->device = device;
|
|
|
e47e58 |
+ info->tool = tool;
|
|
|
e47e58 |
+ info->settings = lookup_tool_settings (tool, device);
|
|
|
e47e58 |
+ info->changed_id =
|
|
|
e47e58 |
+ g_signal_connect (info->settings, "changed",
|
|
|
e47e58 |
+ G_CALLBACK (current_tool_changed_cb),
|
|
|
e47e58 |
+ info);
|
|
|
e47e58 |
+ return info;
|
|
|
e47e58 |
+}
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+static void
|
|
|
e47e58 |
+current_tool_info_free (CurrentToolInfo *info)
|
|
|
e47e58 |
+{
|
|
|
e47e58 |
+ g_signal_handler_disconnect (info->settings, info->changed_id);
|
|
|
e47e58 |
+ g_free (info);
|
|
|
e47e58 |
+}
|
|
|
e47e58 |
+
|
|
|
e47e58 |
static void
|
|
|
e47e58 |
meta_input_settings_tool_changed (ClutterDeviceManager *device_manager,
|
|
|
e47e58 |
ClutterInputDevice *device,
|
|
|
e47e58 |
ClutterInputDeviceTool *tool,
|
|
|
e47e58 |
MetaInputSettings *input_settings)
|
|
|
e47e58 |
{
|
|
|
e47e58 |
- if (!tool)
|
|
|
e47e58 |
- return;
|
|
|
e47e58 |
+ MetaInputSettingsPrivate *priv;
|
|
|
e47e58 |
|
|
|
e47e58 |
- apply_stylus_settings (input_settings, device, tool);
|
|
|
e47e58 |
+ priv = meta_input_settings_get_instance_private (input_settings);
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ if (tool)
|
|
|
e47e58 |
+ {
|
|
|
e47e58 |
+ CurrentToolInfo *current_tool;
|
|
|
e47e58 |
+
|
|
|
e47e58 |
+ current_tool = current_tool_info_new (input_settings, device, tool);
|
|
|
e47e58 |
+ g_hash_table_insert (priv->current_tools, device, current_tool);
|
|
|
e47e58 |
+ apply_stylus_settings (input_settings, device, tool);
|
|
|
e47e58 |
+ }
|
|
|
e47e58 |
+ else
|
|
|
e47e58 |
+ {
|
|
|
e47e58 |
+ g_hash_table_remove (priv->current_tools, device);
|
|
|
e47e58 |
+ }
|
|
|
e47e58 |
}
|
|
|
e47e58 |
|
|
|
e47e58 |
static void
|
|
|
e47e58 |
@@ -1616,6 +1678,9 @@ meta_input_settings_init (MetaInputSettings *settings)
|
|
|
e47e58 |
priv->mappable_devices =
|
|
|
e47e58 |
g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) device_mapping_info_free);
|
|
|
e47e58 |
|
|
|
e47e58 |
+ priv->current_tools =
|
|
|
e47e58 |
+ g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) current_tool_info_free);
|
|
|
e47e58 |
+
|
|
|
e47e58 |
priv->monitor_manager = g_object_ref (meta_monitor_manager_get ());
|
|
|
e47e58 |
g_signal_connect (priv->monitor_manager, "monitors-changed-internal",
|
|
|
e47e58 |
G_CALLBACK (monitors_changed_cb), settings);
|
|
|
e47e58 |
--
|
|
|
e47e58 |
2.16.1
|
|
|
e47e58 |
|