mirror of
https://github.com/brl/mutter.git
synced 2025-02-08 17:44:09 +00:00
wayland: Move strips/rings management back to MetaWaylandTabletPad
This is best for 2 reasons: - It's feels cleaner doing first creation of rings/strips and then the group assignment. The other option is making groups iterate other all rings/strips and selectively skip those not meant for it, which sounds somewhat redundant. - Some minimal accounting of rings/strips without group restrictions is needed for meta_wayland_tablet_pad_get_label(). The rings/strips memory is now owned by MetaWaylandTabletPad instead of groups, which is sort of meaningless since all are meant to go at the same time.
This commit is contained in:
parent
62e4954c96
commit
138a47b8f9
@ -50,29 +50,12 @@ MetaWaylandTabletPadGroup *
|
|||||||
meta_wayland_tablet_pad_group_new (MetaWaylandTabletPad *pad)
|
meta_wayland_tablet_pad_group_new (MetaWaylandTabletPad *pad)
|
||||||
{
|
{
|
||||||
MetaWaylandTabletPadGroup *group;
|
MetaWaylandTabletPadGroup *group;
|
||||||
guint n_elems, i;
|
|
||||||
|
|
||||||
group = g_slice_new0 (MetaWaylandTabletPadGroup);
|
group = g_slice_new0 (MetaWaylandTabletPadGroup);
|
||||||
wl_list_init (&group->resource_list);
|
wl_list_init (&group->resource_list);
|
||||||
wl_list_init (&group->focus_resource_list);
|
wl_list_init (&group->focus_resource_list);
|
||||||
group->pad = pad;
|
group->pad = pad;
|
||||||
|
|
||||||
n_elems = clutter_input_device_get_n_rings (pad->device);
|
|
||||||
|
|
||||||
for (i = 0; i < n_elems; i++)
|
|
||||||
{
|
|
||||||
group->rings = g_list_prepend (group->rings,
|
|
||||||
meta_wayland_tablet_pad_ring_new (pad));
|
|
||||||
}
|
|
||||||
|
|
||||||
n_elems = clutter_input_device_get_n_strips (pad->device);
|
|
||||||
|
|
||||||
for (i = 0; i < n_elems; i++)
|
|
||||||
{
|
|
||||||
group->strips = g_list_prepend (group->strips,
|
|
||||||
meta_wayland_tablet_pad_strip_new (pad));
|
|
||||||
}
|
|
||||||
|
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +63,6 @@ void
|
|||||||
meta_wayland_tablet_pad_group_free (MetaWaylandTabletPadGroup *group)
|
meta_wayland_tablet_pad_group_free (MetaWaylandTabletPadGroup *group)
|
||||||
{
|
{
|
||||||
struct wl_resource *resource, *next;
|
struct wl_resource *resource, *next;
|
||||||
GList *l;
|
|
||||||
|
|
||||||
wl_resource_for_each_safe (resource, next, &group->resource_list)
|
wl_resource_for_each_safe (resource, next, &group->resource_list)
|
||||||
{
|
{
|
||||||
@ -88,11 +70,6 @@ meta_wayland_tablet_pad_group_free (MetaWaylandTabletPadGroup *group)
|
|||||||
wl_list_init (wl_resource_get_link (resource));
|
wl_list_init (wl_resource_get_link (resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (l = group->rings; l; l = l->next)
|
|
||||||
meta_wayland_tablet_pad_ring_free (l->data);
|
|
||||||
for (l = group->strips; l; l = l->next)
|
|
||||||
meta_wayland_tablet_pad_strip_free (l->data);
|
|
||||||
|
|
||||||
g_list_free (group->rings);
|
g_list_free (group->rings);
|
||||||
g_list_free (group->strips);
|
g_list_free (group->strips);
|
||||||
|
|
||||||
|
@ -61,13 +61,81 @@ pad_handle_focus_surface_destroy (struct wl_listener *listener,
|
|||||||
meta_wayland_tablet_pad_set_focus (pad, NULL);
|
meta_wayland_tablet_pad_set_focus (pad, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
group_rings_strips (MetaWaylandTabletPad *pad)
|
||||||
|
{
|
||||||
|
gint n_group, n_elem;
|
||||||
|
GList *g, *l;
|
||||||
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
|
MetaBackend *backend = meta_get_backend ();
|
||||||
|
struct libinput_device *libinput_device = NULL;
|
||||||
|
|
||||||
|
if (META_IS_BACKEND_NATIVE (backend))
|
||||||
|
libinput_device = clutter_evdev_input_device_get_libinput_device (pad->device);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (n_group = 0, g = pad->groups; g; g = g->next)
|
||||||
|
{
|
||||||
|
MetaWaylandTabletPadGroup *group = g->data;
|
||||||
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
|
struct libinput_tablet_pad_mode_group *mode_group = NULL;
|
||||||
|
|
||||||
|
if (libinput_device)
|
||||||
|
mode_group = libinput_device_tablet_pad_get_mode_group (libinput_device, n_group);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (n_elem = 0, l = pad->rings; l; l = l->next)
|
||||||
|
{
|
||||||
|
MetaWaylandTabletPadRing *ring = l->data;
|
||||||
|
|
||||||
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
|
if (mode_group)
|
||||||
|
{
|
||||||
|
if (libinput_tablet_pad_mode_group_has_ring (mode_group, n_elem))
|
||||||
|
meta_wayland_tablet_pad_ring_set_group (ring, group);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* Assign everything to the first group */
|
||||||
|
if (n_group == 0)
|
||||||
|
meta_wayland_tablet_pad_ring_set_group (ring, group);
|
||||||
|
}
|
||||||
|
n_elem++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (n_elem = 0, l = pad->strips; l; l = l->next)
|
||||||
|
{
|
||||||
|
MetaWaylandTabletPadStrip *strip = l->data;
|
||||||
|
|
||||||
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
|
if (mode_group)
|
||||||
|
{
|
||||||
|
if (libinput_tablet_pad_mode_group_has_strip (mode_group, n_elem))
|
||||||
|
meta_wayland_tablet_pad_strip_set_group (strip, group);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* Assign everything to the first group */
|
||||||
|
if (n_group == 0)
|
||||||
|
meta_wayland_tablet_pad_strip_set_group (strip, group);
|
||||||
|
}
|
||||||
|
|
||||||
|
n_elem++;
|
||||||
|
}
|
||||||
|
|
||||||
|
n_group++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MetaWaylandTabletPad *
|
MetaWaylandTabletPad *
|
||||||
meta_wayland_tablet_pad_new (ClutterInputDevice *device,
|
meta_wayland_tablet_pad_new (ClutterInputDevice *device,
|
||||||
MetaWaylandTabletSeat *tablet_seat)
|
MetaWaylandTabletSeat *tablet_seat)
|
||||||
{
|
{
|
||||||
MetaBackend *backend = meta_get_backend ();
|
MetaBackend *backend = meta_get_backend ();
|
||||||
MetaWaylandTabletPad *pad;
|
MetaWaylandTabletPad *pad;
|
||||||
guint n_mode_groups, i;
|
guint n_elems, i;
|
||||||
|
|
||||||
pad = g_slice_new0 (MetaWaylandTabletPad);
|
pad = g_slice_new0 (MetaWaylandTabletPad);
|
||||||
wl_list_init (&pad->resource_list);
|
wl_list_init (&pad->resource_list);
|
||||||
@ -90,14 +158,36 @@ meta_wayland_tablet_pad_new (ClutterInputDevice *device,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
n_mode_groups = clutter_input_device_get_n_mode_groups (pad->device);
|
n_elems = clutter_input_device_get_n_mode_groups (pad->device);
|
||||||
|
|
||||||
for (i = 0; i < n_mode_groups; i++)
|
for (i = 0; i < n_elems; i++)
|
||||||
{
|
{
|
||||||
pad->groups = g_list_prepend (pad->groups,
|
pad->groups = g_list_prepend (pad->groups,
|
||||||
meta_wayland_tablet_pad_group_new (pad));
|
meta_wayland_tablet_pad_group_new (pad));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n_elems = clutter_input_device_get_n_rings (pad->device);
|
||||||
|
|
||||||
|
for (i = 0; i < n_elems; i++)
|
||||||
|
{
|
||||||
|
MetaWaylandTabletPadRing *ring;
|
||||||
|
|
||||||
|
ring = meta_wayland_tablet_pad_ring_new (pad);
|
||||||
|
pad->rings = g_list_prepend (pad->rings, ring);
|
||||||
|
}
|
||||||
|
|
||||||
|
n_elems = clutter_input_device_get_n_strips (pad->device);
|
||||||
|
|
||||||
|
for (i = 0; i < n_elems; i++)
|
||||||
|
{
|
||||||
|
MetaWaylandTabletPadStrip *strip;
|
||||||
|
|
||||||
|
strip = meta_wayland_tablet_pad_strip_new (pad);
|
||||||
|
pad->strips = g_list_prepend (pad->strips, strip);
|
||||||
|
}
|
||||||
|
|
||||||
|
group_rings_strips (pad);
|
||||||
|
|
||||||
return pad;
|
return pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +207,10 @@ meta_wayland_tablet_pad_free (MetaWaylandTabletPad *pad)
|
|||||||
|
|
||||||
g_list_free_full (pad->groups,
|
g_list_free_full (pad->groups,
|
||||||
(GDestroyNotify) meta_wayland_tablet_pad_group_free);
|
(GDestroyNotify) meta_wayland_tablet_pad_group_free);
|
||||||
|
g_list_free_full (pad->rings,
|
||||||
|
(GDestroyNotify) meta_wayland_tablet_pad_ring_free);
|
||||||
|
g_list_free_full (pad->strips,
|
||||||
|
(GDestroyNotify) meta_wayland_tablet_pad_strip_free);
|
||||||
|
|
||||||
g_hash_table_destroy (pad->feedback);
|
g_hash_table_destroy (pad->feedback);
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ struct _MetaWaylandTabletPad
|
|||||||
|
|
||||||
uint32_t n_buttons;
|
uint32_t n_buttons;
|
||||||
GList *groups;
|
GList *groups;
|
||||||
|
GList *rings;
|
||||||
|
GList *strips;
|
||||||
|
|
||||||
GHashTable *feedback;
|
GHashTable *feedback;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user