evdev: Always create the main seat

There could be times when we may not necessarily see a device appear
at initialization time, like when we're VT switched away when we
initialize, and thus we can't ever rely on a main seat appearing.

Always create a main seat with logical pointer/keyboard devices, and
tie the first physical seat that comes in to the main seat.

https://bugzilla.gnome.org/show_bug.cgi?id=726199
This commit is contained in:
Jasper St. Pierre 2014-03-10 10:25:22 -04:00
parent defe55ff09
commit dcaf5686a2

View File

@ -648,8 +648,7 @@ clutter_seat_evdev_set_libinput_seat (ClutterSeatEvdev *seat,
} }
static ClutterSeatEvdev * static ClutterSeatEvdev *
clutter_seat_evdev_new (ClutterDeviceManagerEvdev *manager_evdev, clutter_seat_evdev_new (ClutterDeviceManagerEvdev *manager_evdev)
struct libinput_seat *libinput_seat)
{ {
ClutterDeviceManager *manager = CLUTTER_DEVICE_MANAGER (manager_evdev); ClutterDeviceManager *manager = CLUTTER_DEVICE_MANAGER (manager_evdev);
ClutterDeviceManagerEvdevPrivate *priv = manager_evdev->priv; ClutterDeviceManagerEvdevPrivate *priv = manager_evdev->priv;
@ -663,8 +662,6 @@ clutter_seat_evdev_new (ClutterDeviceManagerEvdev *manager_evdev,
if (!seat) if (!seat)
return NULL; return NULL;
clutter_seat_evdev_set_libinput_seat (seat, libinput_seat);
device = _clutter_input_device_evdev_new_virtual ( device = _clutter_input_device_evdev_new_virtual (
manager, seat, CLUTTER_POINTER_DEVICE); manager, seat, CLUTTER_POINTER_DEVICE);
_clutter_input_device_set_stage (device, priv->stage); _clutter_input_device_set_stage (device, priv->stage);
@ -672,12 +669,6 @@ clutter_seat_evdev_new (ClutterDeviceManagerEvdev *manager_evdev,
_clutter_device_manager_add_device (manager, device); _clutter_device_manager_add_device (manager, device);
seat->core_pointer = device; seat->core_pointer = device;
/* Clutter has the notion of global "core" pointers and keyboard devices,
* so we need to have a main seat to get them from. Make whatever seat comes
* first the main seat. */
if (priv->main_seat == NULL)
priv->main_seat = seat;
device = _clutter_input_device_evdev_new_virtual ( device = _clutter_input_device_evdev_new_virtual (
manager, seat, CLUTTER_KEYBOARD_DEVICE); manager, seat, CLUTTER_KEYBOARD_DEVICE);
_clutter_input_device_set_stage (device, priv->stage); _clutter_input_device_set_stage (device, priv->stage);
@ -713,6 +704,7 @@ clutter_seat_evdev_new (ClutterDeviceManagerEvdev *manager_evdev,
seat->repeat_delay = 250; /* ms */ seat->repeat_delay = 250; /* ms */
seat->repeat_interval = 33; /* ms */ seat->repeat_interval = 33; /* ms */
priv->seats = g_slist_append (priv->seats, seat);
return seat; return seat;
} }
@ -733,6 +725,7 @@ clutter_seat_evdev_free (ClutterSeatEvdev *seat)
clear_repeat_timer (seat); clear_repeat_timer (seat);
if (seat->libinput_seat)
libinput_seat_unref (seat->libinput_seat); libinput_seat_unref (seat->libinput_seat);
g_free (seat); g_free (seat);
@ -766,8 +759,15 @@ evdev_add_device (ClutterDeviceManagerEvdev *manager_evdev,
seat = libinput_seat_get_user_data (libinput_seat); seat = libinput_seat_get_user_data (libinput_seat);
if (seat == NULL) if (seat == NULL)
{ {
seat = clutter_seat_evdev_new (manager_evdev, libinput_seat); /* Clutter has the notion of global "core" pointers and keyboard devices,
priv->seats = g_slist_append (priv->seats, seat); * which are located on the main seat. Make whatever seat comes first the
* main seat. */
if (priv->main_seat->libinput_seat == NULL)
seat = priv->main_seat;
else
seat = clutter_seat_evdev_new (manager_evdev);
clutter_seat_evdev_set_libinput_seat (seat, libinput_seat);
} }
device = _clutter_input_device_evdev_new (manager, seat, libinput_device); device = _clutter_input_device_evdev_new (manager, seat, libinput_device);
@ -1199,10 +1199,9 @@ clutter_device_manager_evdev_constructed (GObject *gobject)
return; return;
} }
dispatch_libinput (manager_evdev); priv->main_seat = clutter_seat_evdev_new (manager_evdev);
g_assert (priv->main_seat != NULL); dispatch_libinput (manager_evdev);
g_assert (priv->main_seat->core_pointer != NULL);
source = clutter_event_source_new (manager_evdev); source = clutter_event_source_new (manager_evdev);
priv->event_source = source; priv->event_source = source;