@@ -1169,12 +1169,10 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
1169
1169
container_destroy (output -> swayc );
1170
1170
}
1171
1171
1172
- if (& output -> link ) {
1173
- wl_list_remove (& output -> link );
1174
- wl_list_remove (& output -> destroy .link );
1175
- output -> wlr_output = NULL ;
1176
- free (output );
1177
- }
1172
+ wl_list_remove (& output -> link );
1173
+ wl_list_remove (& output -> destroy .link );
1174
+ output -> wlr_output -> data = NULL ;
1175
+ free (output );
1178
1176
}
1179
1177
1180
1178
static void handle_mode (struct wl_listener * listener , void * data ) {
@@ -1212,10 +1210,13 @@ void handle_new_output(struct wl_listener *listener, void *data) {
1212
1210
output -> wlr_output = wlr_output ;
1213
1211
wlr_output -> data = output ;
1214
1212
output -> server = server ;
1215
- wl_list_insert (& root_container .sway_root -> outputs , & output -> link );
1216
-
1217
1213
output -> damage = wlr_output_damage_create (wlr_output );
1218
1214
1215
+ wl_signal_add (& wlr_output -> events .destroy , & output -> destroy );
1216
+ output -> destroy .notify = handle_destroy ;
1217
+
1218
+ wl_list_insert (& root_container .sway_root -> outputs , & output -> link );
1219
+
1219
1220
if (!wl_list_empty (& wlr_output -> modes )) {
1220
1221
struct wlr_output_mode * mode =
1221
1222
wl_container_of (wlr_output -> modes .prev , mode , link );
@@ -1228,6 +1229,10 @@ void handle_new_output(struct wl_listener *listener, void *data) {
1228
1229
void output_enable (struct sway_output * output ) {
1229
1230
struct wlr_output * wlr_output = output -> wlr_output ;
1230
1231
1232
+ if (!sway_assert (output -> swayc == NULL , "output is already enabled" )) {
1233
+ return ;
1234
+ }
1235
+
1231
1236
output -> swayc = output_create (output );
1232
1237
if (!output -> swayc ) {
1233
1238
// Output is disabled
@@ -1241,8 +1246,6 @@ void output_enable(struct sway_output *output) {
1241
1246
1242
1247
input_manager_configure_xcursor (input_manager );
1243
1248
1244
- wl_signal_add (& wlr_output -> events .destroy , & output -> destroy );
1245
- output -> destroy .notify = handle_destroy ;
1246
1249
wl_signal_add (& wlr_output -> events .mode , & output -> mode );
1247
1250
output -> mode .notify = handle_mode ;
1248
1251
wl_signal_add (& wlr_output -> events .transform , & output -> transform );
0 commit comments