mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
clutter/seat: Add private method to peek list of input devices
Add a method to ClutterSeat that allows peeking the list of input devices and allow looping through devices a bit faster. The API left is private so we can make use of peeking the GList internally, but don't have to expose any details to the outside, which means we'd have to eventually stick with a GList forever to avoid breaking API. Since we now have the peek_devices() API internally, we can implement ClutterSeats public list_devices() API using g_list_copy() on the list returned by peek_devices(). https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1275
This commit is contained in:
parent
d4457d1f7f
commit
45c14f74b4
@ -354,6 +354,17 @@ clutter_seat_get_keyboard (ClutterSeat *seat)
|
||||
return CLUTTER_SEAT_GET_CLASS (seat)->get_keyboard (seat);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_seat_peek_devices: (skip)
|
||||
**/
|
||||
const GList *
|
||||
clutter_seat_peek_devices (ClutterSeat *seat)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_SEAT (seat), NULL);
|
||||
|
||||
return CLUTTER_SEAT_GET_CLASS (seat)->peek_devices (seat);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_seat_list_devices:
|
||||
* @seat: a #ClutterSeat
|
||||
@ -370,7 +381,7 @@ clutter_seat_list_devices (ClutterSeat *seat)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_SEAT (seat), NULL);
|
||||
|
||||
return CLUTTER_SEAT_GET_CLASS (seat)->list_devices (seat);
|
||||
return g_list_copy ((GList *)clutter_seat_peek_devices (seat));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -96,7 +96,7 @@ struct _ClutterSeatClass
|
||||
ClutterInputDevice * (* get_pointer) (ClutterSeat *seat);
|
||||
ClutterInputDevice * (* get_keyboard) (ClutterSeat *seat);
|
||||
|
||||
GList * (* list_devices) (ClutterSeat *seat);
|
||||
const GList * (* peek_devices) (ClutterSeat *seat);
|
||||
|
||||
void (* bell_notify) (ClutterSeat *seat);
|
||||
|
||||
@ -133,6 +133,7 @@ CLUTTER_EXPORT
|
||||
ClutterInputDevice * clutter_seat_get_keyboard (ClutterSeat *seat);
|
||||
CLUTTER_EXPORT
|
||||
GList * clutter_seat_list_devices (ClutterSeat *seat);
|
||||
const GList * clutter_seat_peek_devices (ClutterSeat *seat);
|
||||
CLUTTER_EXPORT
|
||||
void clutter_seat_bell_notify (ClutterSeat *seat);
|
||||
|
||||
|
@ -2636,17 +2636,12 @@ meta_seat_native_get_keyboard (ClutterSeat *seat)
|
||||
return seat_native->core_keyboard;
|
||||
}
|
||||
|
||||
static GList *
|
||||
meta_seat_native_list_devices (ClutterSeat *seat)
|
||||
static const GList *
|
||||
meta_seat_native_peek_devices (ClutterSeat *seat)
|
||||
{
|
||||
MetaSeatNative *seat_native = META_SEAT_NATIVE (seat);
|
||||
GList *devices = NULL;
|
||||
GSList *l;
|
||||
|
||||
for (l = seat_native->devices; l; l = l->next)
|
||||
devices = g_list_prepend (devices, l->data);
|
||||
|
||||
return devices;
|
||||
return (const GList *) seat_native->devices;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2771,7 +2766,7 @@ meta_seat_native_class_init (MetaSeatNativeClass *klass)
|
||||
|
||||
seat_class->get_pointer = meta_seat_native_get_pointer;
|
||||
seat_class->get_keyboard = meta_seat_native_get_keyboard;
|
||||
seat_class->list_devices = meta_seat_native_list_devices;
|
||||
seat_class->peek_devices = meta_seat_native_peek_devices;
|
||||
seat_class->bell_notify = meta_seat_native_bell_notify;
|
||||
seat_class->get_keymap = meta_seat_native_get_keymap;
|
||||
seat_class->copy_event_data = meta_seat_native_copy_event_data;
|
||||
|
@ -1471,16 +1471,12 @@ meta_seat_x11_get_keyboard (ClutterSeat *seat)
|
||||
return seat_x11->core_keyboard;
|
||||
}
|
||||
|
||||
static GList *
|
||||
meta_seat_x11_list_devices (ClutterSeat *seat)
|
||||
static const GList *
|
||||
meta_seat_x11_peek_devices (ClutterSeat *seat)
|
||||
{
|
||||
MetaSeatX11 *seat_x11 = META_SEAT_X11 (seat);
|
||||
GList *retval = NULL, *l;
|
||||
|
||||
for (l = seat_x11->devices; l; l = l->next)
|
||||
retval = g_list_prepend (retval, l->data);
|
||||
|
||||
return retval;
|
||||
return (const GList *) seat_x11->devices;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1565,7 +1561,7 @@ meta_seat_x11_class_init (MetaSeatX11Class *klass)
|
||||
|
||||
seat_class->get_pointer = meta_seat_x11_get_pointer;
|
||||
seat_class->get_keyboard = meta_seat_x11_get_keyboard;
|
||||
seat_class->list_devices = meta_seat_x11_list_devices;
|
||||
seat_class->peek_devices = meta_seat_x11_peek_devices;
|
||||
seat_class->bell_notify = meta_seat_x11_bell_notify;
|
||||
seat_class->get_keymap = meta_seat_x11_get_keymap;
|
||||
seat_class->copy_event_data = meta_seat_x11_copy_event_data;
|
||||
|
Loading…
Reference in New Issue
Block a user