[PATCH libinput 4/5] tablet: remove libinput_tool_(un)ref()

Peter Hutterer peter.hutterer at who-t.net
Thu Jun 26 00:46:50 PDT 2014


On Thu, Jun 26, 2014 at 02:31:21AM -0400, Stephen Chandler Paul wrote:
> Signed-off-by: Stephen Chandler Paul <thatslyude at gmail.com>

sorry, this must've been a misunderstanding on IRC: I didn't mean remove
those -  I was referring to we don't need the ref/unref when adding the tool
to the other tablet events.

what we should do to tool ref/unref though is bring it in line with the
changes from master to return the object or NULL.

Cheers,
   Peter

> ---
>  src/evdev-tablet.c     |  1 -
>  src/libinput-private.h |  1 -
>  src/libinput.c         | 19 +------------------
>  src/libinput.h         | 30 +++---------------------------
>  4 files changed, 4 insertions(+), 47 deletions(-)
> 
> diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
> index 710e391..c754060 100644
> --- a/src/evdev-tablet.c
> +++ b/src/evdev-tablet.c
> @@ -281,7 +281,6 @@ tablet_get_tool(struct libinput *li,
>  		*tool = (struct libinput_tool) {
>  			.type = type,
>  			.serial = serial,
> -			.refcount = 1,
>  		};
>  
>  		list_insert(&li->tool_list, &tool->link);
> diff --git a/src/libinput-private.h b/src/libinput-private.h
> index a396d78..d429ad3 100644
> --- a/src/libinput-private.h
> +++ b/src/libinput-private.h
> @@ -95,7 +95,6 @@ struct libinput_tool {
>  	struct list link;
>  	uint32_t serial;
>  	enum libinput_tool_type type;
> -	int refcount;
>  };
>  
>  typedef void (*libinput_source_dispatch_t)(void *data);
> diff --git a/src/libinput.c b/src/libinput.c
> index a00f6b5..d7adfac 100644
> --- a/src/libinput.c
> +++ b/src/libinput.c
> @@ -583,23 +583,6 @@ libinput_tool_get_serial(struct libinput_tool *tool)
>  	return tool->serial;
>  }
>  
> -LIBINPUT_EXPORT void
> -libinput_tool_ref(struct libinput_tool *tool)
> -{
> -	tool->refcount++;
> -}
> -
> -LIBINPUT_EXPORT void
> -libinput_tool_unref(struct libinput_tool *tool)
> -{
> -	assert(tool->refcount > 0);
> -
> -	if (--tool->refcount == 0) {
> -		list_remove(&tool->link);
> -		free(tool);
> -	}
> -}
> -
>  struct libinput_source *
>  libinput_add_fd(struct libinput *libinput,
>  		int fd,
> @@ -733,7 +716,7 @@ libinput_unref(struct libinput *libinput)
>  	}
>  
>  	list_for_each_safe(tool, next_tool, &libinput->tool_list, link) {
> -		libinput_tool_unref(tool);
> +		free(tool);
>  	}
>  
>  	libinput_timer_subsys_destroy(libinput);
> diff --git a/src/libinput.h b/src/libinput.h
> index c6a361c..f454af1 100644
> --- a/src/libinput.h
> +++ b/src/libinput.h
> @@ -919,12 +919,9 @@ libinput_event_tablet_get_y_transformed(struct libinput_event_tablet *event,
>   * @ingroup event_tablet
>   *
>   * Returns the tool that was in use during this event.
> - * By default, the lifetime of each tool will stay valid for as long as it is
> - * being used, and is destroyed when another tool comes into proximity. However,
> - * the lifetime of the tool may be extended by using libinput_tool_ref() to
> - * increment the reference count of the tool. This guarantees that whenever the
> - * tool comes back into proximity of the tablet, that the same structure will be
> - * used to represent the tool.
> + * Each tool object stays valid for the lifetime of each libinput context. This
> + * means that for a single physical tool, the same object will be returned with
> + * any events where it's in use even if after leaving proximity.
>   *
>   * @note On tablets where the serial number of tools is not reported, each tool
>   * cannot be guaranteed to be unique.
> @@ -1003,27 +1000,6 @@ libinput_tool_get_type(struct libinput_tool *tool);
>  /**
>   * @ingroup event_tablet
>   *
> - * Increment the ref count of tool by one
> - *
> - * @param tool The tool to increment the ref count of
> - */
> -void
> -libinput_tool_ref(struct libinput_tool *tool);
> -
> -/**
> - * @ingroup event_tablet
> - *
> - * Decrement the ref count of tool by one. When the ref count of tool reaches 0,
> - * the memory allocated for tool will be freed.
> - *
> - * @param tool The tool to decrement the ref count of
> - */
> -void
> -libinput_tool_unref(struct libinput_tool *tool);
> -
> -/**
> - * @ingroup event_tablet
> - *
>   * Return the serial number of a tool
>   *
>   * @note Not all tablets report a serial number along with the type of tool
> -- 
> 1.8.5.5
> 


More information about the wayland-devel mailing list