aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/libinput/tablet_pad.c3
-rw-r--r--backend/libinput/tablet_tool.c2
-rw-r--r--examples/support/shared.c10
-rw-r--r--examples/support/shared.h3
-rw-r--r--examples/tablet.c59
-rw-r--r--include/wlr/types/wlr_tablet_pad.h3
-rw-r--r--meson.build2
-rw-r--r--rootston/seat.c4
-rw-r--r--types/wlr_output_layout.c4
9 files changed, 67 insertions, 23 deletions
diff --git a/backend/libinput/tablet_pad.c b/backend/libinput/tablet_pad.c
index 70e4c677..f71e1efa 100644
--- a/backend/libinput/tablet_pad.c
+++ b/backend/libinput/tablet_pad.c
@@ -34,6 +34,7 @@ void handle_tablet_pad_button(struct libinput_event *event,
wlr_event.time_msec =
usec_to_msec(libinput_event_tablet_pad_get_time_usec(pevent));
wlr_event.button = libinput_event_tablet_pad_get_button_number(pevent);
+ wlr_event.mode = libinput_event_tablet_pad_get_mode(pevent);
switch (libinput_event_tablet_pad_get_button_state(pevent)) {
case LIBINPUT_BUTTON_STATE_PRESSED:
wlr_event.state = WLR_BUTTON_PRESSED;
@@ -60,6 +61,7 @@ void handle_tablet_pad_ring(struct libinput_event *event,
usec_to_msec(libinput_event_tablet_pad_get_time_usec(pevent));
wlr_event.ring = libinput_event_tablet_pad_get_ring_number(pevent);
wlr_event.position = libinput_event_tablet_pad_get_ring_position(pevent);
+ wlr_event.mode = libinput_event_tablet_pad_get_mode(pevent);
switch (libinput_event_tablet_pad_get_ring_source(pevent)) {
case LIBINPUT_TABLET_PAD_RING_SOURCE_UNKNOWN:
wlr_event.source = WLR_TABLET_PAD_RING_SOURCE_UNKNOWN;
@@ -86,6 +88,7 @@ void handle_tablet_pad_strip(struct libinput_event *event,
usec_to_msec(libinput_event_tablet_pad_get_time_usec(pevent));
wlr_event.strip = libinput_event_tablet_pad_get_strip_number(pevent);
wlr_event.position = libinput_event_tablet_pad_get_strip_position(pevent);
+ wlr_event.mode = libinput_event_tablet_pad_get_mode(pevent);
switch (libinput_event_tablet_pad_get_strip_source(pevent)) {
case LIBINPUT_TABLET_PAD_STRIP_SOURCE_UNKNOWN:
wlr_event.source = WLR_TABLET_PAD_STRIP_SOURCE_UNKNOWN;
diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c
index 4e60367f..27cf7c81 100644
--- a/backend/libinput/tablet_tool.c
+++ b/backend/libinput/tablet_tool.c
@@ -71,8 +71,6 @@ void handle_tablet_tool_axis(struct libinput_event *event,
wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_WHEEL;
wlr_event.wheel_delta = libinput_event_tablet_tool_get_wheel_delta(tevent);
}
- wlr_log(L_DEBUG, "Tablet tool axis event %d @ %f,%f",
- wlr_event.updated_axes, wlr_event.x_mm, wlr_event.y_mm);
wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.axis, &wlr_event);
}
diff --git a/examples/support/shared.c b/examples/support/shared.c
index c4f9288d..e6233206 100644
--- a/examples/support/shared.c
+++ b/examples/support/shared.c
@@ -294,6 +294,14 @@ static void tablet_pad_button_notify(struct wl_listener *listener, void *data) {
}
}
+static void tablet_pad_ring_notify(struct wl_listener *listener, void *data) {
+ struct wlr_event_tablet_pad_ring *event = data;
+ struct tablet_pad_state *pstate = wl_container_of(listener, pstate, ring);
+ if (pstate->compositor->pad_ring_cb) {
+ pstate->compositor->pad_ring_cb(pstate, event->ring, event->position);
+ }
+}
+
static void tablet_pad_destroy_notify(struct wl_listener *listener, void *data) {
struct tablet_pad_state *pstate = wl_container_of(listener, pstate, destroy);
struct compositor_state *state = pstate->compositor;
@@ -315,6 +323,8 @@ static void tablet_pad_add(struct wlr_input_device *device,
wl_signal_add(&device->events.destroy, &pstate->destroy);
pstate->button.notify = tablet_pad_button_notify;
wl_signal_add(&device->tablet_pad->events.button, &pstate->button);
+ pstate->ring.notify = tablet_pad_ring_notify;
+ wl_signal_add(&device->tablet_pad->events.ring, &pstate->ring);
wl_list_insert(&state->tablet_pads, &pstate->link);
}
diff --git a/examples/support/shared.h b/examples/support/shared.h
index 8cdea301..d00e75b3 100644
--- a/examples/support/shared.h
+++ b/examples/support/shared.h
@@ -73,6 +73,7 @@ struct tablet_pad_state {
struct wlr_input_device *device;
struct wl_listener destroy;
struct wl_listener button;
+ struct wl_listener ring;
struct wl_list link;
void *data;
};
@@ -117,6 +118,8 @@ struct compositor_state {
uint32_t button, enum wlr_button_state state);
void (*pad_button_cb)(struct tablet_pad_state *s,
uint32_t button, enum wlr_button_state state);
+ void (*pad_ring_cb)(struct tablet_pad_state *s,
+ uint32_t ring, double position);
struct wl_display *display;
struct wl_event_loop *event_loop;
diff --git a/examples/tablet.c b/examples/tablet.c
index ca76ec5a..5bfa1271 100644
--- a/examples/tablet.c
+++ b/examples/tablet.c
@@ -14,6 +14,7 @@
#include <wlr/render.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
+#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_tablet_tool.h>
#include <wlr/types/wlr_tablet_pad.h>
@@ -28,7 +29,9 @@ struct sample_state {
double distance;
double pressure;
double x_mm, y_mm;
+ double x_tilt, y_tilt;
double width_mm, height_mm;
+ double ring;
struct wl_list link;
float tool_color[4];
float pad_color[4];
@@ -46,7 +49,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
wlr_renderer_begin(sample->renderer, wlr_output);
wlr_renderer_clear(sample->renderer, &(float[]){0.25f, 0.25f, 0.25f, 1});
- float matrix[16], view[16];
+ float matrix[16];
float distance = 0.8f * (1 - sample->distance);
float tool_color[4] = { distance, distance, distance, 1 };
for (size_t i = 0; sample->button && i < 4; ++i) {
@@ -58,22 +61,31 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
float pad_height = sample->height_mm * scale;
float left = width / 2.0f - pad_width / 2.0f;
float top = height / 2.0f - pad_height / 2.0f;
- wlr_matrix_translate(&matrix, left, top, 0);
- wlr_matrix_scale(&view, pad_width, pad_height, 1);
- wlr_matrix_mul(&matrix, &view, &view);
- wlr_matrix_mul(&wlr_output->transform_matrix, &view, &matrix);
+ struct wlr_box box = {
+ .x = left, .y = top,
+ .width = pad_width, .height = pad_height,
+ };
+ wlr_matrix_project_box(&matrix, &box, 0, 0,
+ &wlr_output->transform_matrix);
wlr_render_colored_quad(sample->renderer, &sample->pad_color, &matrix);
if (sample->proximity) {
- wlr_matrix_translate(&matrix,
- sample->x_mm * scale - 8 * (sample->pressure + 1) + left,
- sample->y_mm * scale - 8 * (sample->pressure + 1) + top, 0);
- wlr_matrix_scale(&view,
- 16 * (sample->pressure + 1),
- 16 * (sample->pressure + 1), 1);
- wlr_matrix_mul(&matrix, &view, &view);
- wlr_matrix_mul(&wlr_output->transform_matrix, &view, &matrix);
- wlr_render_colored_ellipse(sample->renderer, &tool_color, &matrix);
+ struct wlr_box box = {
+ .x = sample->x_mm * scale - 8 * (sample->pressure + 1) + left,
+ .y = sample->y_mm * scale - 8 * (sample->pressure + 1) + top,
+ .width = 16 * (sample->pressure + 1),
+ .height = 16 * (sample->pressure + 1),
+ };
+ wlr_matrix_project_box(&matrix, &box, 0, sample->ring,
+ &wlr_output->transform_matrix);
+ wlr_render_colored_quad(sample->renderer, &tool_color, &matrix);
+ box.x += sample->x_tilt;
+ box.y += sample->y_tilt;
+ box.width /= 2;
+ box.height /= 2;
+ wlr_matrix_project_box(&matrix, &box, 0, 0,
+ &wlr_output->transform_matrix);
+ wlr_render_colored_quad(sample->renderer, &tool_color, &matrix);
}
wlr_renderer_end(sample->renderer);
@@ -97,6 +109,12 @@ static void handle_tool_axis(struct tablet_tool_state *tstate,
if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_PRESSURE)) {
sample->pressure = event->pressure;
}
+ if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_X)) {
+ sample->x_tilt = event->tilt_x;
+ }
+ if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_Y)) {
+ sample->y_tilt = event->tilt_y;
+ }
}
static void handle_tool_proximity(struct tablet_tool_state *tstate,
@@ -125,7 +143,7 @@ static void handle_tool_button(struct tablet_tool_state *tstate,
static void handle_pad_button(struct tablet_pad_state *pstate,
uint32_t button, enum wlr_button_state state) {
struct sample_state *sample = pstate->compositor->data;
- float default_color[4] = { 0.75, 0.75, 0.75, 1.0 };
+ float default_color[4] = { 0.5, 0.5, 0.5, 1.0 };
if (state == WLR_BUTTON_RELEASED) {
memcpy(sample->pad_color, default_color, sizeof(default_color));
} else {
@@ -139,11 +157,19 @@ static void handle_pad_button(struct tablet_pad_state *pstate,
}
}
+static void handle_pad_ring(struct tablet_pad_state *pstate,
+ uint32_t ring, double position) {
+ struct sample_state *sample = pstate->compositor->data;
+ if (position != -1) {
+ sample->ring = -(position * (M_PI / 180.0));
+ }
+}
+
int main(int argc, char *argv[]) {
wlr_log_init(L_DEBUG, NULL);
struct sample_state state = {
.tool_color = { 1, 1, 1, 1 },
- .pad_color = { 0.75, 0.75, 0.75, 1.0 }
+ .pad_color = { 0.5, 0.5, 0.5, 1.0 }
};
struct compositor_state compositor = { 0,
.data = &state,
@@ -152,6 +178,7 @@ int main(int argc, char *argv[]) {
.tool_proximity_cb = handle_tool_proximity,
.tool_button_cb = handle_tool_button,
.pad_button_cb = handle_pad_button,
+ .pad_ring_cb = handle_pad_ring,
};
compositor_init(&compositor);
diff --git a/include/wlr/types/wlr_tablet_pad.h b/include/wlr/types/wlr_tablet_pad.h
index e70db516..73082c56 100644
--- a/include/wlr/types/wlr_tablet_pad.h
+++ b/include/wlr/types/wlr_tablet_pad.h
@@ -29,6 +29,7 @@ struct wlr_event_tablet_pad_button {
uint32_t time_msec;
uint32_t button;
enum wlr_button_state state;
+ unsigned int mode;
};
enum wlr_tablet_pad_ring_source {
@@ -41,6 +42,7 @@ struct wlr_event_tablet_pad_ring {
enum wlr_tablet_pad_ring_source source;
uint32_t ring;
double position;
+ unsigned int mode;
};
enum wlr_tablet_pad_strip_source {
@@ -53,6 +55,7 @@ struct wlr_event_tablet_pad_strip {
enum wlr_tablet_pad_strip_source source;
uint32_t strip;
double position;
+ unsigned int mode;
};
#endif
diff --git a/meson.build b/meson.build
index 553d2b88..c7ca038c 100644
--- a/meson.build
+++ b/meson.build
@@ -196,7 +196,7 @@ git = find_program('git', required: false)
if git.found()
all_files = run_command(
git,
- ['--git-dir=@0@/.git'.format(meson.source_root()),
+ ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
'ls-files',
':/*.[ch]'])
all_files = files(all_files.stdout().split())
diff --git a/rootston/seat.c b/rootston/seat.c
index 9acbb737..8ac41f6c 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -514,13 +514,13 @@ static void seat_add_tablet_pad(struct roots_seat *seat,
static void handle_tablet_tool_destroy(struct wl_listener *listener,
void *data) {
- struct roots_pointer *tablet_tool =
+ struct roots_tablet_tool *tablet_tool =
wl_container_of(listener, tablet_tool, device_destroy);
struct roots_seat *seat = tablet_tool->seat;
- wl_list_remove(&tablet_tool->link);
wlr_cursor_detach_input_device(seat->cursor->cursor, tablet_tool->device);
wl_list_remove(&tablet_tool->device_destroy.link);
+ wl_list_remove(&tablet_tool->link);
free(tablet_tool);
seat_update_capabilities(seat);
diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c
index c305f04d..2462bdd2 100644
--- a/types/wlr_output_layout.c
+++ b/types/wlr_output_layout.c
@@ -48,6 +48,7 @@ struct wlr_output_layout *wlr_output_layout_create() {
static void wlr_output_layout_output_destroy(
struct wlr_output_layout_output *l_output) {
wlr_signal_emit_safe(&l_output->events.destroy, l_output);
+ wlr_output_destroy_global(l_output->output);
wl_list_remove(&l_output->state->mode.link);
wl_list_remove(&l_output->state->scale.link);
wl_list_remove(&l_output->state->transform.link);
@@ -64,7 +65,7 @@ void wlr_output_layout_destroy(struct wlr_output_layout *layout) {
wlr_signal_emit_safe(&layout->events.destroy, layout);
- struct wlr_output_layout_output *l_output, *temp = NULL;
+ struct wlr_output_layout_output *l_output, *temp;
wl_list_for_each_safe(l_output, temp, &layout->outputs, link) {
wlr_output_layout_output_destroy(l_output);
}
@@ -291,7 +292,6 @@ void wlr_output_layout_remove(struct wlr_output_layout *layout,
wlr_output_layout_output_destroy(l_output);
wlr_output_layout_reconfigure(layout);
}
- wlr_output_destroy_global(output);
}
void wlr_output_layout_output_coords(struct wlr_output_layout *layout,