aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar Alexander Orzechowski <alex@ozal.ski>2024-01-18 10:00:45 -0500
committerLibravatar Kirill Primak <vyivel@eclair.cafe>2024-01-18 18:36:54 +0300
commit1eb16d136774c8fb3c9085df45156264f0db8814 (patch)
tree9c348ab37edae50b76a388d7e8d8dcd011cea33b /include
parentview: init function should return a success bool (diff)
downloadsway-1eb16d136774c8fb3c9085df45156264f0db8814.tar.gz
sway-1eb16d136774c8fb3c9085df45156264f0db8814.tar.zst
sway-1eb16d136774c8fb3c9085df45156264f0db8814.zip
scene_graph: Maintain `wlr_scene_node`s for the sway tree.
Diffstat (limited to 'include')
-rw-r--r--include/sway/output.h15
-rw-r--r--include/sway/tree/container.h21
-rw-r--r--include/sway/tree/node.h12
-rw-r--r--include/sway/tree/root.h26
-rw-r--r--include/sway/tree/view.h4
-rw-r--r--include/sway/tree/workspace.h7
6 files changed, 85 insertions, 0 deletions
diff --git a/include/sway/output.h b/include/sway/output.h
index 96bd10db..691ac8dd 100644
--- a/include/sway/output.h
+++ b/include/sway/output.h
@@ -5,6 +5,7 @@
5#include <wayland-server-core.h> 5#include <wayland-server-core.h>
6#include <wlr/types/wlr_damage_ring.h> 6#include <wlr/types/wlr_damage_ring.h>
7#include <wlr/types/wlr_output.h> 7#include <wlr/types/wlr_output.h>
8#include <wlr/types/wlr_scene.h>
8#include "config.h" 9#include "config.h"
9#include "sway/tree/node.h" 10#include "sway/tree/node.h"
10#include "sway/tree/view.h" 11#include "sway/tree/view.h"
@@ -19,7 +20,21 @@ struct sway_output_state {
19 20
20struct sway_output { 21struct sway_output {
21 struct sway_node node; 22 struct sway_node node;
23
24 struct {
25 struct wlr_scene_tree *tiling;
26 struct wlr_scene_tree *fullscreen;
27 } layers;
28
29 // when a container is fullscreen, in case the fullscreen surface is
30 // translucent (can see behind) we must make sure that the background is a
31 // solid color in order to conform to the wayland protocol. This rect
32 // ensures that when looking through a surface, all that will be seen
33 // is black.
34 struct wlr_scene_rect *fullscreen_background;
35
22 struct wlr_output *wlr_output; 36 struct wlr_output *wlr_output;
37 struct wlr_scene_output *scene_output;
23 struct sway_server *server; 38 struct sway_server *server;
24 struct wl_list link; 39 struct wl_list link;
25 40
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index fe3ee8a8..ee22a0d0 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -3,6 +3,7 @@
3#include <stdint.h> 3#include <stdint.h>
4#include <sys/types.h> 4#include <sys/types.h>
5#include <wlr/types/wlr_compositor.h> 5#include <wlr/types/wlr_compositor.h>
6#include <wlr/types/wlr_scene.h>
6#include "list.h" 7#include "list.h"
7#include "sway/tree/node.h" 8#include "sway/tree/node.h"
8 9
@@ -68,6 +69,26 @@ struct sway_container {
68 struct sway_node node; 69 struct sway_node node;
69 struct sway_view *view; 70 struct sway_view *view;
70 71
72 struct wlr_scene_tree *scene_tree;
73
74 struct {
75 struct wlr_scene_tree *tree;
76
77 struct wlr_scene_tree *border;
78 struct wlr_scene_tree *background;
79 } title_bar;
80
81 struct {
82 struct wlr_scene_tree *tree;
83
84 struct wlr_scene_rect *top;
85 struct wlr_scene_rect *bottom;
86 struct wlr_scene_rect *left;
87 struct wlr_scene_rect *right;
88 } border;
89
90 struct wlr_scene_tree *content_tree;
91
71 struct sway_container_state current; 92 struct sway_container_state current;
72 struct sway_container_state pending; 93 struct sway_container_state pending;
73 94
diff --git a/include/sway/tree/node.h b/include/sway/tree/node.h
index 03a389a4..e2dbcdf0 100644
--- a/include/sway/tree/node.h
+++ b/include/sway/tree/node.h
@@ -2,6 +2,7 @@
2#define _SWAY_NODE_H 2#define _SWAY_NODE_H
3#include <wayland-server-core.h> 3#include <wayland-server-core.h>
4#include <stdbool.h> 4#include <stdbool.h>
5#include <wlr/types/wlr_scene.h>
5#include "list.h" 6#include "list.h"
6 7
7#define MIN_SANE_W 100 8#define MIN_SANE_W 100
@@ -75,4 +76,15 @@ list_t *node_get_children(struct sway_node *node);
75 76
76bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor); 77bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor);
77 78
79// when destroying a sway tree, it's not known which order the tree will be
80// destroyed. To prevent freeing of scene_nodes recursing up the tree,
81// let's use this helper function to disown them to the staging node.
82void scene_node_disown_children(struct wlr_scene_tree *tree);
83
84// a helper function used to allocate tree nodes. If an allocation failure
85// occurs a flag is flipped that can be checked later to destroy a parent
86// of this scene node preventing memory leaks.
87struct wlr_scene_tree *alloc_scene_tree(struct wlr_scene_tree *parent,
88 bool *failed);
89
78#endif 90#endif
diff --git a/include/sway/tree/root.h b/include/sway/tree/root.h
index b3dda12f..9cb3d7bf 100644
--- a/include/sway/tree/root.h
+++ b/include/sway/tree/root.h
@@ -3,6 +3,7 @@
3#include <wayland-server-core.h> 3#include <wayland-server-core.h>
4#include <wayland-util.h> 4#include <wayland-util.h>
5#include <wlr/types/wlr_output_layout.h> 5#include <wlr/types/wlr_output_layout.h>
6#include <wlr/types/wlr_scene.h>
6#include <wlr/render/wlr_texture.h> 7#include <wlr/render/wlr_texture.h>
7#include "sway/tree/container.h" 8#include "sway/tree/container.h"
8#include "sway/tree/node.h" 9#include "sway/tree/node.h"
@@ -16,6 +17,31 @@ struct sway_root {
16 struct wlr_output_layout *output_layout; 17 struct wlr_output_layout *output_layout;
17 18
18 struct wl_listener output_layout_change; 19 struct wl_listener output_layout_change;
20
21 // scene node layout:
22 // - root
23 // - staging
24 // - layer shell stuff
25 // - tiling
26 // - floating
27 // - fullscreen stuff
28 // - seat stuff
29 // - ext_session_lock
30 struct wlr_scene *root_scene;
31
32 // since wlr_scene nodes can't be orphaned and must always
33 // have a parent, use this staging scene_tree so that a
34 // node always have a valid parent. Nothing in this
35 // staging node will be visible.
36 struct wlr_scene_tree *staging;
37
38 struct {
39 struct wlr_scene_tree *tiling;
40 struct wlr_scene_tree *floating;
41 struct wlr_scene_tree *fullscreen;
42 struct wlr_scene_tree *fullscreen_global;
43 } layers;
44
19#if HAVE_XWAYLAND 45#if HAVE_XWAYLAND
20 struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link 46 struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link
21#endif 47#endif
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 822e7bb3..4aaed9e3 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -2,6 +2,7 @@
2#define _SWAY_VIEW_H 2#define _SWAY_VIEW_H
3#include <wayland-server-core.h> 3#include <wayland-server-core.h>
4#include <wlr/types/wlr_compositor.h> 4#include <wlr/types/wlr_compositor.h>
5#include <wlr/types/wlr_scene.h>
5#include "sway/config.h" 6#include "sway/config.h"
6#if HAVE_XWAYLAND 7#if HAVE_XWAYLAND
7#include <wlr/xwayland.h> 8#include <wlr/xwayland.h>
@@ -69,6 +70,9 @@ struct sway_view {
69 enum sway_view_type type; 70 enum sway_view_type type;
70 const struct sway_view_impl *impl; 71 const struct sway_view_impl *impl;
71 72
73 struct wlr_scene_tree *scene_tree;
74 struct wlr_scene_tree *content_tree;
75
72 struct sway_container *container; // NULL if unmapped and transactions finished 76 struct sway_container *container; // NULL if unmapped and transactions finished
73 struct wlr_surface *surface; // NULL for unmapped views 77 struct wlr_surface *surface; // NULL for unmapped views
74 struct sway_xdg_decoration *xdg_decoration; 78 struct sway_xdg_decoration *xdg_decoration;
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h
index b0fef4ca..58bde20c 100644
--- a/include/sway/tree/workspace.h
+++ b/include/sway/tree/workspace.h
@@ -2,6 +2,7 @@
2#define _SWAY_WORKSPACE_H 2#define _SWAY_WORKSPACE_H
3 3
4#include <stdbool.h> 4#include <stdbool.h>
5#include <wlr/types/wlr_scene.h>
5#include "sway/config.h" 6#include "sway/config.h"
6#include "sway/tree/container.h" 7#include "sway/tree/container.h"
7#include "sway/tree/node.h" 8#include "sway/tree/node.h"
@@ -23,6 +24,12 @@ struct sway_workspace_state {
23 24
24struct sway_workspace { 25struct sway_workspace {
25 struct sway_node node; 26 struct sway_node node;
27
28 struct {
29 struct wlr_scene_tree *tiling;
30 struct wlr_scene_tree *fullscreen;
31 } layers;
32
26 struct sway_container *fullscreen; 33 struct sway_container *fullscreen;
27 34
28 char *name; 35 char *name;