seat-impl: Keep track of virtual input devices too
Virtual input devices too are dealt with inside the input thread, as without this, things like touch mode won't get updated correctly. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
This commit is contained in:
@ -1575,20 +1575,18 @@ meta_input_device_native_new_in_impl (MetaSeatImpl *seat_impl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* meta_input_device_native_new_virtual:
|
* meta_input_device_native_new_virtual_in_impl:
|
||||||
* @seat: the seat the device will belong to
|
* @seat: the seat the device will belong to
|
||||||
* @type: the input device type
|
* @type: the input device type
|
||||||
*
|
*
|
||||||
* Create a new virtual ClutterInputDevice of the given type.
|
* Create a new virtual ClutterInputDevice of the given type.
|
||||||
*/
|
*/
|
||||||
ClutterInputDevice *
|
ClutterInputDevice *
|
||||||
meta_input_device_native_new_virtual (ClutterSeat *seat,
|
meta_input_device_native_new_virtual_in_impl (MetaSeatImpl *seat_impl,
|
||||||
ClutterInputDeviceType type,
|
ClutterInputDeviceType type,
|
||||||
ClutterInputMode mode)
|
ClutterInputMode mode)
|
||||||
{
|
{
|
||||||
MetaInputDeviceNative *device;
|
MetaInputDeviceNative *device;
|
||||||
MetaBackend *backend =
|
|
||||||
meta_seat_native_get_backend (META_SEAT_NATIVE (seat));
|
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
@ -1608,11 +1606,11 @@ meta_input_device_native_new_virtual (ClutterSeat *seat,
|
|||||||
};
|
};
|
||||||
|
|
||||||
device = g_object_new (META_TYPE_INPUT_DEVICE_NATIVE,
|
device = g_object_new (META_TYPE_INPUT_DEVICE_NATIVE,
|
||||||
"backend", backend,
|
"backend", meta_seat_impl_get_backend (seat_impl),
|
||||||
"name", name,
|
"name", name,
|
||||||
"device-type", type,
|
"device-type", type,
|
||||||
"device-mode", mode,
|
"device-mode", mode,
|
||||||
"seat", seat,
|
"seat", seat_impl->seat_native,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
return CLUTTER_INPUT_DEVICE (device);
|
return CLUTTER_INPUT_DEVICE (device);
|
||||||
|
@ -135,9 +135,9 @@ GType meta_input_device_native_get_type (void) G_GNUC
|
|||||||
ClutterInputDevice * meta_input_device_native_new_in_impl (MetaSeatImpl *seat_impl,
|
ClutterInputDevice * meta_input_device_native_new_in_impl (MetaSeatImpl *seat_impl,
|
||||||
struct libinput_device *libinput_device);
|
struct libinput_device *libinput_device);
|
||||||
|
|
||||||
ClutterInputDevice * meta_input_device_native_new_virtual (ClutterSeat *seat,
|
ClutterInputDevice * meta_input_device_native_new_virtual_in_impl (MetaSeatImpl *seat_impl,
|
||||||
ClutterInputDeviceType type,
|
ClutterInputDeviceType type,
|
||||||
ClutterInputMode mode);
|
ClutterInputMode mode);
|
||||||
|
|
||||||
void meta_input_device_native_update_leds_in_impl (MetaInputDeviceNative *device,
|
void meta_input_device_native_update_leds_in_impl (MetaInputDeviceNative *device,
|
||||||
enum libinput_led leds);
|
enum libinput_led leds);
|
||||||
|
@ -1639,6 +1639,9 @@ has_pointer (MetaSeatImpl *seat_impl)
|
|||||||
static gboolean
|
static gboolean
|
||||||
device_is_tablet_switch (MetaInputDeviceNative *device_native)
|
device_is_tablet_switch (MetaInputDeviceNative *device_native)
|
||||||
{
|
{
|
||||||
|
if (!device_native->libinput_device)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (libinput_device_has_capability (device_native->libinput_device,
|
if (libinput_device_has_capability (device_native->libinput_device,
|
||||||
LIBINPUT_DEVICE_CAP_SWITCH) &&
|
LIBINPUT_DEVICE_CAP_SWITCH) &&
|
||||||
libinput_device_switch_has_switch (device_native->libinput_device,
|
libinput_device_switch_has_switch (device_native->libinput_device,
|
||||||
@ -1696,16 +1699,13 @@ update_touch_mode (MetaSeatImpl *seat_impl)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ClutterInputDevice *
|
static void
|
||||||
evdev_add_device (MetaSeatImpl *seat_impl,
|
meta_seat_impl_take_device (MetaSeatImpl *seat_impl,
|
||||||
struct libinput_device *libinput_device)
|
ClutterInputDevice *device)
|
||||||
{
|
{
|
||||||
ClutterInputDeviceType type;
|
ClutterInputDeviceType type;
|
||||||
ClutterInputDevice *device;
|
|
||||||
gboolean is_touchscreen, is_tablet_switch, is_pointer;
|
gboolean is_touchscreen, is_tablet_switch, is_pointer;
|
||||||
|
|
||||||
device = meta_input_device_native_new_in_impl (seat_impl, libinput_device);
|
|
||||||
|
|
||||||
seat_impl->devices = g_slist_prepend (seat_impl->devices, device);
|
seat_impl->devices = g_slist_prepend (seat_impl->devices, device);
|
||||||
meta_seat_impl_sync_leds_in_impl (seat_impl);
|
meta_seat_impl_sync_leds_in_impl (seat_impl);
|
||||||
|
|
||||||
@ -1736,19 +1736,17 @@ evdev_add_device (MetaSeatImpl *seat_impl,
|
|||||||
meta_input_device_native_apply_kbd_a11y_settings_in_impl (keyboard_native,
|
meta_input_device_native_apply_kbd_a11y_settings_in_impl (keyboard_native,
|
||||||
&kbd_a11y_settings);
|
&kbd_a11y_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
return device;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
evdev_remove_device (MetaSeatImpl *seat_impl,
|
meta_seat_impl_remove_device (MetaSeatImpl *seat_impl,
|
||||||
MetaInputDeviceNative *device_native)
|
ClutterInputDevice *device)
|
||||||
{
|
{
|
||||||
ClutterInputDevice *device;
|
MetaInputDeviceNative *device_native;
|
||||||
ClutterInputDeviceType device_type;
|
ClutterInputDeviceType device_type;
|
||||||
gboolean is_touchscreen, is_tablet_switch, is_pointer;
|
gboolean is_touchscreen, is_tablet_switch, is_pointer;
|
||||||
|
|
||||||
device = CLUTTER_INPUT_DEVICE (device_native);
|
device_native = META_INPUT_DEVICE_NATIVE (device);
|
||||||
seat_impl->devices = g_slist_remove (seat_impl->devices, device);
|
seat_impl->devices = g_slist_remove (seat_impl->devices, device);
|
||||||
|
|
||||||
device_type = clutter_input_device_get_device_type (device);
|
device_type = clutter_input_device_get_device_type (device);
|
||||||
@ -1791,7 +1789,9 @@ process_base_event (MetaSeatImpl *seat_impl,
|
|||||||
case LIBINPUT_EVENT_DEVICE_ADDED:
|
case LIBINPUT_EVENT_DEVICE_ADDED:
|
||||||
libinput_device = libinput_event_get_device (event);
|
libinput_device = libinput_event_get_device (event);
|
||||||
|
|
||||||
device = evdev_add_device (seat_impl, libinput_device);
|
device = meta_input_device_native_new_in_impl (seat_impl,
|
||||||
|
libinput_device);
|
||||||
|
meta_seat_impl_take_device (seat_impl, device);
|
||||||
device_event =
|
device_event =
|
||||||
clutter_event_device_notify_new (CLUTTER_DEVICE_ADDED,
|
clutter_event_device_notify_new (CLUTTER_DEVICE_ADDED,
|
||||||
CLUTTER_EVENT_NONE,
|
CLUTTER_EVENT_NONE,
|
||||||
@ -1811,8 +1811,7 @@ process_base_event (MetaSeatImpl *seat_impl,
|
|||||||
CLUTTER_CURRENT_TIME,
|
CLUTTER_CURRENT_TIME,
|
||||||
device);
|
device);
|
||||||
meta_input_settings_remove_device (input_settings, device);
|
meta_input_settings_remove_device (input_settings, device);
|
||||||
evdev_remove_device (seat_impl,
|
meta_seat_impl_remove_device (seat_impl, device);
|
||||||
META_INPUT_DEVICE_NATIVE (device));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -2877,6 +2876,29 @@ init_libinput_source (MetaSeatImpl *seat_impl)
|
|||||||
g_source_unref (source);
|
g_source_unref (source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_core_devices (MetaSeatImpl *seat_impl)
|
||||||
|
{
|
||||||
|
ClutterInputDevice *device;
|
||||||
|
|
||||||
|
device =
|
||||||
|
meta_input_device_native_new_virtual_in_impl (seat_impl,
|
||||||
|
CLUTTER_POINTER_DEVICE,
|
||||||
|
CLUTTER_INPUT_MODE_LOGICAL);
|
||||||
|
seat_impl->pointer_x = INITIAL_POINTER_X;
|
||||||
|
seat_impl->pointer_y = INITIAL_POINTER_Y;
|
||||||
|
meta_input_device_native_set_coords_in_impl (META_INPUT_DEVICE_NATIVE (device),
|
||||||
|
seat_impl->pointer_x,
|
||||||
|
seat_impl->pointer_y);
|
||||||
|
seat_impl->core_pointer = device;
|
||||||
|
|
||||||
|
device =
|
||||||
|
meta_input_device_native_new_virtual_in_impl (seat_impl,
|
||||||
|
CLUTTER_KEYBOARD_DEVICE,
|
||||||
|
CLUTTER_INPUT_MODE_LOGICAL);
|
||||||
|
seat_impl->core_keyboard = device;
|
||||||
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
input_thread (MetaSeatImpl *seat_impl)
|
input_thread (MetaSeatImpl *seat_impl)
|
||||||
{
|
{
|
||||||
@ -2896,6 +2918,8 @@ input_thread (MetaSeatImpl *seat_impl)
|
|||||||
"Mutter Input Thread");
|
"Mutter Input Thread");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
init_core_devices (seat_impl);
|
||||||
|
|
||||||
priv->device_files =
|
priv->device_files =
|
||||||
g_hash_table_new_full (NULL, NULL,
|
g_hash_table_new_full (NULL, NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@ -2986,31 +3010,6 @@ meta_seat_impl_initable_init (GInitable *initable,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
meta_seat_impl_constructed (GObject *object)
|
|
||||||
{
|
|
||||||
MetaSeatImpl *seat_impl = META_SEAT_IMPL (object);
|
|
||||||
ClutterInputDevice *device;
|
|
||||||
|
|
||||||
device = meta_input_device_native_new_virtual (
|
|
||||||
CLUTTER_SEAT (seat_impl->seat_native), CLUTTER_POINTER_DEVICE,
|
|
||||||
CLUTTER_INPUT_MODE_LOGICAL);
|
|
||||||
seat_impl->pointer_x = INITIAL_POINTER_X;
|
|
||||||
seat_impl->pointer_y = INITIAL_POINTER_Y;
|
|
||||||
meta_input_device_native_set_coords_in_impl (META_INPUT_DEVICE_NATIVE (device),
|
|
||||||
seat_impl->pointer_x,
|
|
||||||
seat_impl->pointer_y);
|
|
||||||
seat_impl->core_pointer = device;
|
|
||||||
|
|
||||||
device = meta_input_device_native_new_virtual (
|
|
||||||
CLUTTER_SEAT (seat_impl->seat_native), CLUTTER_KEYBOARD_DEVICE,
|
|
||||||
CLUTTER_INPUT_MODE_LOGICAL);
|
|
||||||
seat_impl->core_keyboard = device;
|
|
||||||
|
|
||||||
if (G_OBJECT_CLASS (meta_seat_impl_parent_class)->constructed)
|
|
||||||
G_OBJECT_CLASS (meta_seat_impl_parent_class)->constructed (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_seat_impl_set_property (GObject *object,
|
meta_seat_impl_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
@ -3307,7 +3306,6 @@ meta_seat_impl_class_init (MetaSeatImplClass *klass)
|
|||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->constructed = meta_seat_impl_constructed;
|
|
||||||
object_class->set_property = meta_seat_impl_set_property;
|
object_class->set_property = meta_seat_impl_set_property;
|
||||||
object_class->get_property = meta_seat_impl_get_property;
|
object_class->get_property = meta_seat_impl_get_property;
|
||||||
object_class->finalize = meta_seat_impl_finalize;
|
object_class->finalize = meta_seat_impl_finalize;
|
||||||
@ -3901,3 +3899,34 @@ meta_seat_impl_get_backend (MetaSeatImpl *seat_impl)
|
|||||||
{
|
{
|
||||||
return meta_seat_native_get_backend (seat_impl->seat_native);
|
return meta_seat_native_get_backend (seat_impl->seat_native);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_seat_impl_add_virtual_input_device (MetaSeatImpl *seat_impl,
|
||||||
|
ClutterInputDevice *device)
|
||||||
|
{
|
||||||
|
ClutterEvent *device_event;
|
||||||
|
|
||||||
|
meta_seat_impl_take_device (seat_impl, g_object_ref (device));
|
||||||
|
|
||||||
|
device_event =
|
||||||
|
clutter_event_device_notify_new (CLUTTER_DEVICE_ADDED,
|
||||||
|
CLUTTER_EVENT_NONE,
|
||||||
|
CLUTTER_CURRENT_TIME,
|
||||||
|
device);
|
||||||
|
queue_event (seat_impl, device_event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_seat_impl_remove_virtual_input_device (MetaSeatImpl *seat_impl,
|
||||||
|
ClutterInputDevice *device)
|
||||||
|
{
|
||||||
|
ClutterEvent *device_event;
|
||||||
|
|
||||||
|
meta_seat_impl_remove_device (seat_impl, device);
|
||||||
|
|
||||||
|
device_event = clutter_event_device_notify_new (CLUTTER_DEVICE_REMOVED,
|
||||||
|
CLUTTER_EVENT_NONE,
|
||||||
|
CLUTTER_CURRENT_TIME,
|
||||||
|
device);
|
||||||
|
queue_event (seat_impl, device_event);
|
||||||
|
}
|
||||||
|
@ -257,3 +257,9 @@ void meta_seat_impl_queue_main_thread_idle (MetaSeatImpl *seat_impl,
|
|||||||
GDestroyNotify destroy_notify);
|
GDestroyNotify destroy_notify);
|
||||||
|
|
||||||
MetaBackend * meta_seat_impl_get_backend (MetaSeatImpl *seat_impl);
|
MetaBackend * meta_seat_impl_get_backend (MetaSeatImpl *seat_impl);
|
||||||
|
|
||||||
|
void meta_seat_impl_add_virtual_input_device (MetaSeatImpl *seat_impl,
|
||||||
|
ClutterInputDevice *device);
|
||||||
|
|
||||||
|
void meta_seat_impl_remove_virtual_input_device (MetaSeatImpl *seat_impl,
|
||||||
|
ClutterInputDevice *device);
|
||||||
|
@ -45,6 +45,7 @@ typedef struct _ImplState ImplState;
|
|||||||
|
|
||||||
struct _ImplState
|
struct _ImplState
|
||||||
{
|
{
|
||||||
|
MetaSeatImpl *seat_impl;
|
||||||
ClutterInputDevice *device;
|
ClutterInputDevice *device;
|
||||||
int button_count[KEY_CNT];
|
int button_count[KEY_CNT];
|
||||||
};
|
};
|
||||||
@ -159,14 +160,10 @@ static gboolean
|
|||||||
release_device_in_impl (GTask *task)
|
release_device_in_impl (GTask *task)
|
||||||
{
|
{
|
||||||
ImplState *impl_state = g_task_get_task_data (task);
|
ImplState *impl_state = g_task_get_task_data (task);
|
||||||
ClutterSeat *seat;
|
MetaSeatImpl *seat_impl = impl_state->seat_impl;
|
||||||
MetaSeatImpl *seat_impl;
|
|
||||||
int code;
|
int code;
|
||||||
uint64_t time_us;
|
uint64_t time_us;
|
||||||
ClutterEvent *device_event;
|
|
||||||
|
|
||||||
seat = clutter_input_device_get_seat (impl_state->device);
|
|
||||||
seat_impl = META_SEAT_NATIVE (seat)->impl;
|
|
||||||
time_us = g_get_monotonic_time ();
|
time_us = g_get_monotonic_time ();
|
||||||
|
|
||||||
meta_topic (META_DEBUG_INPUT,
|
meta_topic (META_DEBUG_INPUT,
|
||||||
@ -200,11 +197,7 @@ release_device_in_impl (GTask *task)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
device_event = clutter_event_device_notify_new (CLUTTER_DEVICE_REMOVED,
|
meta_seat_impl_remove_virtual_input_device (seat_impl, impl_state->device);
|
||||||
CLUTTER_EVENT_NONE,
|
|
||||||
time_us,
|
|
||||||
impl_state->device);
|
|
||||||
_clutter_event_push (device_event, FALSE);
|
|
||||||
|
|
||||||
g_clear_object (&impl_state->device);
|
g_clear_object (&impl_state->device);
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
@ -243,7 +236,7 @@ meta_virtual_input_device_native_notify_relative_motion (ClutterVirtualInputDevi
|
|||||||
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
g_return_if_fail (virtual_evdev->impl_state->device != NULL);
|
g_return_if_fail (virtual_evdev->impl_state != NULL);
|
||||||
|
|
||||||
event = g_new0 (MetaVirtualEventMotion, 1);
|
event = g_new0 (MetaVirtualEventMotion, 1);
|
||||||
event->time_us = time_us;
|
event->time_us = time_us;
|
||||||
@ -288,7 +281,7 @@ meta_virtual_input_device_native_notify_absolute_motion (ClutterVirtualInputDevi
|
|||||||
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
g_return_if_fail (virtual_evdev->impl_state->device != NULL);
|
g_return_if_fail (virtual_evdev->impl_state != NULL);
|
||||||
|
|
||||||
event = g_new0 (MetaVirtualEventMotion, 1);
|
event = g_new0 (MetaVirtualEventMotion, 1);
|
||||||
event->time_us = time_us;
|
event->time_us = time_us;
|
||||||
@ -362,7 +355,7 @@ meta_virtual_input_device_native_notify_button (ClutterVirtualInputDevice *virtu
|
|||||||
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
g_return_if_fail (virtual_evdev->impl_state->device != NULL);
|
g_return_if_fail (virtual_evdev->impl_state != NULL);
|
||||||
|
|
||||||
event = g_new0 (MetaVirtualEventButton, 1);
|
event = g_new0 (MetaVirtualEventButton, 1);
|
||||||
event->time_us = time_us;
|
event->time_us = time_us;
|
||||||
@ -432,7 +425,7 @@ meta_virtual_input_device_native_notify_key (ClutterVirtualInputDevice *virtual_
|
|||||||
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
g_return_if_fail (virtual_evdev->impl_state->device != NULL);
|
g_return_if_fail (virtual_evdev->impl_state != NULL);
|
||||||
|
|
||||||
event = g_new0 (MetaVirtualEventKey, 1);
|
event = g_new0 (MetaVirtualEventKey, 1);
|
||||||
event->time_us = time_us;
|
event->time_us = time_us;
|
||||||
@ -622,7 +615,7 @@ meta_virtual_input_device_native_notify_keyval (ClutterVirtualInputDevice *virtu
|
|||||||
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
g_return_if_fail (virtual_evdev->impl_state->device != NULL);
|
g_return_if_fail (virtual_evdev->impl_state != NULL);
|
||||||
|
|
||||||
event = g_new0 (MetaVirtualEventKey, 1);
|
event = g_new0 (MetaVirtualEventKey, 1);
|
||||||
event->time_us = time_us;
|
event->time_us = time_us;
|
||||||
@ -701,7 +694,7 @@ meta_virtual_input_device_native_notify_discrete_scroll (ClutterVirtualInputDevi
|
|||||||
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
g_return_if_fail (virtual_evdev->impl_state->device != NULL);
|
g_return_if_fail (virtual_evdev->impl_state != NULL);
|
||||||
|
|
||||||
event = g_new0 (MetaVirtualEventScroll, 1);
|
event = g_new0 (MetaVirtualEventScroll, 1);
|
||||||
event->time_us = time_us;
|
event->time_us = time_us;
|
||||||
@ -762,7 +755,7 @@ meta_virtual_input_device_native_notify_scroll_continuous (ClutterVirtualInputDe
|
|||||||
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
g_return_if_fail (virtual_evdev->impl_state->device != NULL);
|
g_return_if_fail (virtual_evdev->impl_state != NULL);
|
||||||
|
|
||||||
event = g_new0 (MetaVirtualEventScroll, 1);
|
event = g_new0 (MetaVirtualEventScroll, 1);
|
||||||
event->time_us = time_us;
|
event->time_us = time_us;
|
||||||
@ -823,7 +816,7 @@ meta_virtual_input_device_native_notify_touch_down (ClutterVirtualInputDevice *v
|
|||||||
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
g_return_if_fail (virtual_evdev->impl_state->device != NULL);
|
g_return_if_fail (virtual_evdev->impl_state != NULL);
|
||||||
|
|
||||||
event = g_new0 (MetaVirtualEventTouch, 1);
|
event = g_new0 (MetaVirtualEventTouch, 1);
|
||||||
event->time_us = time_us;
|
event->time_us = time_us;
|
||||||
@ -883,7 +876,7 @@ meta_virtual_input_device_native_notify_touch_motion (ClutterVirtualInputDevice
|
|||||||
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
g_return_if_fail (virtual_evdev->impl_state->device != NULL);
|
g_return_if_fail (virtual_evdev->impl_state != NULL);
|
||||||
|
|
||||||
event = g_new0 (MetaVirtualEventTouch, 1);
|
event = g_new0 (MetaVirtualEventTouch, 1);
|
||||||
event->time_us = time_us;
|
event->time_us = time_us;
|
||||||
@ -941,7 +934,7 @@ meta_virtual_input_device_native_notify_touch_up (ClutterVirtualInputDevice *vir
|
|||||||
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
g_return_if_fail (virtual_evdev->impl_state->device != NULL);
|
g_return_if_fail (virtual_evdev->impl_state != NULL);
|
||||||
|
|
||||||
event = g_new0 (MetaVirtualEventTouch, 1);
|
event = g_new0 (MetaVirtualEventTouch, 1);
|
||||||
event->time_us = time_us;
|
event->time_us = time_us;
|
||||||
@ -1000,6 +993,29 @@ meta_virtual_input_device_native_set_property (GObject *object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
create_device_in_impl (GTask *task)
|
||||||
|
{
|
||||||
|
ImplState *impl_state = g_task_get_task_data (task);
|
||||||
|
MetaVirtualInputDeviceNative *virtual_evdev =
|
||||||
|
g_task_get_source_object (task);
|
||||||
|
MetaSeatImpl *seat_impl = virtual_evdev->seat->impl;
|
||||||
|
ClutterVirtualInputDevice *virtual_device =
|
||||||
|
CLUTTER_VIRTUAL_INPUT_DEVICE (virtual_evdev);
|
||||||
|
ClutterInputDeviceType device_type =
|
||||||
|
clutter_virtual_input_device_get_device_type (virtual_device);
|
||||||
|
|
||||||
|
impl_state->seat_impl = seat_impl;
|
||||||
|
impl_state->device =
|
||||||
|
meta_input_device_native_new_virtual_in_impl (seat_impl,
|
||||||
|
device_type,
|
||||||
|
CLUTTER_INPUT_MODE_PHYSICAL);
|
||||||
|
meta_seat_impl_add_virtual_input_device (seat_impl, impl_state->device);
|
||||||
|
|
||||||
|
g_task_return_boolean (task, TRUE);
|
||||||
|
return G_SOURCE_REMOVE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_virtual_input_device_native_constructed (GObject *object)
|
meta_virtual_input_device_native_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
@ -1008,7 +1024,7 @@ meta_virtual_input_device_native_constructed (GObject *object)
|
|||||||
MetaVirtualInputDeviceNative *virtual_evdev =
|
MetaVirtualInputDeviceNative *virtual_evdev =
|
||||||
META_VIRTUAL_INPUT_DEVICE_NATIVE (object);
|
META_VIRTUAL_INPUT_DEVICE_NATIVE (object);
|
||||||
ClutterInputDeviceType device_type;
|
ClutterInputDeviceType device_type;
|
||||||
ClutterEvent *device_event = NULL;
|
g_autoptr (GTask) task = NULL;
|
||||||
|
|
||||||
device_type = clutter_virtual_input_device_get_device_type (virtual_device);
|
device_type = clutter_virtual_input_device_get_device_type (virtual_device);
|
||||||
|
|
||||||
@ -1017,17 +1033,11 @@ meta_virtual_input_device_native_constructed (GObject *object)
|
|||||||
device_type, virtual_device);
|
device_type, virtual_device);
|
||||||
|
|
||||||
virtual_evdev->impl_state = g_new0 (ImplState, 1);
|
virtual_evdev->impl_state = g_new0 (ImplState, 1);
|
||||||
virtual_evdev->impl_state->device =
|
|
||||||
meta_input_device_native_new_virtual (CLUTTER_SEAT (virtual_evdev->seat),
|
|
||||||
device_type,
|
|
||||||
CLUTTER_INPUT_MODE_PHYSICAL);
|
|
||||||
|
|
||||||
device_event =
|
task = g_task_new (virtual_device, NULL, NULL, NULL);
|
||||||
clutter_event_device_notify_new (CLUTTER_DEVICE_ADDED,
|
g_task_set_task_data (task, virtual_evdev->impl_state, NULL);
|
||||||
CLUTTER_EVENT_NONE,
|
meta_seat_impl_run_input_task (virtual_evdev->seat->impl, task,
|
||||||
CLUTTER_CURRENT_TIME,
|
(GSourceFunc) create_device_in_impl);
|
||||||
virtual_evdev->impl_state->device);
|
|
||||||
_clutter_event_push (device_event, FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user