Implement output auto-selection in rootston

This commit is contained in:
Drew DeVault 2018-04-22 19:15:49 +02:00
parent 177b548b15
commit edbf4a2f60
4 changed files with 26 additions and 7 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}