mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
backends/native: Move MetaInputSettings ownership to MetaSeatImpl
Together with keymaps and devices, MetaInputSettings will live in the ninth circle of hell with MetaSeatImpl, forever tied to it. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403
This commit is contained in:
parent
09e02a772e
commit
abd858fb69
@ -124,13 +124,36 @@ update_viewports (MetaBackend *backend)
|
||||
g_object_unref (viewports);
|
||||
}
|
||||
|
||||
static void
|
||||
kbd_a11y_changed_cb (MetaInputSettings *input_settings,
|
||||
MetaKbdA11ySettings *a11y_settings,
|
||||
MetaBackend *backend)
|
||||
{
|
||||
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
||||
ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend);
|
||||
ClutterInputDevice *device;
|
||||
|
||||
device = clutter_seat_get_keyboard (seat);
|
||||
if (device)
|
||||
meta_input_device_native_apply_kbd_a11y_settings (META_INPUT_DEVICE_NATIVE (device),
|
||||
a11y_settings);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_native_post_init (MetaBackend *backend)
|
||||
{
|
||||
MetaBackendNative *native = META_BACKEND_NATIVE (backend);
|
||||
MetaSettings *settings = meta_backend_get_settings (backend);
|
||||
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
||||
MetaSeatNative *seat =
|
||||
META_SEAT_NATIVE (clutter_backend_get_default_seat (clutter_backend));
|
||||
|
||||
META_BACKEND_CLASS (meta_backend_native_parent_class)->post_init (backend);
|
||||
|
||||
native->input_settings = meta_seat_impl_get_input_settings (seat->impl);
|
||||
g_signal_connect_object (native->input_settings, "kbd-a11y-changed",
|
||||
G_CALLBACK (kbd_a11y_changed_cb), backend, 0);
|
||||
|
||||
if (meta_settings_is_experimental_feature_enabled (settings,
|
||||
META_EXPERIMENTAL_FEATURE_RT_SCHEDULER))
|
||||
{
|
||||
@ -192,34 +215,11 @@ meta_backend_native_create_renderer (MetaBackend *backend,
|
||||
return META_RENDERER (renderer_native);
|
||||
}
|
||||
|
||||
static void
|
||||
kbd_a11y_changed_cb (MetaInputSettings *input_settings,
|
||||
MetaKbdA11ySettings *a11y_settings,
|
||||
MetaBackend *backend)
|
||||
{
|
||||
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
||||
ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend);
|
||||
ClutterInputDevice *device;
|
||||
|
||||
device = clutter_seat_get_keyboard (seat);
|
||||
if (device)
|
||||
meta_input_device_native_apply_kbd_a11y_settings (META_INPUT_DEVICE_NATIVE (device),
|
||||
a11y_settings);
|
||||
}
|
||||
|
||||
static MetaInputSettings *
|
||||
meta_backend_native_create_input_settings (MetaBackend *backend)
|
||||
{
|
||||
MetaBackendNative *native = META_BACKEND_NATIVE (backend);
|
||||
|
||||
if (!native->input_settings)
|
||||
{
|
||||
native->input_settings = g_object_new (META_TYPE_INPUT_SETTINGS_NATIVE,
|
||||
NULL);
|
||||
g_signal_connect_object (native->input_settings, "kbd-a11y-changed",
|
||||
G_CALLBACK (kbd_a11y_changed_cb), backend, 0);
|
||||
}
|
||||
|
||||
return native->input_settings;
|
||||
}
|
||||
|
||||
|
@ -246,10 +246,11 @@ clear_slow_keys (MetaInputDeviceNative *device)
|
||||
static guint
|
||||
get_slow_keys_delay (ClutterInputDevice *device)
|
||||
{
|
||||
MetaInputDeviceNative *device_native = META_INPUT_DEVICE_NATIVE (device);
|
||||
MetaKbdA11ySettings a11y_settings;
|
||||
MetaInputSettings *input_settings;
|
||||
|
||||
input_settings = meta_backend_get_input_settings (meta_get_backend ());
|
||||
input_settings = meta_seat_impl_get_input_settings (device_native->seat_impl);
|
||||
meta_input_settings_get_kbd_a11y_settings (input_settings, &a11y_settings);
|
||||
/* Settings use int, we use uint, make sure we dont go negative */
|
||||
return MAX (0, a11y_settings.slowkeys_delay);
|
||||
@ -342,10 +343,11 @@ stop_slow_keys (ClutterEvent *event,
|
||||
static guint
|
||||
get_debounce_delay (ClutterInputDevice *device)
|
||||
{
|
||||
MetaInputDeviceNative *device_native = META_INPUT_DEVICE_NATIVE (device);
|
||||
MetaKbdA11ySettings a11y_settings;
|
||||
MetaInputSettings *input_settings;
|
||||
|
||||
input_settings = meta_backend_get_input_settings (meta_get_backend ());
|
||||
input_settings = meta_seat_impl_get_input_settings (device_native->seat_impl);
|
||||
meta_input_settings_get_kbd_a11y_settings (input_settings, &a11y_settings);
|
||||
/* Settings use int, we use uint, make sure we dont go negative */
|
||||
return MAX (0, a11y_settings.debounce_delay);
|
||||
|
@ -33,6 +33,55 @@
|
||||
|
||||
G_DEFINE_TYPE (MetaInputSettingsNative, meta_input_settings_native, META_TYPE_INPUT_SETTINGS)
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_SEAT_IMPL,
|
||||
N_PROPS,
|
||||
};
|
||||
|
||||
GParamSpec *props[N_PROPS] = { 0 };
|
||||
|
||||
static void
|
||||
meta_input_settings_native_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaInputSettingsNative *input_settings_native =
|
||||
META_INPUT_SETTINGS_NATIVE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SEAT_IMPL:
|
||||
input_settings_native->seat_impl = g_value_get_object (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_settings_native_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaInputSettingsNative *input_settings_native =
|
||||
META_INPUT_SETTINGS_NATIVE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SEAT_IMPL:
|
||||
g_value_set_object (value, input_settings_native->seat_impl);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_settings_native_set_send_events (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
@ -386,10 +435,10 @@ meta_input_settings_native_set_keyboard_repeat (MetaInputSettings *settings,
|
||||
guint delay,
|
||||
guint interval)
|
||||
{
|
||||
ClutterSeat *seat;
|
||||
MetaInputSettingsNative *input_settings_native;
|
||||
|
||||
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
||||
meta_seat_impl_set_keyboard_repeat (META_SEAT_NATIVE (seat)->impl,
|
||||
input_settings_native = META_INPUT_SETTINGS_NATIVE (settings);
|
||||
meta_seat_impl_set_keyboard_repeat (input_settings_native->seat_impl,
|
||||
enabled, delay, interval);
|
||||
}
|
||||
|
||||
@ -675,6 +724,10 @@ static void
|
||||
meta_input_settings_native_class_init (MetaInputSettingsNativeClass *klass)
|
||||
{
|
||||
MetaInputSettingsClass *input_settings_class = META_INPUT_SETTINGS_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = meta_input_settings_native_set_property;
|
||||
object_class->get_property = meta_input_settings_native_get_property;
|
||||
|
||||
input_settings_class->set_send_events = meta_input_settings_native_set_send_events;
|
||||
input_settings_class->set_matrix = meta_input_settings_native_set_matrix;
|
||||
@ -709,9 +762,27 @@ meta_input_settings_native_class_init (MetaInputSettingsNativeClass *klass)
|
||||
|
||||
input_settings_class->has_two_finger_scroll = meta_input_settings_native_has_two_finger_scroll;
|
||||
input_settings_class->is_trackball_device = meta_input_settings_native_is_trackball_device;
|
||||
|
||||
props[PROP_SEAT_IMPL] =
|
||||
g_param_spec_object ("seat-impl",
|
||||
"Seat Impl",
|
||||
"Seat Impl",
|
||||
PROP_SEAT_IMPL,
|
||||
CLUTTER_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, props);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_settings_native_init (MetaInputSettingsNative *settings)
|
||||
{
|
||||
}
|
||||
|
||||
MetaInputSettings *
|
||||
meta_input_settings_native_new (MetaSeatImpl *seat)
|
||||
{
|
||||
return g_object_new (META_TYPE_INPUT_SETTINGS_NATIVE,
|
||||
"seat-impl", seat,
|
||||
NULL);
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ typedef struct _MetaInputSettingsNativeClass MetaInputSettingsNativeClass;
|
||||
struct _MetaInputSettingsNative
|
||||
{
|
||||
MetaInputSettings parent_instance;
|
||||
MetaSeatImpl *seat_impl;
|
||||
};
|
||||
|
||||
struct _MetaInputSettingsNativeClass
|
||||
@ -46,4 +47,6 @@ struct _MetaInputSettingsNativeClass
|
||||
|
||||
GType meta_input_settings_native_get_type (void) G_GNUC_CONST;
|
||||
|
||||
MetaInputSettings * meta_input_settings_native_new (MetaSeatImpl *seat);
|
||||
|
||||
#endif /* META_INPUT_SETTINGS_NATIVE_H */
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "backends/native/meta-event-native.h"
|
||||
#include "backends/native/meta-input-device-native.h"
|
||||
#include "backends/native/meta-input-device-tool-native.h"
|
||||
#include "backends/native/meta-input-settings-native.h"
|
||||
#include "backends/native/meta-keymap-native.h"
|
||||
#include "backends/native/meta-virtual-input-device-native.h"
|
||||
#include "clutter/clutter-mutter.h"
|
||||
@ -1532,7 +1533,7 @@ process_base_event (MetaSeatImpl *seat,
|
||||
struct libinput_device *libinput_device;
|
||||
MetaInputSettings *input_settings;
|
||||
|
||||
input_settings = meta_backend_get_input_settings (meta_get_backend ());
|
||||
input_settings = seat->input_settings;
|
||||
|
||||
switch (libinput_event_get_type (event))
|
||||
{
|
||||
@ -1614,7 +1615,8 @@ translate_tool_type (struct libinput_tablet_tool *libinput_tool)
|
||||
}
|
||||
|
||||
static void
|
||||
input_device_update_tool (ClutterInputDevice *input_device,
|
||||
input_device_update_tool (MetaSeatImpl *seat,
|
||||
ClutterInputDevice *input_device,
|
||||
struct libinput_tablet_tool *libinput_tool)
|
||||
{
|
||||
MetaInputDeviceNative *evdev_device = META_INPUT_DEVICE_NATIVE (input_device);
|
||||
@ -1641,7 +1643,7 @@ input_device_update_tool (ClutterInputDevice *input_device,
|
||||
if (evdev_device->last_tool != tool)
|
||||
{
|
||||
evdev_device->last_tool = tool;
|
||||
input_settings = meta_backend_get_input_settings (meta_get_backend ());
|
||||
input_settings = seat->input_settings;
|
||||
meta_input_settings_notify_tool_change (input_settings, input_device, tool);
|
||||
}
|
||||
}
|
||||
@ -2224,10 +2226,10 @@ process_device_event (MetaSeatImpl *seat,
|
||||
libinput_tool = libinput_event_tablet_tool_get_tool (tablet_event);
|
||||
|
||||
if (in)
|
||||
input_device_update_tool (device, libinput_tool);
|
||||
input_device_update_tool (seat, device, libinput_tool);
|
||||
notify_proximity (device, time, in);
|
||||
if (!in)
|
||||
input_device_update_tool (device, NULL);
|
||||
input_device_update_tool (seat, device, NULL);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -2480,6 +2482,8 @@ meta_seat_impl_constructed (GObject *object)
|
||||
|
||||
udev_unref (udev);
|
||||
|
||||
seat->input_settings = meta_input_settings_native_new (seat);
|
||||
|
||||
seat->udev_client = g_udev_client_new ((const gchar *[]) { "input", NULL });
|
||||
|
||||
source = meta_event_source_new (seat);
|
||||
@ -3124,7 +3128,7 @@ meta_seat_impl_notify_kbd_a11y_flags_changed (MetaSeatImpl *impl,
|
||||
{
|
||||
MetaInputSettings *input_settings;
|
||||
|
||||
input_settings = meta_backend_get_input_settings (meta_get_backend ());
|
||||
input_settings = impl->input_settings;
|
||||
meta_input_settings_notify_kbd_a11y_change (input_settings,
|
||||
new_flags, what_changed);
|
||||
g_signal_emit (impl, signals[KBD_A11Y_FLAGS_CHANGED], 0,
|
||||
@ -3145,3 +3149,9 @@ meta_seat_impl_notify_bell (MetaSeatImpl *impl)
|
||||
{
|
||||
g_signal_emit (impl, signals[BELL], 0);
|
||||
}
|
||||
|
||||
MetaInputSettings *
|
||||
meta_seat_impl_get_input_settings (MetaSeatImpl *impl)
|
||||
{
|
||||
return impl->input_settings;
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ struct _MetaSeatImpl
|
||||
MetaPointerConstraintImpl *pointer_constraint;
|
||||
|
||||
MetaKeymapNative *keymap;
|
||||
MetaInputSettings *input_settings;
|
||||
|
||||
MetaViewportInfo *viewports;
|
||||
|
||||
@ -263,4 +264,6 @@ void meta_seat_impl_notify_kbd_a11y_mods_state_changed (MetaSeatImpl *impl,
|
||||
xkb_mod_mask_t new_locked_mods);
|
||||
void meta_seat_impl_notify_bell (MetaSeatImpl *impl);
|
||||
|
||||
MetaInputSettings * meta_seat_impl_get_input_settings (MetaSeatImpl *impl);
|
||||
|
||||
#endif /* META_SEAT_IMPL_H */
|
||||
|
Loading…
Reference in New Issue
Block a user