]> git.mdlowis.com Git - proto/labwc.git/commitdiff
desktop: move scene-tree node in move-to-back
authorJohan Malm <jgm323@gmail.com>
Sat, 25 Mar 2023 16:38:43 +0000 (16:38 +0000)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 26 Mar 2023 19:22:57 +0000 (20:22 +0100)
view_minimize() does not need to call desktop_move_to_back() because the
stacking order is not changed and the windowSwitcher uses the scene-tree
nodes anyway.

Note: Movement of xwayland sub-views still relies on keeping server->views
in sync with z-order

include/view-impl-common.h
include/view.h
src/desktop.c
src/view-impl-common.c
src/view.c
src/xdg.c
src/xwayland.c

index 0ee5a8dc7b3af936eb4dfde3bd22527a709bb8c7..a36f2d518af3968acd4acb56c8818aa5f3eaa62f 100644 (file)
@@ -10,6 +10,7 @@
 struct view;
 
 void view_impl_move_to_front(struct view *view);
+void view_impl_move_to_back(struct view *view);
 void view_impl_map(struct view *view);
 
 /*
index f7a0996eb5c1b533e689f0927bc457d41cf79bc7..f3eb0634b797b8c522038c9aed4f81db110bd752 100644 (file)
@@ -37,6 +37,7 @@ struct view_impl {
        void (*unmap)(struct view *view);
        void (*maximize)(struct view *view, bool maximize);
        void (*move_to_front)(struct view *view);
+       void (*move_to_back)(struct view *view);
 };
 
 struct view {
index 3b871f517d5e25fab5c236c008dbc7fa948ec164..1e43c382f4a3644ceab4adb1ffe9961906a5be92 100644 (file)
@@ -30,8 +30,10 @@ desktop_move_to_back(struct view *view)
        if (!view) {
                return;
        }
-       wl_list_remove(&view->link);
-       wl_list_append(&view->server->views, &view->link);
+       if (view->impl->move_to_back) {
+               view->impl->move_to_back(view);
+               cursor_update_focus(view->server);
+       }
 }
 
 void
index e336fa6959616a2b1aa2a8cecae45ba220508d71..e4d13f840209e5b812d56a38b753c69a54b6ae46 100644 (file)
@@ -2,6 +2,7 @@
 /* view-impl-common.c: common code for shell view->impl functions */
 #include <stdio.h>
 #include <strings.h>
+#include "common/list.h"
 #include "labwc.h"
 #include "view.h"
 #include "view-impl-common.h"
@@ -14,6 +15,14 @@ view_impl_move_to_front(struct view *view)
        wlr_scene_node_raise_to_top(&view->scene_tree->node);
 }
 
+void
+view_impl_move_to_back(struct view *view)
+{
+       wl_list_remove(&view->link);
+       wl_list_append(&view->server->views, &view->link);
+       wlr_scene_node_lower_to_bottom(&view->scene_tree->node);
+}
+
 void
 view_impl_map(struct view *view)
 {
index a7a6a8a0c4831fd89eb0086488cffe88dd25e760..bfa0e035e3ea34c7f8b704c54ddba82d20e8d293 100644 (file)
@@ -232,7 +232,6 @@ view_minimize(struct view *view, bool minimized)
        view->minimized = minimized;
        if (minimized) {
                view->impl->unmap(view);
-               desktop_move_to_back(view);
                _view_set_activated(view, false);
                if (view == view->server->focused_view) {
                        /*
index 806be850dff3d3405e2a6e1e55ce15193967662a..1c4160029ed757646b26cbb4caf8fe786d7536ee 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -455,6 +455,7 @@ static const struct view_impl xdg_toplevel_view_impl = {
        .unmap = xdg_toplevel_view_unmap,
        .maximize = xdg_toplevel_view_maximize,
        .move_to_front = view_impl_move_to_front,
+       .move_to_back = view_impl_move_to_back,
 };
 
 void
index f688dac1231a64f0d46ea39383e578f3103ad158..1a849513f51559adb2fa12e06094c7e7d24c6e00 100644 (file)
@@ -497,8 +497,13 @@ xwayland_view_maximize(struct view *view, bool maximized)
                maximized);
 }
 
+enum z_direction {
+       LAB_TO_FRONT,
+       LAB_TO_BACK,
+};
+
 static void
-move_sub_views_to_front(struct view *parent)
+move_sub_views(struct view *parent, enum z_direction z_direction)
 {
        assert(parent);
 
@@ -524,7 +529,11 @@ move_sub_views_to_front(struct view *parent)
                if (top_parent_of(view) != parent_xwayland_surface) {
                        continue;
                }
-               view_impl_move_to_front(view);
+               if (z_direction == LAB_TO_FRONT) {
+                       view_impl_move_to_front(view);
+               } else if (z_direction == LAB_TO_BACK) {
+                       view_impl_move_to_back(view);
+               }
        }
 }
 
@@ -532,7 +541,14 @@ static void
 xwayland_view_move_to_front(struct view *view)
 {
        view_impl_move_to_front(view);
-       move_sub_views_to_front(view);
+       move_sub_views(view, LAB_TO_FRONT);
+}
+
+static void
+xwayland_view_move_to_back(struct view *view)
+{
+       view_impl_move_to_back(view);
+       move_sub_views(view, LAB_TO_BACK);
 }
 
 static void
@@ -576,6 +592,7 @@ static const struct view_impl xwayland_view_impl = {
        .unmap = xwayland_view_unmap,
        .maximize = xwayland_view_maximize,
        .move_to_front = xwayland_view_move_to_front,
+       .move_to_back = xwayland_view_move_to_back,
 };
 
 static void