Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix output manager segfault #4673

Merged
merged 2 commits into from
Oct 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/sway/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ struct sway_output {
int lx, ly; // layout coords
int width, height; // transformed buffer size
enum wl_output_subpixel detected_subpixel;
// last applied mode when the output is DPMS'ed
struct wlr_output_mode *current_mode;

bool enabled, configured;
list_t *workspaces;
Expand Down Expand Up @@ -90,7 +92,7 @@ struct sway_output *all_output_by_name_or_id(const char *name_or_id);

void output_sort_workspaces(struct sway_output *output);

void output_enable(struct sway_output *output, struct output_config *oc);
bool output_enable(struct sway_output *output, struct output_config *oc);

void output_disable(struct sway_output *output);

Expand Down
4 changes: 2 additions & 2 deletions sway/config/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
if (!oc || oc->dpms_state != DPMS_OFF) {
wlr_output_enable(wlr_output, true);
}
output_enable(output, oc);
return true;
return output_enable(output, oc);
}

if (oc && oc->dpms_state == DPMS_ON) {
Expand Down Expand Up @@ -279,6 +278,7 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
sway_log(SWAY_ERROR, "Failed to modeset output %s", wlr_output->name);
return false;
}
output->current_mode = wlr_output->current_mode;

if (oc && oc->scale > 0) {
sway_log(SWAY_DEBUG, "Set %s scale to %f", oc->name, oc->scale);
Expand Down
1 change: 1 addition & 0 deletions sway/desktop/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ static void update_output_manager_config(struct sway_server *server) {
root->output_layout, output->wlr_output);
// We mark the output enabled even if it is switched off by DPMS
config_head->state.enabled = output->enabled;
config_head->state.mode = output->current_mode;
if (output_box) {
config_head->state.x = output_box->x;
config_head->state.y = output_box->y;
Expand Down
11 changes: 7 additions & 4 deletions sway/tree/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void restore_workspaces(struct sway_output *output) {
struct sway_workspace *ws = root->noop_output->workspaces->items[0];
workspace_detach(ws);
output_add_workspace(output, ws);

// If the floater was made floating while on the NOOP output, its width
// and height will be zero and it should be reinitialized as a floating
// container to get the appropriate size and location. Additionally, if
Expand Down Expand Up @@ -104,9 +104,9 @@ struct sway_output *output_create(struct wlr_output *wlr_output) {
return output;
}

void output_enable(struct sway_output *output, struct output_config *oc) {
bool output_enable(struct sway_output *output, struct output_config *oc) {
if (!sway_assert(!output->enabled, "output is already enabled")) {
return;
return false;
}
struct wlr_output *wlr_output = output->wlr_output;
size_t len = sizeof(output->layers) / sizeof(output->layers[0]);
Expand All @@ -117,7 +117,7 @@ void output_enable(struct sway_output *output, struct output_config *oc) {
output->enabled = true;
if (!apply_output_config(oc, output)) {
output->enabled = false;
return;
return false;
}

output->configured = true;
Expand Down Expand Up @@ -155,6 +155,8 @@ void output_enable(struct sway_output *output, struct output_config *oc) {

arrange_layers(output);
arrange_root();

return true;
}

static void evacuate_sticky(struct sway_workspace *old_ws,
Expand Down Expand Up @@ -267,6 +269,7 @@ void output_disable(struct sway_output *output) {

output->enabled = false;
output->configured = false;
output->current_mode = NULL;

arrange_root();
}
Expand Down