mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
Allow leasing desktop displays
Apps such as Gamescope eventually want to offer a DRM lease option to use planes and handle all of getting to the screen themselves. This implements logic to allow leasing of desktop displays
This commit is contained in:
parent
050af96d57
commit
505b1edb98
3 changed files with 37 additions and 17 deletions
|
|
@ -251,6 +251,8 @@ struct output {
|
||||||
|
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
struct wl_listener frame;
|
struct wl_listener frame;
|
||||||
|
|
||||||
|
bool leased;
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef LAB_NR_LAYERS
|
#undef LAB_NR_LAYERS
|
||||||
|
|
|
||||||
31
src/output.c
31
src/output.c
|
|
@ -59,16 +59,22 @@ new_output_notify(struct wl_listener *listener, void *data)
|
||||||
struct wlr_output *wlr_output = data;
|
struct wlr_output *wlr_output = data;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is a non-desktop output, offer it for leasing.
|
* We offer any display as available for lease, some apps like
|
||||||
* We may want to do more logic here in future, if we choose
|
* gamescope, want to take ownership of a display when they can
|
||||||
* to offer non-desktop outputs.
|
* to use planes and present directly.
|
||||||
|
* This is also useful for debugging the DRM parts of
|
||||||
|
* another compositor.
|
||||||
|
*/
|
||||||
|
if (server->drm_lease_manager) {
|
||||||
|
wlr_drm_lease_v1_manager_offer_output(
|
||||||
|
server->drm_lease_manager, wlr_output);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't configure any non-desktop displays, such as VR headsets;
|
||||||
*/
|
*/
|
||||||
if (wlr_output->non_desktop) {
|
if (wlr_output->non_desktop) {
|
||||||
wlr_log(WLR_DEBUG, "Not configuring non-desktop output");
|
wlr_log(WLR_DEBUG, "Not configuring non-desktop output");
|
||||||
if (server->drm_lease_manager) {
|
|
||||||
wlr_drm_lease_v1_manager_offer_output(
|
|
||||||
server->drm_lease_manager, wlr_output);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -231,11 +237,12 @@ output_config_apply(struct server *server,
|
||||||
wl_list_for_each(head, &config->heads, link) {
|
wl_list_for_each(head, &config->heads, link) {
|
||||||
struct wlr_output *o = head->state.output;
|
struct wlr_output *o = head->state.output;
|
||||||
struct output *output = output_from_wlr_output(server, o);
|
struct output *output = output_from_wlr_output(server, o);
|
||||||
bool need_to_add = head->state.enabled && !o->enabled;
|
bool output_enabled = head->state.enabled && !output->leased;
|
||||||
bool need_to_remove = !head->state.enabled && o->enabled;
|
bool need_to_add = output_enabled && !o->enabled;
|
||||||
|
bool need_to_remove = !output_enabled && o->enabled;
|
||||||
|
|
||||||
wlr_output_enable(o, head->state.enabled);
|
wlr_output_enable(o, output_enabled);
|
||||||
if (head->state.enabled) {
|
if (output_enabled) {
|
||||||
/* Output specifc actions only */
|
/* Output specifc actions only */
|
||||||
if (head->state.mode) {
|
if (head->state.mode) {
|
||||||
wlr_output_set_mode(o, head->state.mode);
|
wlr_output_set_mode(o, head->state.mode);
|
||||||
|
|
@ -261,7 +268,7 @@ output_config_apply(struct server *server,
|
||||||
assert(output->scene_output);
|
assert(output->scene_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (head->state.enabled) {
|
if (output_enabled) {
|
||||||
wlr_output_layout_move(server->output_layout, o,
|
wlr_output_layout_move(server->output_layout, o,
|
||||||
head->state.x, head->state.y);
|
head->state.x, head->state.y);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
21
src/server.c
21
src/server.c
|
|
@ -151,16 +151,27 @@ handle_input_disinhibit(struct wl_listener *listener, void *data)
|
||||||
static void
|
static void
|
||||||
handle_drm_lease_request(struct wl_listener *listener, void *data)
|
handle_drm_lease_request(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
* We only offer non-desktop outputs, but in the future we might want to do
|
|
||||||
* more logic here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct wlr_drm_lease_request_v1 *req = data;
|
struct wlr_drm_lease_request_v1 *req = data;
|
||||||
struct wlr_drm_lease_v1 *lease = wlr_drm_lease_request_v1_grant(req);
|
struct wlr_drm_lease_v1 *lease = wlr_drm_lease_request_v1_grant(req);
|
||||||
if (!lease) {
|
if (!lease) {
|
||||||
wlr_log(WLR_ERROR, "Failed to grant lease request");
|
wlr_log(WLR_ERROR, "Failed to grant lease request");
|
||||||
wlr_drm_lease_request_v1_reject(req);
|
wlr_drm_lease_request_v1_reject(req);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(size_t i = 0; i < req->n_connectors; ++i) {
|
||||||
|
struct output *output = req->connectors[i]->output->data;
|
||||||
|
if (!output) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_output_enable(output->wlr_output, false);
|
||||||
|
wlr_output_commit(output->wlr_output);
|
||||||
|
|
||||||
|
wlr_output_layout_remove(output->server->output_layout, output->wlr_output);
|
||||||
|
output->scene_output = NULL;
|
||||||
|
|
||||||
|
output->leased = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue