mirror of
https://github.com/cage-kiosk/cage.git
synced 2026-03-14 05:34:52 -04:00
output: fix crash when re-enabling DRM output
The output is disabled then re-enabled using the wlr-output-management protocol with tool such as wlr-randr. $ wlr-randr --output HDMI-A-1 --off $ wlr-randr --output HDMI-A-1 --on When re-enabled the new output configuration is committed before the output to be added to the global output layout. However, handle_output_commit() expects the output to be already part of this global layout and assert failed. Now, do not treat this in handle_output_commit() and simply ensure the resulting scene output is not NULL in handle_output_frame().
This commit is contained in:
parent
a769943447
commit
4dc3cf80b2
1 changed files with 31 additions and 20 deletions
51
output.c
51
output.c
|
|
@ -68,6 +68,29 @@ update_output_manager_config(struct cg_server *server)
|
||||||
wlr_output_manager_v1_set_configuration(server->output_manager_v1, config);
|
wlr_output_manager_v1_set_configuration(server->output_manager_v1, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
output_layout_add_auto(struct cg_output *output)
|
||||||
|
{
|
||||||
|
wlr_output_layout_add_auto(output->server->output_layout, output->wlr_output);
|
||||||
|
output->scene_output = wlr_scene_get_scene_output(output->server->scene, output->wlr_output);
|
||||||
|
assert(output->scene_output != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
output_layout_add(struct cg_output *output, int32_t x, int32_t y)
|
||||||
|
{
|
||||||
|
wlr_output_layout_add(output->server->output_layout, output->wlr_output, x, y);
|
||||||
|
output->scene_output = wlr_scene_get_scene_output(output->server->scene, output->wlr_output);
|
||||||
|
assert(output->scene_output != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
output_layout_remove(struct cg_output *output)
|
||||||
|
{
|
||||||
|
wlr_output_layout_remove(output->server->output_layout, output->wlr_output);
|
||||||
|
output->scene_output = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
output_enable(struct cg_output *output)
|
output_enable(struct cg_output *output)
|
||||||
{
|
{
|
||||||
|
|
@ -78,12 +101,11 @@ output_enable(struct cg_output *output)
|
||||||
* duplicate the enabled property in cg_output. */
|
* duplicate the enabled property in cg_output. */
|
||||||
wlr_log(WLR_DEBUG, "Enabling output %s", wlr_output->name);
|
wlr_log(WLR_DEBUG, "Enabling output %s", wlr_output->name);
|
||||||
|
|
||||||
wlr_output_layout_add_auto(output->server->output_layout, wlr_output);
|
|
||||||
wlr_output_enable(wlr_output, true);
|
wlr_output_enable(wlr_output, true);
|
||||||
wlr_output_commit(wlr_output);
|
|
||||||
|
|
||||||
output->scene_output = wlr_scene_get_scene_output(output->server->scene, wlr_output);
|
if (wlr_output_commit(wlr_output)) {
|
||||||
assert(output->scene_output != NULL);
|
output_layout_add_auto(output);
|
||||||
|
}
|
||||||
|
|
||||||
update_output_manager_config(output->server);
|
update_output_manager_config(output->server);
|
||||||
}
|
}
|
||||||
|
|
@ -98,12 +120,10 @@ output_disable(struct cg_output *output)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
output->scene_output = NULL;
|
|
||||||
|
|
||||||
wlr_log(WLR_DEBUG, "Disabling output %s", wlr_output->name);
|
wlr_log(WLR_DEBUG, "Disabling output %s", wlr_output->name);
|
||||||
wlr_output_enable(wlr_output, false);
|
wlr_output_enable(wlr_output, false);
|
||||||
wlr_output_layout_remove(output->server->output_layout, wlr_output);
|
|
||||||
wlr_output_commit(wlr_output);
|
wlr_output_commit(wlr_output);
|
||||||
|
output_layout_remove(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
@ -136,9 +156,9 @@ output_apply_config(struct cg_output *output, struct wlr_output_configuration_he
|
||||||
}
|
}
|
||||||
|
|
||||||
if (head->state.enabled) {
|
if (head->state.enabled) {
|
||||||
wlr_output_layout_add(output->server->output_layout, head->state.output, head->state.x, head->state.y);
|
output_layout_add(output, head->state.x, head->state.y);
|
||||||
} else {
|
} else {
|
||||||
wlr_output_layout_remove(output->server->output_layout, output->wlr_output);
|
output_layout_remove(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -149,7 +169,7 @@ handle_output_frame(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct cg_output *output = wl_container_of(listener, output, frame);
|
struct cg_output *output = wl_container_of(listener, output, frame);
|
||||||
|
|
||||||
if (!output->wlr_output->enabled) {
|
if (!output->wlr_output->enabled || !output->scene_output) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,15 +190,6 @@ handle_output_commit(struct wl_listener *listener, void *data)
|
||||||
* - output layout change will also be called if needed to position the views
|
* - output layout change will also be called if needed to position the views
|
||||||
* - always update output manager configuration even if the output is now disabled */
|
* - always update output manager configuration even if the output is now disabled */
|
||||||
|
|
||||||
if (event->committed & WLR_OUTPUT_STATE_ENABLED) {
|
|
||||||
if (output->wlr_output->enabled) {
|
|
||||||
output->scene_output = wlr_scene_get_scene_output(output->server->scene, output->wlr_output);
|
|
||||||
assert(output->scene_output != NULL);
|
|
||||||
} else {
|
|
||||||
output->scene_output = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event->committed & OUTPUT_CONFIG_UPDATED) {
|
if (event->committed & OUTPUT_CONFIG_UPDATED) {
|
||||||
update_output_manager_config(output->server);
|
update_output_manager_config(output->server);
|
||||||
}
|
}
|
||||||
|
|
@ -234,7 +245,7 @@ output_destroy(struct cg_output *output)
|
||||||
wl_list_remove(&output->frame.link);
|
wl_list_remove(&output->frame.link);
|
||||||
wl_list_remove(&output->link);
|
wl_list_remove(&output->link);
|
||||||
|
|
||||||
wlr_output_layout_remove(server->output_layout, output->wlr_output);
|
output_layout_remove(output);
|
||||||
|
|
||||||
free(output);
|
free(output);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue