]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/output.c: Make sure we are always using the correct scene_node
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Sat, 30 Apr 2022 23:23:31 +0000 (01:23 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 2 May 2022 08:54:01 +0000 (09:54 +0100)
Also make sure we are only applying layout specific changes
once the output specific ones were committed successfully.

Fixes #312
Reported-By: @fakeczg
src/output.c

index d4863a9ffcba0522e4daf15957f271c669a3267c..0e3768d4beb91aca8faef4638fce217a18622a08 100644 (file)
@@ -169,15 +169,7 @@ new_output_notify(struct wl_listener *listener, void *data)
        }
 
        wlr_output_layout_add_auto(server->output_layout, wlr_output);
-
-       /* TODO: check this makes sense */
-       struct wlr_scene_output *scene_output;
-       wl_list_for_each (scene_output, &output->server->scene->outputs, link) {
-               if (scene_output->output == wlr_output) {
-                       output->scene_output = scene_output;
-                       break;
-               }
-       }
+       output->scene_output = wlr_scene_get_scene_output(server->scene, wlr_output);
        assert(output->scene_output);
 }
 
@@ -238,19 +230,13 @@ output_config_apply(struct server *server,
        struct wlr_output_configuration_head_v1 *head;
        wl_list_for_each(head, &config->heads, link) {
                struct wlr_output *o = head->state.output;
+               struct output *output = output_from_wlr_output(server, o);
                bool need_to_add = head->state.enabled && !o->enabled;
-               if (need_to_add) {
-                       wlr_output_layout_add_auto(server->output_layout, o);
-               }
-
                bool need_to_remove = !head->state.enabled && o->enabled;
-               if (need_to_remove) {
-                       /* TODO: should we output->scene_output = NULL; ?? */
-                       wlr_output_layout_remove(server->output_layout, o);
-               }
 
                wlr_output_enable(o, head->state.enabled);
                if (head->state.enabled) {
+                       /* Output specifc actions only */
                        if (head->state.mode) {
                                wlr_output_set_mode(o, head->state.mode);
                        } else {
@@ -260,12 +246,31 @@ output_config_apply(struct server *server,
                                wlr_output_set_custom_mode(o, width,
                                        height, refresh);
                        }
-                       wlr_output_layout_move(server->output_layout, o,
-                               head->state.x, head->state.y);
                        wlr_output_set_scale(o, head->state.scale);
                        wlr_output_set_transform(o, head->state.transform);
                }
-               wlr_output_commit(o);
+               if (!wlr_output_commit(o)) {
+                       wlr_log(WLR_ERROR, "Output config commit failed");
+                       continue;
+               }
+
+               /* Only do Layout specific actions if the commit went trough */
+               if (need_to_add) {
+                       wlr_output_layout_add_auto(server->output_layout, o);
+                       output->scene_output = wlr_scene_get_scene_output(server->scene, o);
+                       assert(output->scene_output);
+               }
+
+               if (head->state.enabled) {
+                       wlr_output_layout_move(server->output_layout, o,
+                               head->state.x, head->state.y);
+               }
+
+               if (need_to_remove) {
+                       wlr_output_layout_remove(server->output_layout, o);
+                       output->scene_output = NULL;
+               }
+
        }
 
        server->pending_output_config = NULL;