output: implement CAGE_MULTI_OUTPUT_MODE_LAST

In this mode, only the last connected output will be used. If that one
is unplugged, the previously last connected output will be enabled. This
for example allows one to switch between two outputs, e.g. on a handheld
device such as a mobile phone.
This commit is contained in:
Jente Hidskes 2020-05-31 16:04:01 +02:00
parent c09dec7cc7
commit 1f11ad113d
No known key found for this signature in database
GPG key ID: 04BE5A29F32D91EA
2 changed files with 19 additions and 6 deletions

View file

@ -404,15 +404,20 @@ output_destroy(struct cg_output *output)
wlr_output_layout_remove(server->output_layout, output->wlr_output);
struct cg_view *view;
wl_list_for_each (view, &output->server->views, link) {
view_position(view);
}
free(output);
if (wl_list_empty(&server->outputs)) {
wl_display_terminate(server->wl_display);
} else if (server->output_mode == CAGE_MULTI_OUTPUT_MODE_LAST) {
struct cg_output *prev = wl_container_of(server->outputs.next, prev, link);
if (prev) {
output_enable(prev);
struct cg_view *view;
wl_list_for_each (view, &server->views, link) {
view_position(view);
}
}
}
}
@ -465,6 +470,12 @@ handle_new_output(struct wl_listener *listener, void *data)
}
wlr_output_set_transform(wlr_output, output->server->output_transform);
if (server->output_mode == CAGE_MULTI_OUTPUT_MODE_LAST) {
struct cg_output *next = wl_container_of(output->link.next, next, link);
if (next) {
output_disable(next);
}
}
if (wlr_xcursor_manager_load(server->seat->xcursor_manager, wlr_output->scale)) {
wlr_log(WLR_ERROR, "Cannot load XCursor theme for output '%s' with scale %f", wlr_output->name,