[mutter/wip/carlosg/input-thread: 134/159] backends: Make MetaInputMapper take over MetaInputSettings public API
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/input-thread: 134/159] backends: Make MetaInputMapper take over MetaInputSettings public API
- Date: Wed, 12 Aug 2020 17:24:05 +0000 (UTC)
commit a23f6c2be568821d4bdc49ffe5301799c0f212e0
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Aug 4 14:17:39 2020 +0200
backends: Make MetaInputMapper take over MetaInputSettings public API
Banish MetaInputSettings from MetaBackend "public" API, it's now meant to
spend the rest of its days in the backend dungeons, maybe hanging
off a thread.
MetaInputMapper replaces all external uses.
src/backends/meta-backend-private.h | 2 +
src/backends/meta-backend.c | 58 ++++++++++++++++++++++++
src/backends/meta-input-mapper-private.h | 3 +-
src/backends/meta-input-settings-private.h | 5 ---
src/backends/meta-input-settings.c | 72 ------------------------------
src/backends/native/meta-backend-native.c | 16 +++++--
src/core/display.c | 20 ++++-----
7 files changed, 84 insertions(+), 92 deletions(-)
---
diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h
index 6782d77747..dc43bd345e 100644
--- a/src/backends/meta-backend-private.h
+++ b/src/backends/meta-backend-private.h
@@ -34,6 +34,7 @@
#include "backends/meta-backend-types.h"
#include "backends/meta-cursor-renderer.h"
#include "backends/meta-egl.h"
+#include "backends/meta-input-mapper-private.h"
#include "backends/meta-input-settings-private.h"
#include "backends/meta-monitor-manager-private.h"
#include "backends/meta-orientation-manager.h"
@@ -176,6 +177,7 @@ gboolean meta_is_stage_views_enabled (void);
gboolean meta_is_stage_views_scaled (void);
+MetaInputMapper *meta_backend_get_input_mapper (MetaBackend *backend);
MetaInputSettings *meta_backend_get_input_settings (MetaBackend *backend);
void meta_backend_notify_keymap_changed (MetaBackend *backend);
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 46720d285b..3e79978d9e 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -56,6 +56,7 @@
#include "backends/meta-cursor-renderer.h"
#include "backends/meta-cursor-tracker-private.h"
#include "backends/meta-idle-monitor-private.h"
+#include "backends/meta-input-mapper-private.h"
#include "backends/meta-input-settings-private.h"
#include "backends/meta-logical-monitor.h"
#include "backends/meta-monitor-manager-dummy.h"
@@ -123,6 +124,7 @@ struct _MetaBackendPrivate
MetaCursorTracker *cursor_tracker;
GHashTable *cursor_renderers;
MetaInputSettings *input_settings;
+ MetaInputMapper *input_mapper;
MetaRenderer *renderer;
#ifdef HAVE_EGL
MetaEgl *egl;
@@ -380,8 +382,19 @@ on_device_added (ClutterSeat *seat,
gpointer user_data)
{
MetaBackend *backend = META_BACKEND (user_data);
+ MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
+ ClutterInputDeviceType device_type;
create_device_monitor (backend, device);
+ device_type = clutter_input_device_get_device_type (device);
+
+ if (device_type == CLUTTER_TOUCHSCREEN_DEVICE ||
+ device_type == CLUTTER_TABLET_DEVICE ||
+ device_type == CLUTTER_PEN_DEVICE ||
+ device_type == CLUTTER_ERASER_DEVICE ||
+ device_type == CLUTTER_CURSOR_DEVICE ||
+ device_type == CLUTTER_PAD_DEVICE)
+ meta_input_mapper_add_device (priv->input_mapper, device);
}
static inline gboolean
@@ -453,6 +466,8 @@ on_device_removed (ClutterSeat *seat,
destroy_device_monitor (backend, device);
+ meta_input_mapper_remove_device (priv->input_mapper, device);
+
/* If the device the user last interacted goes away, check again pointer
* visibility.
*/
@@ -530,6 +545,33 @@ meta_backend_create_input_settings (MetaBackend *backend)
return META_BACKEND_GET_CLASS (backend)->create_input_settings (backend);
}
+static void
+input_mapper_device_mapped_cb (MetaInputMapper *mapper,
+ ClutterInputDevice *device,
+ float matrix[6],
+ MetaInputSettings *input_settings)
+{
+ meta_input_settings_set_device_matrix (input_settings, device, matrix);
+}
+
+static void
+input_mapper_device_enabled_cb (MetaInputMapper *mapper,
+ ClutterInputDevice *device,
+ gboolean enabled,
+ MetaInputSettings *input_settings)
+{
+ meta_input_settings_set_device_enabled (input_settings, device, enabled);
+}
+
+static void
+input_mapper_device_aspect_ratio_cb (MetaInputMapper *mapper,
+ ClutterInputDevice *device,
+ double aspect_ratio,
+ MetaInputSettings *input_settings)
+{
+ meta_input_settings_set_device_aspect_ratio (input_settings, device, aspect_ratio);
+}
+
static void
meta_backend_real_post_init (MetaBackend *backend)
{
@@ -569,6 +611,14 @@ meta_backend_real_post_init (MetaBackend *backend)
meta_input_settings_maybe_restore_numlock_state (priv->input_settings);
}
+ priv->input_mapper = meta_input_mapper_new ();
+ g_signal_connect (priv->input_mapper, "device-mapped",
+ G_CALLBACK (input_mapper_device_mapped_cb), backend);
+ g_signal_connect (priv->input_mapper, "device-enabled",
+ G_CALLBACK (input_mapper_device_enabled_cb), backend);
+ g_signal_connect (priv->input_mapper, "device-aspect-ratio",
+ G_CALLBACK (input_mapper_device_aspect_ratio_cb), backend);
+
#ifdef HAVE_REMOTE_DESKTOP
priv->dbus_session_watcher = g_object_new (META_TYPE_DBUS_SESSION_WATCHER, NULL);
priv->screen_cast = meta_screen_cast_new (backend,
@@ -1453,6 +1503,14 @@ meta_is_stage_views_scaled (void)
return layout_mode == META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL;
}
+MetaInputMapper *
+meta_backend_get_input_mapper (MetaBackend *backend)
+{
+ MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
+
+ return priv->input_mapper;
+}
+
MetaInputSettings *
meta_backend_get_input_settings (MetaBackend *backend)
{
diff --git a/src/backends/meta-input-mapper-private.h b/src/backends/meta-input-mapper-private.h
index 67ffbe5652..63d480dba7 100644
--- a/src/backends/meta-input-mapper-private.h
+++ b/src/backends/meta-input-mapper-private.h
@@ -23,7 +23,8 @@
#define META_INPUT_MAPPER_H
#include <clutter/clutter.h>
-#include "meta-monitor-manager-private.h"
+
+#include "backends/meta-backend-types.h"
#define META_TYPE_INPUT_MAPPER (meta_input_mapper_get_type ())
diff --git a/src/backends/meta-input-settings-private.h b/src/backends/meta-input-settings-private.h
index d1ba001db5..3c3abde5a3 100644
--- a/src/backends/meta-input-settings-private.h
+++ b/src/backends/meta-input-settings-private.h
@@ -136,11 +136,6 @@ struct _MetaInputSettingsClass
ClutterInputDevice *device);
};
-GSettings * meta_input_settings_get_tablet_settings (MetaInputSettings *settings,
- ClutterInputDevice *device);
-MetaLogicalMonitor * meta_input_settings_get_tablet_logical_monitor (MetaInputSettings *settings,
- ClutterInputDevice *device);
-
void meta_input_settings_maybe_save_numlock_state (MetaInputSettings *input_settings);
void meta_input_settings_maybe_restore_numlock_state (MetaInputSettings *input_settings);
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
index 04bbfc1eef..64d4997a8e 100644
--- a/src/backends/meta-input-settings.c
+++ b/src/backends/meta-input-settings.c
@@ -82,9 +82,6 @@ struct _MetaInputSettingsPrivate
GHashTable *current_tools;
GHashTable *two_finger_devices;
-
- /* For absolute devices with no mapping in settings */
- MetaInputMapper *input_mapper;
};
typedef gboolean (* ConfigBoolMappingFunc) (MetaInputSettings *input_settings,
@@ -141,7 +138,6 @@ meta_input_settings_dispose (GObject *object)
g_clear_object (&priv->gsd_settings);
g_clear_object (&priv->keyboard_a11y_settings);
g_clear_object (&priv->mouse_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);
@@ -1406,33 +1402,6 @@ lookup_tool_settings (ClutterInputDeviceTool *tool,
return tool_settings;
}
-static void
-input_mapper_device_mapped_cb (MetaInputMapper *mapper,
- ClutterInputDevice *device,
- float matrix[6],
- MetaInputSettings *input_settings)
-{
- meta_input_settings_set_device_matrix (input_settings, device, matrix);
-}
-
-static void
-input_mapper_device_enabled_cb (MetaInputMapper *mapper,
- ClutterInputDevice *device,
- gboolean enabled,
- MetaInputSettings *input_settings)
-{
- meta_input_settings_set_device_enabled (input_settings, device, enabled);
-}
-
-static void
-input_mapper_device_aspect_ratio_cb (MetaInputMapper *mapper,
- ClutterInputDevice *device,
- double aspect_ratio,
- MetaInputSettings *input_settings)
-{
- meta_input_settings_set_device_aspect_ratio (input_settings, device, aspect_ratio);
-}
-
static void
device_mapping_info_free (DeviceMappingInfo *info)
{
@@ -1465,8 +1434,6 @@ check_add_mappable_device (MetaInputSettings *input_settings,
if (!settings)
return FALSE;
- meta_input_mapper_add_device (priv->input_mapper, device);
-
priv = meta_input_settings_get_instance_private (input_settings);
info = g_slice_new0 (DeviceMappingInfo);
@@ -1640,7 +1607,6 @@ meta_input_settings_device_removed (ClutterSeat *seat,
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);
@@ -1813,44 +1779,6 @@ meta_input_settings_init (MetaInputSettings *settings)
g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) current_tool_info_free);
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);
- g_signal_connect (priv->input_mapper, "device-enabled",
- G_CALLBACK (input_mapper_device_enabled_cb), settings);
- g_signal_connect (priv->input_mapper, "device-aspect-ratio",
- G_CALLBACK (input_mapper_device_aspect_ratio_cb), settings);
-}
-
-GSettings *
-meta_input_settings_get_tablet_settings (MetaInputSettings *settings,
- ClutterInputDevice *device)
-{
- MetaInputSettingsPrivate *priv;
- DeviceMappingInfo *info;
-
- g_return_val_if_fail (META_IS_INPUT_SETTINGS (settings), NULL);
- g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
-
- priv = meta_input_settings_get_instance_private (settings);
- info = g_hash_table_lookup (priv->mappable_devices, device);
-
- return info ? g_object_ref (info->settings) : NULL;
-}
-
-MetaLogicalMonitor *
-meta_input_settings_get_tablet_logical_monitor (MetaInputSettings *settings,
- ClutterInputDevice *device)
-{
- MetaInputSettingsPrivate *priv;
-
- g_return_val_if_fail (META_IS_INPUT_SETTINGS (settings), NULL);
- g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
-
- priv = meta_input_settings_get_instance_private (settings);
-
- return meta_input_mapper_get_device_logical_monitor (priv->input_mapper, device);
}
void
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index 27c71122f3..7bf2cca3c5 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -69,6 +69,7 @@ struct _MetaBackendNative
MetaLauncher *launcher;
MetaUdev *udev;
MetaKms *kms;
+ MetaInputSettings *input_settings;
gulong udev_device_added_handler_id;
};
@@ -96,6 +97,7 @@ meta_backend_native_finalize (GObject *object)
g_clear_object (&native->udev);
g_clear_object (&native->kms);
meta_launcher_free (native->launcher);
+ g_clear_object (&native->input_settings);
G_OBJECT_CLASS (meta_backend_native_parent_class)->finalize (object);
}
@@ -192,7 +194,15 @@ meta_backend_native_create_renderer (MetaBackend *backend,
static MetaInputSettings *
meta_backend_native_create_input_settings (MetaBackend *backend)
{
- return g_object_new (META_TYPE_INPUT_SETTINGS_NATIVE, NULL);
+ MetaBackendNative *native = META_BACKEND_NATIVE (backend);
+
+ if (!native->input_settings)
+ {
+ native->input_settings = g_object_new (META_TYPE_INPUT_SETTINGS_NATIVE,
+ NULL);
+ }
+
+ return native->input_settings;
}
static MetaLogicalMonitor *
@@ -611,7 +621,6 @@ void meta_backend_native_resume (MetaBackendNative *native)
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerKms *monitor_manager_kms =
META_MONITOR_MANAGER_KMS (monitor_manager);
- MetaInputSettings *input_settings;
MetaIdleMonitor *idle_monitor;
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
MetaSeatNative *seat =
@@ -633,8 +642,7 @@ void meta_backend_native_resume (MetaBackendNative *native)
idle_monitor = meta_idle_monitor_get_core ();
meta_idle_monitor_reset_idletime (idle_monitor);
- input_settings = meta_backend_get_input_settings (backend);
- meta_input_settings_maybe_restore_numlock_state (input_settings);
+ meta_input_settings_maybe_restore_numlock_state (native->input_settings);
clutter_seat_ensure_a11y_state (CLUTTER_SEAT (seat));
}
diff --git a/src/core/display.c b/src/core/display.c
index 221b5b18a6..5663726075 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -45,7 +45,7 @@
#include "backends/meta-cursor-tracker-private.h"
#include "backends/meta-idle-monitor-dbus.h"
#include "backends/meta-input-device-private.h"
-#include "backends/meta-input-settings-private.h"
+#include "backends/meta-input-mapper-private.h"
#include "backends/meta-stage-private.h"
#include "backends/x11/meta-backend-x11.h"
#include "backends/x11/meta-event-x11.h"
@@ -2909,7 +2909,7 @@ meta_display_request_pad_osd (MetaDisplay *display,
gboolean edition_mode)
{
MetaBackend *backend = meta_get_backend ();
- MetaInputSettings *input_settings;
+ MetaInputMapper *input_mapper;
const gchar *layout_path = NULL;
ClutterActor *osd;
MetaLogicalMonitor *logical_monitor;
@@ -2925,13 +2925,13 @@ meta_display_request_pad_osd (MetaDisplay *display,
if (display->current_pad_osd)
return;
- input_settings = meta_backend_get_input_settings (meta_get_backend ());
+ input_mapper = meta_backend_get_input_mapper (meta_get_backend ());
- if (input_settings)
+ if (input_mapper)
{
- settings = meta_input_settings_get_tablet_settings (input_settings, pad);
+ settings = meta_input_mapper_get_tablet_settings (input_mapper, pad);
logical_monitor =
- meta_input_settings_get_tablet_logical_monitor (input_settings, pad);
+ meta_input_mapper_get_device_logical_monitor (input_mapper, pad);
#ifdef HAVE_LIBWACOM
wacom_device = meta_input_device_get_wacom_device (META_INPUT_DEVICE (pad));
layout_path = libwacom_get_layout_filename (wacom_device);
@@ -3015,15 +3015,15 @@ static gint
lookup_tablet_monitor (MetaDisplay *display,
ClutterInputDevice *device)
{
- MetaInputSettings *input_settings;
+ MetaInputMapper *input_mapper;
MetaLogicalMonitor *monitor;
gint monitor_idx = -1;
- input_settings = meta_backend_get_input_settings (meta_get_backend ());
- if (!input_settings)
+ input_mapper = meta_backend_get_input_mapper (meta_get_backend ());
+ if (!input_mapper)
return -1;
- monitor = meta_input_settings_get_tablet_logical_monitor (input_settings, device);
+ monitor = meta_input_mapper_get_device_logical_monitor (input_mapper, device);
if (monitor)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]