Fix compilation errors related to disabled outputs

master
emersion 7 years ago
parent 0b798ed954
commit 88cd7616db
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

@ -1169,12 +1169,10 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
container_destroy(output->swayc); container_destroy(output->swayc);
} }
if (&output->link) { wl_list_remove(&output->link);
wl_list_remove(&output->link); wl_list_remove(&output->destroy.link);
wl_list_remove(&output->destroy.link); output->wlr_output->data = NULL;
output->wlr_output = NULL; free(output);
free(output);
}
} }
static void handle_mode(struct wl_listener *listener, void *data) { static void handle_mode(struct wl_listener *listener, void *data) {
@ -1212,10 +1210,13 @@ void handle_new_output(struct wl_listener *listener, void *data) {
output->wlr_output = wlr_output; output->wlr_output = wlr_output;
wlr_output->data = output; wlr_output->data = output;
output->server = server; output->server = server;
wl_list_insert(&root_container.sway_root->outputs, &output->link);
output->damage = wlr_output_damage_create(wlr_output); output->damage = wlr_output_damage_create(wlr_output);
wl_signal_add(&wlr_output->events.destroy, &output->destroy);
output->destroy.notify = handle_destroy;
wl_list_insert(&root_container.sway_root->outputs, &output->link);
if (!wl_list_empty(&wlr_output->modes)) { if (!wl_list_empty(&wlr_output->modes)) {
struct wlr_output_mode *mode = struct wlr_output_mode *mode =
wl_container_of(wlr_output->modes.prev, mode, link); wl_container_of(wlr_output->modes.prev, mode, link);
@ -1228,6 +1229,10 @@ void handle_new_output(struct wl_listener *listener, void *data) {
void output_enable(struct sway_output *output) { void output_enable(struct sway_output *output) {
struct wlr_output *wlr_output = output->wlr_output; struct wlr_output *wlr_output = output->wlr_output;
if (!sway_assert(output->swayc == NULL, "output is already enabled")) {
return;
}
output->swayc = output_create(output); output->swayc = output_create(output);
if (!output->swayc) { if (!output->swayc) {
// Output is disabled // Output is disabled
@ -1241,8 +1246,6 @@ void output_enable(struct sway_output *output) {
input_manager_configure_xcursor(input_manager); input_manager_configure_xcursor(input_manager);
wl_signal_add(&wlr_output->events.destroy, &output->destroy);
output->destroy.notify = handle_destroy;
wl_signal_add(&wlr_output->events.mode, &output->mode); wl_signal_add(&wlr_output->events.mode, &output->mode);
output->mode.notify = handle_mode; output->mode.notify = handle_mode;
wl_signal_add(&wlr_output->events.transform, &output->transform); wl_signal_add(&wlr_output->events.transform, &output->transform);

@ -83,7 +83,8 @@ static const char *ipc_json_get_output_transform(enum wl_output_transform transf
return NULL; return NULL;
} }
static void ipc_json_describe_output(struct sway_container *container, json_object *object) { static void ipc_json_describe_output(struct sway_container *container,
json_object *object) {
struct wlr_output *wlr_output = container->sway_output->wlr_output; struct wlr_output *wlr_output = container->sway_output->wlr_output;
json_object_object_add(object, "type", json_object_object_add(object, "type",
json_object_new_string("output")); json_object_new_string("output"));
@ -141,12 +142,12 @@ static void ipc_json_describe_output(struct sway_container *container, json_obje
json_object *ipc_json_describe_disabled_output(struct sway_output *output) { json_object *ipc_json_describe_disabled_output(struct sway_output *output) {
struct wlr_output *wlr_output = output->wlr_output; struct wlr_output *wlr_output = output->wlr_output;
json_object *object = json_object_new_object(); json_object *object = json_object_new_object();
json_object_object_add(object, "type", json_object_new_string("output")); json_object_object_add(object, "type", json_object_new_string("output"));
json_object_object_add(object, "name", json_object_object_add(object, "name",
wlr_output->name ? json_object_new_string(wlr_output->name) : NULL); json_object_new_string(wlr_output->name));
json_object_object_add(object, "active", json_object_new_boolean(false)); json_object_object_add(object, "active", json_object_new_boolean(false));
json_object_object_add(object, "make", json_object_object_add(object, "make",
json_object_new_string(wlr_output->make)); json_object_new_string(wlr_output->make));

Loading…
Cancel
Save