mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-03-21 23:50:45 +01:00
tablet: Include tool with all events
Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
8b1b988fd8
commit
bcbf9f95fd
5 changed files with 51 additions and 37 deletions
|
|
@ -94,10 +94,7 @@ tablet_update_tool(struct tablet_dispatch *tablet,
|
|||
assert(tool != LIBINPUT_TOOL_NONE);
|
||||
|
||||
if (enabled) {
|
||||
if (tool != tablet->current_tool_type) {
|
||||
tablet->current_tool_type = tool;
|
||||
tablet_set_status(tablet, TABLET_TOOL_UPDATED);
|
||||
}
|
||||
tablet->current_tool_type = tool;
|
||||
tablet_mark_all_axes_changed(tablet, device);
|
||||
tablet_set_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY);
|
||||
tablet_unset_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY);
|
||||
|
|
@ -126,7 +123,8 @@ normalize_tilt(const struct input_absinfo * absinfo) {
|
|||
static void
|
||||
tablet_check_notify_axes(struct tablet_dispatch *tablet,
|
||||
struct evdev_device *device,
|
||||
uint32_t time)
|
||||
uint32_t time,
|
||||
struct libinput_tool *tool)
|
||||
{
|
||||
struct libinput_device *base = &device->base;
|
||||
bool axis_update_needed = false;
|
||||
|
|
@ -169,6 +167,7 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet,
|
|||
!tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY))
|
||||
tablet_notify_axis(base,
|
||||
time,
|
||||
tool,
|
||||
tablet->changed_axes,
|
||||
tablet->axes);
|
||||
|
||||
|
|
@ -247,11 +246,9 @@ tablet_process_misc(struct tablet_dispatch *tablet,
|
|||
{
|
||||
switch (e->code) {
|
||||
case MSC_SERIAL:
|
||||
if (e->value != (int32_t)tablet->current_tool_serial &&
|
||||
e->value != -1) {
|
||||
if (e->value != -1)
|
||||
tablet->current_tool_serial = e->value;
|
||||
tablet_set_status(tablet, TABLET_TOOL_UPDATED);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
log_info(device->base.seat->libinput,
|
||||
|
|
@ -297,6 +294,7 @@ static void
|
|||
tablet_notify_button_mask(struct tablet_dispatch *tablet,
|
||||
struct evdev_device *device,
|
||||
uint32_t time,
|
||||
struct libinput_tool *tool,
|
||||
uint32_t buttons,
|
||||
uint32_t button_base,
|
||||
enum libinput_button_state state)
|
||||
|
|
@ -316,6 +314,7 @@ tablet_notify_button_mask(struct tablet_dispatch *tablet,
|
|||
|
||||
tablet_notify_button(base,
|
||||
time,
|
||||
tool,
|
||||
num_button + button_base - 1,
|
||||
state);
|
||||
}
|
||||
|
|
@ -325,6 +324,7 @@ static void
|
|||
tablet_notify_buttons(struct tablet_dispatch *tablet,
|
||||
struct evdev_device *device,
|
||||
uint32_t time,
|
||||
struct libinput_tool *tool,
|
||||
enum libinput_button_state state)
|
||||
{
|
||||
uint32_t stylus_buttons;
|
||||
|
|
@ -336,8 +336,13 @@ tablet_notify_buttons(struct tablet_dispatch *tablet,
|
|||
stylus_buttons =
|
||||
tablet_get_released_buttons(tablet, stylus_buttons);
|
||||
|
||||
tablet_notify_button_mask(tablet, device, time,
|
||||
stylus_buttons, BTN_TOUCH, state);
|
||||
tablet_notify_button_mask(tablet,
|
||||
device,
|
||||
time,
|
||||
tool,
|
||||
stylus_buttons,
|
||||
BTN_TOUCH,
|
||||
state);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -392,24 +397,30 @@ tablet_flush(struct tablet_dispatch *tablet,
|
|||
|
||||
if (tablet_has_status(tablet, TABLET_AXES_UPDATED)) {
|
||||
sanitize_tablet_axes(tablet);
|
||||
tablet_check_notify_axes(tablet, device, time);
|
||||
tablet_check_notify_axes(tablet, device, time, tool);
|
||||
tablet_unset_status(tablet, TABLET_AXES_UPDATED);
|
||||
}
|
||||
|
||||
if (tablet_has_status(tablet, TABLET_BUTTONS_RELEASED)) {
|
||||
tablet_notify_buttons(tablet, device, time,
|
||||
tablet_notify_buttons(tablet,
|
||||
device,
|
||||
time,
|
||||
tool,
|
||||
LIBINPUT_BUTTON_STATE_RELEASED);
|
||||
tablet_unset_status(tablet, TABLET_BUTTONS_RELEASED);
|
||||
}
|
||||
|
||||
if (tablet_has_status(tablet, TABLET_BUTTONS_PRESSED)) {
|
||||
tablet_notify_buttons(tablet, device, time,
|
||||
tablet_notify_buttons(tablet,
|
||||
device,
|
||||
time,
|
||||
tool,
|
||||
LIBINPUT_BUTTON_STATE_PRESSED);
|
||||
tablet_unset_status(tablet, TABLET_BUTTONS_PRESSED);
|
||||
}
|
||||
|
||||
if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY)) {
|
||||
tablet_notify_proximity_out(&device->base, time);
|
||||
tablet_notify_proximity_out(&device->base, time, tool);
|
||||
tablet_set_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY);
|
||||
tablet_unset_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,13 +30,12 @@
|
|||
enum tablet_status {
|
||||
TABLET_NONE = 0,
|
||||
TABLET_AXES_UPDATED = 1 << 0,
|
||||
TABLET_TOOL_UPDATED = 1 << 1,
|
||||
TABLET_BUTTONS_PRESSED = 1 << 2,
|
||||
TABLET_BUTTONS_RELEASED = 1 << 3,
|
||||
TABLET_STYLUS_IN_CONTACT = 1 << 4,
|
||||
TABLET_TOOL_LEAVING_PROXIMITY = 1 << 5,
|
||||
TABLET_TOOL_OUT_OF_PROXIMITY = 1 << 6,
|
||||
TABLET_TOOL_ENTERING_PROXIMITY = 1 << 7
|
||||
TABLET_BUTTONS_PRESSED = 1 << 1,
|
||||
TABLET_BUTTONS_RELEASED = 1 << 2,
|
||||
TABLET_STYLUS_IN_CONTACT = 1 << 3,
|
||||
TABLET_TOOL_LEAVING_PROXIMITY = 1 << 4,
|
||||
TABLET_TOOL_OUT_OF_PROXIMITY = 1 << 5,
|
||||
TABLET_TOOL_ENTERING_PROXIMITY = 1 << 6
|
||||
};
|
||||
|
||||
struct button_state {
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ touch_notify_touch_up(struct libinput_device *device,
|
|||
void
|
||||
tablet_notify_axis(struct libinput_device *device,
|
||||
uint32_t time,
|
||||
struct libinput_tool *tool,
|
||||
unsigned char *changed_axes,
|
||||
double *axes);
|
||||
|
||||
|
|
@ -224,11 +225,13 @@ tablet_notify_proximity_in(struct libinput_device *device,
|
|||
|
||||
void
|
||||
tablet_notify_proximity_out(struct libinput_device *device,
|
||||
uint32_t time);
|
||||
uint32_t time,
|
||||
struct libinput_tool *tool);
|
||||
|
||||
void
|
||||
tablet_notify_button(struct libinput_device *device,
|
||||
uint32_t time,
|
||||
struct libinput_tool *tool,
|
||||
int32_t button,
|
||||
enum libinput_button_state state);
|
||||
void
|
||||
|
|
|
|||
|
|
@ -1230,6 +1230,7 @@ touch_notify_frame(struct libinput_device *device,
|
|||
void
|
||||
tablet_notify_axis(struct libinput_device *device,
|
||||
uint32_t time,
|
||||
struct libinput_tool *tool,
|
||||
unsigned char *changed_axes,
|
||||
double *axes)
|
||||
{
|
||||
|
|
@ -1241,6 +1242,7 @@ tablet_notify_axis(struct libinput_device *device,
|
|||
|
||||
*axis_event = (struct libinput_event_tablet) {
|
||||
.time = time,
|
||||
.tool = tool,
|
||||
.axes = axes,
|
||||
};
|
||||
|
||||
|
|
@ -1276,7 +1278,8 @@ tablet_notify_proximity_in(struct libinput_device *device,
|
|||
|
||||
void
|
||||
tablet_notify_proximity_out(struct libinput_device *device,
|
||||
uint32_t time)
|
||||
uint32_t time,
|
||||
struct libinput_tool *tool)
|
||||
{
|
||||
struct libinput_event_tablet *proximity_out_update_event;
|
||||
|
||||
|
|
@ -1285,7 +1288,8 @@ tablet_notify_proximity_out(struct libinput_device *device,
|
|||
return;
|
||||
|
||||
*proximity_out_update_event = (struct libinput_event_tablet) {
|
||||
.time = time
|
||||
.time = time,
|
||||
.tool = tool,
|
||||
};
|
||||
|
||||
post_device_event(device,
|
||||
|
|
@ -1296,6 +1300,7 @@ tablet_notify_proximity_out(struct libinput_device *device,
|
|||
void
|
||||
tablet_notify_button(struct libinput_device *device,
|
||||
uint32_t time,
|
||||
struct libinput_tool *tool,
|
||||
int32_t button,
|
||||
enum libinput_button_state state)
|
||||
{
|
||||
|
|
@ -1312,6 +1317,7 @@ tablet_notify_button(struct libinput_device *device,
|
|||
|
||||
*button_event = (struct libinput_event_tablet) {
|
||||
.time = time,
|
||||
.tool = tool,
|
||||
.button = button,
|
||||
.state = state,
|
||||
.seat_button_count = seat_button_count,
|
||||
|
|
|
|||
|
|
@ -918,18 +918,13 @@ libinput_event_tablet_get_y_transformed(struct libinput_event_tablet *event,
|
|||
/**
|
||||
* @ingroup event_tablet
|
||||
*
|
||||
* Returns the tool that came into proximity for this event.
|
||||
* For tablet events that are not of type @ref
|
||||
* LIBINPUT_EVENT_TABLET_PROXIMITY_IN, this function returns NULL. 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.
|
||||
*
|
||||
* @note It is an application bug to call this function for events other than
|
||||
* @ref LIBINPUT_EVENT_TABLET_PROXIMITY_IN.
|
||||
* Returns the tool that was in use during this event.
|
||||
* By default, 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.
|
||||
*
|
||||
* @note On tablets where the serial number of tools is not reported, each tool
|
||||
* cannot be guaranteed to be unique.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue