|
|
|
@ -37,6 +37,8 @@ struct wlr_cursor_output_cursor {
|
|
|
|
|
struct wlr_cursor *cursor;
|
|
|
|
|
struct wlr_output_cursor *output_cursor;
|
|
|
|
|
struct wl_list link;
|
|
|
|
|
|
|
|
|
|
struct wl_listener layout_output_destroy;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct wlr_cursor_state {
|
|
|
|
@ -48,6 +50,7 @@ struct wlr_cursor_state {
|
|
|
|
|
struct wlr_output *mapped_output;
|
|
|
|
|
struct wlr_box *mapped_box;
|
|
|
|
|
|
|
|
|
|
struct wl_listener layout_add;
|
|
|
|
|
struct wl_listener layout_change;
|
|
|
|
|
struct wl_listener layout_destroy;
|
|
|
|
|
};
|
|
|
|
@ -70,6 +73,7 @@ struct wlr_cursor *wlr_cursor_create() {
|
|
|
|
|
cur->state->mapped_output = NULL;
|
|
|
|
|
|
|
|
|
|
wl_list_init(&cur->state->devices);
|
|
|
|
|
wl_list_init(&cur->state->output_cursors);
|
|
|
|
|
|
|
|
|
|
// pointer signals
|
|
|
|
|
wl_signal_init(&cur->events.motion);
|
|
|
|
@ -102,6 +106,7 @@ static void wlr_cursor_detach_output_layout(struct wlr_cursor *cur) {
|
|
|
|
|
|
|
|
|
|
wl_list_remove(&cur->state->layout_destroy.link);
|
|
|
|
|
wl_list_remove(&cur->state->layout_change.link);
|
|
|
|
|
wl_list_remove(&cur->state->layout_add.link);
|
|
|
|
|
|
|
|
|
|
cur->state->layout = NULL;
|
|
|
|
|
}
|
|
|
|
@ -263,12 +268,20 @@ void wlr_cursor_move(struct wlr_cursor *cur, struct wlr_input_device *dev,
|
|
|
|
|
void wlr_cursor_set_image(struct wlr_cursor *cur, const uint8_t *pixels,
|
|
|
|
|
int32_t stride, uint32_t width, uint32_t height, int32_t hotspot_x,
|
|
|
|
|
int32_t hotspot_y) {
|
|
|
|
|
// TODO
|
|
|
|
|
struct wlr_cursor_output_cursor *output_cursor;
|
|
|
|
|
wl_list_for_each(output_cursor, &cur->state->output_cursors, link) {
|
|
|
|
|
wlr_output_cursor_set_image(output_cursor->output_cursor, pixels,
|
|
|
|
|
stride, width, height, hotspot_x, hotspot_y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wlr_cursor_set_surface(struct wlr_cursor *cur, struct wlr_surface *surface,
|
|
|
|
|
int32_t hotspot_x, int32_t hotspot_y) {
|
|
|
|
|
// TODO
|
|
|
|
|
struct wlr_cursor_output_cursor *output_cursor;
|
|
|
|
|
wl_list_for_each(output_cursor, &cur->state->output_cursors, link) {
|
|
|
|
|
wlr_output_cursor_set_surface(output_cursor->output_cursor, surface,
|
|
|
|
|
hotspot_x, hotspot_y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void handle_pointer_motion(struct wl_listener *listener, void *data) {
|
|
|
|
@ -489,10 +502,50 @@ static void handle_layout_destroy(struct wl_listener *listener, void *data) {
|
|
|
|
|
wlr_cursor_detach_output_layout(state->cursor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void handle_layout_output_destroy(struct wl_listener *listener,
|
|
|
|
|
void *data) {
|
|
|
|
|
struct wlr_cursor_output_cursor *output_cursor =
|
|
|
|
|
wl_container_of(listener, output_cursor, layout_output_destroy);
|
|
|
|
|
//struct wlr_output_layout_output *l_output = data;
|
|
|
|
|
|
|
|
|
|
wl_list_remove(&output_cursor->link);
|
|
|
|
|
wlr_output_cursor_destroy(output_cursor->output_cursor);
|
|
|
|
|
wl_list_remove(&output_cursor->layout_output_destroy.link);
|
|
|
|
|
free(output_cursor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void handle_layout_add(struct wl_listener *listener, void *data) {
|
|
|
|
|
struct wlr_cursor_state *state =
|
|
|
|
|
wl_container_of(listener, state, layout_add);
|
|
|
|
|
struct wlr_output_layout_output *l_output = data;
|
|
|
|
|
|
|
|
|
|
struct wlr_cursor_output_cursor *output_cursor =
|
|
|
|
|
calloc(1, sizeof(struct wlr_cursor_output_cursor));
|
|
|
|
|
if (output_cursor == NULL) {
|
|
|
|
|
wlr_log(L_ERROR, "Failed to allocate wlr_cursor_output_cursor");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
output_cursor->cursor = state->cursor;
|
|
|
|
|
|
|
|
|
|
output_cursor->output_cursor = wlr_output_cursor_create(l_output->output);
|
|
|
|
|
if (output_cursor->output_cursor == NULL) {
|
|
|
|
|
wlr_log(L_ERROR, "Failed to create wlr_output_cursor");
|
|
|
|
|
free(output_cursor);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
output_cursor->layout_output_destroy.notify = handle_layout_output_destroy;
|
|
|
|
|
wl_signal_add(&l_output->events.destroy,
|
|
|
|
|
&output_cursor->layout_output_destroy);
|
|
|
|
|
|
|
|
|
|
wl_list_insert(&state->cursor->state->output_cursors, &output_cursor->link);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void handle_layout_change(struct wl_listener *listener, void *data) {
|
|
|
|
|
struct wlr_cursor_state *state =
|
|
|
|
|
wl_container_of(listener, state, layout_change);
|
|
|
|
|
struct wlr_output_layout *layout = data;
|
|
|
|
|
|
|
|
|
|
if (!wlr_output_layout_contains_point(layout, NULL, state->cursor->x,
|
|
|
|
|
state->cursor->y)) {
|
|
|
|
|
// the output we were on has gone away so go to the closest boundary
|
|
|
|
@ -513,9 +566,10 @@ void wlr_cursor_attach_output_layout(struct wlr_cursor *cur,
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wl_signal_add(&l->events.add, &cur->state->layout_add);
|
|
|
|
|
cur->state->layout_add.notify = handle_layout_add;
|
|
|
|
|
wl_signal_add(&l->events.change, &cur->state->layout_change);
|
|
|
|
|
cur->state->layout_change.notify = handle_layout_change;
|
|
|
|
|
|
|
|
|
|
wl_signal_add(&l->events.destroy, &cur->state->layout_destroy);
|
|
|
|
|
cur->state->layout_destroy.notify = handle_layout_destroy;
|
|
|
|
|
|
|
|
|
|