Skip to content

Commit

Permalink
output: destroy output after ensuring it is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Nefsen402 committed Feb 22, 2022
1 parent 9e312d7 commit de21489
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
3 changes: 2 additions & 1 deletion sway/desktop/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,12 @@ static void update_output_manager_config(struct sway_server *server) {
static void handle_destroy(struct wl_listener *listener, void *data) {
struct sway_output *output = wl_container_of(listener, output, destroy);
struct sway_server *server = output->server;
output_begin_destroy(output);

if (output->enabled) {
output_disable(output);
}

output_begin_destroy(output);

wl_list_remove(&output->link);

Expand Down
28 changes: 19 additions & 9 deletions sway/desktop/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,18 @@ static void layout_title_bar(struct sway_container *con,
}
}

static void disable_container(struct sway_container *con) {
if (con->view) {
wlr_scene_node_reparent(con->view->scene_node, con->content.node);
}else for (int i = 0; i < con->current.children->length; i++) {
struct sway_container *child = con->current.children->items[i];

wlr_scene_node_reparent(child->scene_node, con->content.node);

disable_container(child);
}
}

static void arrange_container(struct sway_container *con,
int width, int height, bool title_bar) {
// this container might have previously been in the scratchpad,
Expand Down Expand Up @@ -311,6 +323,8 @@ static void arrange_container(struct sway_container *con,

if (activated) {
arrange_container(child, width, height - title_bar_height, false);
} else {
disable_container(child);
}
}
} else if (con->current.layout == L_STACKED) {
Expand All @@ -329,6 +343,8 @@ static void arrange_container(struct sway_container *con,

if (activated) {
arrange_container(child, width, height - content_y, false);
} else {
disable_container(child);
}

y += title_bar_height;
Expand Down Expand Up @@ -489,21 +505,15 @@ static void arrange_workspace(struct sway_workspace *ws, int width, int height)
}
}

static void workspace_disable(struct sway_workspace *ws) {
static void disable_workspace(struct sway_workspace *ws) {
// if any containers were just moved to a disabled workspace it will
// have the parent of the old workspace. Move the workspace so that it won't
// be shown.
for (int i = 0; i < ws->current.tiling->length; i++) {
struct sway_container *child = ws->current.tiling->items[i];

wlr_scene_node_reparent(child->scene_node, ws->layers.tiling);
}

// if this fullscreen node was coming from an enabled output, the view
// parent would be of the old workspace.
if (ws->fullscreen) {
wlr_scene_node_reparent(ws->fullscreen->view->scene_node,
ws->fullscreen->content.node);
disable_container(child);
}

for (int i = 0; i < ws->current.floating->length; i++) {
Expand Down Expand Up @@ -534,7 +544,7 @@ static void arrange_output(struct sway_output *output, int width, int height) {
width - gaps->left - gaps->right,
height - gaps->top - gaps->bottom);
}else{
workspace_disable(child);
disable_workspace(child);
}
}
}
Expand Down

0 comments on commit de21489

Please sign in to comment.