From bc461b029202d14c3d37d07b6fcf2689502ed6e0 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 26 Sep 2019 09:59:47 +1000 Subject: [PATCH] tablet: add a helper function to get the current tool No functional changes. Signed-off-by: Peter Hutterer --- src/evdev-tablet.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index 0e9c8e46..f2fbf847 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -1808,6 +1808,18 @@ out: } +static struct libinput_tablet_tool * +tablet_get_current_tool(struct tablet_dispatch *tablet) +{ + if (tablet->current_tool.type == LIBINPUT_TOOL_NONE) + return NULL; + + return tablet_get_tool(tablet, + tablet->current_tool.type, + tablet->current_tool.id, + tablet->current_tool.serial); +} + static void tablet_flush(struct tablet_dispatch *tablet, struct evdev_device *device, @@ -1816,14 +1828,8 @@ tablet_flush(struct tablet_dispatch *tablet, struct libinput_tablet_tool *tool; tablet_update_tool_state(tablet, device, time); - if (tablet->current_tool.type == LIBINPUT_TOOL_NONE) - return; - - tool = tablet_get_tool(tablet, - tablet->current_tool.type, - tablet->current_tool.id, - tablet->current_tool.serial); + tool = tablet_get_current_tool(tablet); if (!tool) return; /* OOM */