diff options
author | Alexander Orzechowski <alex@ozal.ski> | 2023-11-14 15:11:56 -0500 |
---|---|---|
committer | Kirill Primak <vyivel@eclair.cafe> | 2024-01-18 18:36:54 +0300 |
commit | 5fc85c506687c0b0704e264e50299885e82d5602 (patch) | |
tree | 42ca09b116775ac811ed1186bfbcabd1bb81bc8f /sway/tree/container.c | |
parent | remove damage debug options (diff) | |
download | sway-5fc85c506687c0b0704e264e50299885e82d5602.tar.gz sway-5fc85c506687c0b0704e264e50299885e82d5602.tar.zst sway-5fc85c506687c0b0704e264e50299885e82d5602.zip |
scene_graph: port wlr_forgein_toplevel_management output enter/leave events
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index b19081fc..30cb97ba 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -25,6 +25,35 @@ | |||
25 | #include "log.h" | 25 | #include "log.h" |
26 | #include "stringop.h" | 26 | #include "stringop.h" |
27 | 27 | ||
28 | static void handle_output_enter( | ||
29 | struct wl_listener *listener, void *data) { | ||
30 | struct sway_container *con = wl_container_of( | ||
31 | listener, con, output_enter); | ||
32 | struct wlr_scene_output *output = data; | ||
33 | |||
34 | if (con->view->foreign_toplevel) { | ||
35 | wlr_foreign_toplevel_handle_v1_output_enter( | ||
36 | con->view->foreign_toplevel, output->output); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | static void handle_output_leave( | ||
41 | struct wl_listener *listener, void *data) { | ||
42 | struct sway_container *con = wl_container_of( | ||
43 | listener, con, output_leave); | ||
44 | struct wlr_scene_output *output = data; | ||
45 | |||
46 | if (con->view->foreign_toplevel) { | ||
47 | wlr_foreign_toplevel_handle_v1_output_leave( | ||
48 | con->view->foreign_toplevel, output->output); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | static bool handle_point_accepts_input( | ||
53 | struct wlr_scene_buffer *buffer, double *x, double *y) { | ||
54 | return false; | ||
55 | } | ||
56 | |||
28 | static struct wlr_scene_rect *alloc_rect_node(struct wlr_scene_tree *parent, | 57 | static struct wlr_scene_rect *alloc_rect_node(struct wlr_scene_tree *parent, |
29 | bool *failed) { | 58 | bool *failed) { |
30 | if (*failed) { | 59 | if (*failed) { |
@@ -63,6 +92,7 @@ struct sway_container *container_create(struct sway_view *view) { | |||
63 | // - content_tree (we put the content node here so when we disable the | 92 | // - content_tree (we put the content node here so when we disable the |
64 | // border everything gets disabled. We only render the content iff there | 93 | // border everything gets disabled. We only render the content iff there |
65 | // is a border as well) | 94 | // is a border as well) |
95 | // - buffer used for output enter/leave events for foreign_toplevel | ||
66 | bool failed = false; | 96 | bool failed = false; |
67 | c->scene_tree = alloc_scene_tree(root->staging, &failed); | 97 | c->scene_tree = alloc_scene_tree(root->staging, &failed); |
68 | 98 | ||
@@ -90,6 +120,22 @@ struct sway_container *container_create(struct sway_view *view) { | |||
90 | c->border.bottom = alloc_rect_node(c->border.tree, &failed); | 120 | c->border.bottom = alloc_rect_node(c->border.tree, &failed); |
91 | c->border.left = alloc_rect_node(c->border.tree, &failed); | 121 | c->border.left = alloc_rect_node(c->border.tree, &failed); |
92 | c->border.right = alloc_rect_node(c->border.tree, &failed); | 122 | c->border.right = alloc_rect_node(c->border.tree, &failed); |
123 | |||
124 | c->output_handler = wlr_scene_buffer_create(c->border.tree, NULL); | ||
125 | if (!c->output_handler) { | ||
126 | sway_log(SWAY_ERROR, "Failed to allocate a scene node"); | ||
127 | failed = true; | ||
128 | } | ||
129 | |||
130 | if (!failed) { | ||
131 | c->output_enter.notify = handle_output_enter; | ||
132 | wl_signal_add(&c->output_handler->events.output_enter, | ||
133 | &c->output_enter); | ||
134 | c->output_leave.notify = handle_output_leave; | ||
135 | wl_signal_add(&c->output_handler->events.output_leave, | ||
136 | &c->output_leave); | ||
137 | c->output_handler->point_accepts_input = handle_point_accepts_input; | ||
138 | } | ||
93 | } | 139 | } |
94 | 140 | ||
95 | if (!failed && !scene_descriptor_assign(&c->scene_tree->node, | 141 | if (!failed && !scene_descriptor_assign(&c->scene_tree->node, |
@@ -456,6 +502,7 @@ void container_destroy(struct sway_container *con) { | |||
456 | 502 | ||
457 | if (con->view && con->view->container == con) { | 503 | if (con->view && con->view->container == con) { |
458 | con->view->container = NULL; | 504 | con->view->container = NULL; |
505 | wlr_scene_node_destroy(&con->output_handler->node); | ||
459 | if (con->view->destroying) { | 506 | if (con->view->destroying) { |
460 | view_destroy(con->view); | 507 | view_destroy(con->view); |
461 | } | 508 | } |