backends/native: Proxy touch-mode via MetaSeatImpl

Handle this via a MetaSeatImpl signal, as the heuristics that apply
here are based on libinput events. The MetaSeatNative just forwards
the touch-mode changes now.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403
This commit is contained in:
Carlos Garnacho 2020-08-11 17:19:21 +02:00
parent 2e604709df
commit 074d78bd9b
3 changed files with 25 additions and 2 deletions

View File

@ -109,6 +109,7 @@ enum
{ {
KBD_A11Y_FLAGS_CHANGED, KBD_A11Y_FLAGS_CHANGED,
KBD_A11Y_MODS_STATE_CHANGED, KBD_A11Y_MODS_STATE_CHANGED,
TOUCH_MODE,
N_SIGNALS N_SIGNALS
}; };
@ -1443,7 +1444,7 @@ update_touch_mode (MetaSeatImpl *seat)
if (seat->touch_mode != touch_mode) if (seat->touch_mode != touch_mode)
{ {
seat->touch_mode = touch_mode; seat->touch_mode = touch_mode;
g_object_notify (G_OBJECT (seat->seat), "touch-mode"); g_signal_emit (seat, signals[TOUCH_MODE], 0, touch_mode);
} }
} }
@ -2732,6 +2733,13 @@ meta_seat_impl_class_init (MetaSeatImplClass *klass)
0, NULL, NULL, NULL, 0, NULL, NULL, NULL,
G_TYPE_NONE, 2, G_TYPE_NONE, 2,
G_TYPE_UINT, G_TYPE_UINT); G_TYPE_UINT, G_TYPE_UINT);
signals[TOUCH_MODE] =
g_signal_new ("touch-mode",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
g_object_class_install_properties (object_class, N_PROPS, props); g_object_class_install_properties (object_class, N_PROPS, props);
} }

View File

@ -128,6 +128,15 @@ proxy_kbd_a11y_mods_state_changed (MetaSeatImpl *impl,
new_locked_mods); new_locked_mods);
} }
static void
proxy_touch_mode_changed (MetaSeatImpl *impl,
gboolean enabled,
MetaSeatNative *seat_native)
{
seat_native->touch_mode = enabled;
g_object_notify (G_OBJECT (seat_native), "touch-mode");
}
static void static void
meta_seat_native_constructed (GObject *object) meta_seat_native_constructed (GObject *object)
{ {
@ -138,6 +147,8 @@ meta_seat_native_constructed (GObject *object)
G_CALLBACK (proxy_kbd_a11y_flags_changed), seat); G_CALLBACK (proxy_kbd_a11y_flags_changed), seat);
g_signal_connect (seat->impl, "kbd-a11y-mods-state-changed", g_signal_connect (seat->impl, "kbd-a11y-mods-state-changed",
G_CALLBACK (proxy_kbd_a11y_mods_state_changed), seat); G_CALLBACK (proxy_kbd_a11y_mods_state_changed), seat);
g_signal_connect (seat->impl, "touch-mode",
G_CALLBACK (proxy_touch_mode_changed), seat);
seat->core_pointer = meta_seat_impl_get_pointer (seat->impl); seat->core_pointer = meta_seat_impl_get_pointer (seat->impl);
seat->core_keyboard = meta_seat_impl_get_keyboard (seat->impl); seat->core_keyboard = meta_seat_impl_get_keyboard (seat->impl);
@ -181,7 +192,7 @@ meta_seat_native_get_property (GObject *object,
g_value_set_string (value, seat_native->seat_id); g_value_set_string (value, seat_native->seat_id);
break; break;
case PROP_TOUCH_MODE: case PROP_TOUCH_MODE:
g_value_set_boolean (value, seat_native->impl->touch_mode); g_value_set_boolean (value, seat_native->touch_mode);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);

View File

@ -56,6 +56,7 @@ struct _MetaSeatNative
GHashTable *tablet_cursors; GHashTable *tablet_cursors;
gboolean released; gboolean released;
gboolean touch_mode;
}; };
#define META_TYPE_SEAT_NATIVE meta_seat_native_get_type () #define META_TYPE_SEAT_NATIVE meta_seat_native_get_type ()
@ -117,5 +118,8 @@ MetaCursorRenderer * meta_seat_native_get_cursor_renderer (MetaSeatNative *s
void meta_seat_native_set_viewports (MetaSeatNative *seat, void meta_seat_native_set_viewports (MetaSeatNative *seat,
MetaViewportInfo *viewports); MetaViewportInfo *viewports);
void meta_seat_native_notify_kbd_a11y_change (MetaSeatNative *seat,
MetaKeyboardA11yFlags new_flags,
MetaKeyboardA11yFlags what_changed);
#endif /* META_SEAT_NATIVE_H */ #endif /* META_SEAT_NATIVE_H */