aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/output.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-06-05 17:56:32 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-06-06 20:11:24 -0400
commita1b5b93d299bfe129f2b3409a7f642049fcce1d6 (patch)
tree4d87f5ab8f0f18ada1fc12a4eb4ba3b5d0350527 /sway/desktop/output.c
parentMerge pull request #2116 from RedSoxFan/fix-2113 (diff)
downloadsway-a1b5b93d299bfe129f2b3409a7f642049fcce1d6.tar.gz
sway-a1b5b93d299bfe129f2b3409a7f642049fcce1d6.tar.zst
sway-a1b5b93d299bfe129f2b3409a7f642049fcce1d6.zip
Store sway_outputs so that they can be reenabled
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r--sway/desktop/output.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index acc9caae..5d02f5eb 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -1157,6 +1157,10 @@ void output_damage_whole_container(struct sway_output *output,
1157 wlr_output_damage_add_box(output->damage, &box); 1157 wlr_output_damage_add_box(output->damage, &box);
1158} 1158}
1159 1159
1160static int find_output(const void *output1, const void *output2) {
1161 return output1 == output2 ? 0 : 1;
1162}
1163
1160static void damage_handle_destroy(struct wl_listener *listener, void *data) { 1164static void damage_handle_destroy(struct wl_listener *listener, void *data) {
1161 struct sway_output *output = 1165 struct sway_output *output =
1162 wl_container_of(listener, output, damage_destroy); 1166 wl_container_of(listener, output, damage_destroy);
@@ -1165,7 +1169,19 @@ static void damage_handle_destroy(struct wl_listener *listener, void *data) {
1165 1169
1166static void handle_destroy(struct wl_listener *listener, void *data) { 1170static void handle_destroy(struct wl_listener *listener, void *data) {
1167 struct sway_output *output = wl_container_of(listener, output, destroy); 1171 struct sway_output *output = wl_container_of(listener, output, destroy);
1168 container_destroy(output->swayc); 1172 if (output->swayc) {
1173 container_destroy(output->swayc);
1174 }
1175 int index = list_seq_find(root_container.sway_root->outputs, find_output,
1176 output);
1177 if (index >= 0 && index < root_container.sway_root->outputs->length) {
1178 wlr_log(L_DEBUG, "Removing %s from outputs list",
1179 output->wlr_output->name);
1180 list_del(root_container.sway_root->outputs, index);
1181 wl_list_remove(&output->destroy.link);
1182 output->wlr_output = NULL;
1183 free(output);
1184 }
1169} 1185}
1170 1186
1171static void handle_mode(struct wl_listener *listener, void *data) { 1187static void handle_mode(struct wl_listener *listener, void *data) {
@@ -1203,6 +1219,7 @@ void handle_new_output(struct wl_listener *listener, void *data) {
1203 output->wlr_output = wlr_output; 1219 output->wlr_output = wlr_output;
1204 wlr_output->data = output; 1220 wlr_output->data = output;
1205 output->server = server; 1221 output->server = server;
1222 list_add(root_container.sway_root->outputs, output);
1206 1223
1207 if (!wl_list_empty(&wlr_output->modes)) { 1224 if (!wl_list_empty(&wlr_output->modes)) {
1208 struct wlr_output_mode *mode = 1225 struct wlr_output_mode *mode =
@@ -1210,11 +1227,23 @@ void handle_new_output(struct wl_listener *listener, void *data) {
1210 wlr_output_set_mode(wlr_output, mode); 1227 wlr_output_set_mode(wlr_output, mode);
1211 } 1228 }
1212 1229
1213 output->damage = wlr_output_damage_create(wlr_output); 1230 output_enable(output);
1231}
1232
1233void output_enable(struct sway_output *output) {
1234 struct wlr_output *wlr_output = output->wlr_output;
1235
1236 if (!wlr_output->data) {
1237 wlr_output->data = output;
1238 }
1239
1240 if (!output->damage) {
1241 output->damage = wlr_output_damage_create(wlr_output);
1242 }
1214 1243
1215 output->swayc = output_create(output); 1244 output->swayc = output_create(output);
1216 if (!output->swayc) { 1245 if (!output->swayc) {
1217 free(output); 1246 // Output is disabled
1218 return; 1247 return;
1219 } 1248 }
1220 1249