]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/osd.c: Ensure destroying views are not used as preview anchors
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Mon, 26 Sep 2022 08:58:13 +0000 (10:58 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Tue, 27 Sep 2022 16:35:10 +0000 (17:35 +0100)
src/desktop.c
src/osd.c

index f5384f8d09e1ceda401ed8ead056e456897acafc..5e7e0196e14b8373fc179dafe871c205a0260dc8 100644 (file)
@@ -216,6 +216,10 @@ desktop_cycle_view(struct server *server, struct view *start_view,
         *   - Pre-select the top view if NOT already focused
         *   - Otherwise select the view second from the top
         */
+
+       /* Make sure to have all nodes in their actual ordering */
+       osd_preview_restore(server);
+
        if (!start_view) {
                start_view = first_view(server);
                if (!start_view || start_view != desktop_focused_view(server)) {
@@ -233,9 +237,6 @@ desktop_cycle_view(struct server *server, struct view *start_view,
        /* Scene nodes are ordered like last node == displayed topmost */
        iter = dir == LAB_CYCLE_DIR_FORWARD ? get_prev_item : get_next_item;
 
-       /* Make sure to have all nodes in their actual ordering */
-       osd_preview_restore(server);
-
        do {
                list_item = iter(list_item);
                if (list_item == list_head) {
index f24bbcfdbe94ded2d8e9658ad4ab7423c8a07742..a91ec00077d58ca668131187a025e3ed974dc2c4 100644 (file)
--- a/src/osd.c
+++ b/src/osd.c
@@ -124,6 +124,8 @@ osd_on_view_destroy(struct view *view)
                 * If we are the current OSD selected view, cycle
                 * to the next because we are dying.
                 */
+
+               /* Also resets preview node */
                osd_state->cycle_view = desktop_cycle_view(view->server,
                        osd_state->cycle_view, LAB_CYCLE_DIR_BACKWARD);
 
@@ -137,6 +139,11 @@ osd_on_view_destroy(struct view *view)
                }
        }
 
+       if (osd_state->cycle_view) {
+               /* Update the OSD to reflect the view has now gone. */
+               osd_update(view->server);
+       }
+
        if (view->scene_tree) {
                struct wlr_scene_node *node = &view->scene_tree->node;
                if (osd_state->preview_anchor == node) {
@@ -147,11 +154,6 @@ osd_on_view_destroy(struct view *view)
                        osd_state->preview_anchor = lab_wlr_scene_get_prev_node(node);
                }
        }
-
-       if (osd_state->cycle_view) {
-               /* Update the OSD to reflect the view has now gone. */
-               osd_update(view->server);
-       }
 }
 
 void