tablet: add a helper function to get the current tool
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 25 Sep 2019 23:59:47 +0000 (09:59 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 31 Oct 2019 23:27:39 +0000 (23:27 +0000)
No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-tablet.c

index 0e9c8e4642a3398bb82f33044a214dc00da4c0b9..f2fbf847b0eb4b272ae7f503ae2eb42f4eb9a61d 100644 (file)
@@ -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 */