From 177b548b156ce4b46ff331d7c10f1bf373bf9cf7 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 22 Apr 2018 18:57:45 +0200 Subject: Update layer shell with optional wl_output --- include/wlr/types/wlr_layer_shell.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/wlr/types/wlr_layer_shell.h b/include/wlr/types/wlr_layer_shell.h index 1312e568..79b3a4ea 100644 --- a/include/wlr/types/wlr_layer_shell.h +++ b/include/wlr/types/wlr_layer_shell.h @@ -27,6 +27,9 @@ struct wlr_layer_shell { struct wl_listener display_destroy; struct { + // struct wlr_layer_surface * + // Note: the output may be NULL. In this case, it is your + // responsibility to assign an output before returning. struct wl_signal new_surface; } events; -- cgit v1.2.3 From edbf4a2f60ad05fc46bbb0b83e212e8cc1df2876 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 22 Apr 2018 19:15:49 +0200 Subject: Implement output auto-selection in rootston --- include/rootston/input.h | 2 ++ rootston/desktop.c | 8 +------- rootston/layer_shell.c | 12 ++++++++++++ rootston/seat.c | 11 +++++++++++ 4 files changed, 26 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/rootston/input.h b/include/rootston/input.h index 4395a0f7..ef46fab2 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -30,4 +30,6 @@ bool input_view_has_focus(struct roots_input *input, struct roots_view *view); struct roots_seat *input_get_seat(struct roots_input *input, char *name); +struct roots_seat *input_last_active_seat(struct roots_input *input); + #endif diff --git a/rootston/desktop.c b/rootston/desktop.c index 6ddf56b8..0949b5db 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -326,13 +326,7 @@ bool view_center(struct roots_view *view) { struct roots_desktop *desktop = view->desktop; struct roots_input *input = desktop->server->input; - struct roots_seat *seat = NULL, *_seat; - wl_list_for_each(_seat, &input->seats, link) { - if (!seat || (seat->seat->last_event.tv_sec > _seat->seat->last_event.tv_sec && - seat->seat->last_event.tv_nsec > _seat->seat->last_event.tv_nsec)) { - seat = _seat; - } - } + struct roots_seat *seat = input_last_active_seat(input); if (!seat) { return false; } diff --git a/rootston/layer_shell.c b/rootston/layer_shell.c index 895b0385..b6f7ba4c 100644 --- a/rootston/layer_shell.c +++ b/rootston/layer_shell.c @@ -312,6 +312,18 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) { return; } + if (!layer_surface->output) { + struct roots_input *input = desktop->server->input; + struct roots_seat *seat = input_last_active_seat(input); + assert(seat); // Technically speaking we should handle this case + struct wlr_output *output = + wlr_output_layout_output_at(desktop->layout, + seat->cursor->cursor->x, + seat->cursor->cursor->y); + assert(output); // And this one + layer_surface->output = output; + } + roots_surface->surface_commit.notify = handle_surface_commit; wl_signal_add(&layer_surface->surface->events.commit, &roots_surface->surface_commit); diff --git a/rootston/seat.c b/rootston/seat.c index e12df7d6..44673c75 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -999,3 +999,14 @@ void roots_seat_end_compositor_grab(struct roots_seat *seat) { cursor->mode = ROOTS_CURSOR_PASSTHROUGH; } + +struct roots_seat *input_last_active_seat(struct roots_input *input) { + struct roots_seat *seat = NULL, *_seat; + wl_list_for_each(_seat, &input->seats, link) { + if (!seat || (seat->seat->last_event.tv_sec > _seat->seat->last_event.tv_sec && + seat->seat->last_event.tv_nsec > _seat->seat->last_event.tv_nsec)) { + seat = _seat; + } + } + return seat; +} -- cgit v1.2.3