Implement tablet_tool support in pointer example
This commit is contained in:
parent
4fbe322fa6
commit
30611894f2
|
@ -51,6 +51,11 @@ struct sample_state {
|
|||
struct wl_listener touch_down;
|
||||
struct wl_listener touch_cancel;
|
||||
list_t *touch_points;
|
||||
|
||||
struct wl_listener tablet_tool_axis;
|
||||
struct wl_listener tablet_tool_proxmity;
|
||||
struct wl_listener tablet_tool_tip;
|
||||
struct wl_listener tablet_tool_button;
|
||||
};
|
||||
|
||||
struct touch_point {
|
||||
|
@ -306,6 +311,17 @@ static void handle_touch_cancel(struct wl_listener *listener, void *data) {
|
|||
wlr_log(L_DEBUG, "TODO: touch cancel");
|
||||
}
|
||||
|
||||
static void handle_tablet_tool_axis(struct wl_listener *listener, void *data) {
|
||||
struct sample_state *sample = wl_container_of(listener, sample, tablet_tool_axis);
|
||||
struct wlr_event_tablet_tool_axis *event = data;
|
||||
if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)
|
||||
&& (event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
|
||||
wlr_cursor_warp_absolute(sample->cursor, event->device,
|
||||
event->x_mm / event->width_mm,
|
||||
event->y_mm / event->height_mm);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
struct sample_state state = {
|
||||
.default_color = { 0.25f, 0.25f, 0.25f, 1 },
|
||||
|
@ -344,6 +360,10 @@ int main(int argc, char *argv[]) {
|
|||
wl_signal_add(&state.cursor->events.touch_cancel, &state.touch_cancel);
|
||||
state.touch_cancel.notify = handle_touch_cancel;
|
||||
|
||||
// tool events
|
||||
wl_signal_add(&state.cursor->events.tablet_tool_axis, &state.tablet_tool_axis);
|
||||
state.tablet_tool_axis.notify = handle_tablet_tool_axis;
|
||||
|
||||
struct compositor_state compositor = { 0 };
|
||||
compositor.data = &state;
|
||||
compositor.output_add_cb = handle_output_add;
|
||||
|
|
|
@ -55,7 +55,7 @@ struct wlr_event_tablet_tool_proximity {
|
|||
struct wlr_input_device *device;
|
||||
uint32_t time_sec;
|
||||
uint64_t time_usec;
|
||||
double x, y;
|
||||
double x_mm, y_mm;
|
||||
double width_mm, height_mm;
|
||||
enum wlr_tablet_tool_proximity_state state;
|
||||
};
|
||||
|
@ -69,7 +69,7 @@ struct wlr_event_tablet_tool_tip {
|
|||
struct wlr_input_device *device;
|
||||
uint32_t time_sec;
|
||||
uint64_t time_usec;
|
||||
double x, y;
|
||||
double x_mm, y_mm;
|
||||
double width_mm, height_mm;
|
||||
enum wlr_tablet_tool_tip_state state;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue