aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Alexander Orzechowski <alex@ozal.ski>2023-11-14 15:11:56 -0500
committerLibravatar Kirill Primak <vyivel@eclair.cafe>2024-01-18 18:36:54 +0300
commit5fc85c506687c0b0704e264e50299885e82d5602 (patch)
tree42ca09b116775ac811ed1186bfbcabd1bb81bc8f
parentremove damage debug options (diff)
downloadsway-5fc85c506687c0b0704e264e50299885e82d5602.tar.gz
sway-5fc85c506687c0b0704e264e50299885e82d5602.tar.zst
sway-5fc85c506687c0b0704e264e50299885e82d5602.zip
scene_graph: port wlr_forgein_toplevel_management output enter/leave events
-rw-r--r--include/sway/tree/container.h4
-rw-r--r--sway/desktop/transaction.c4
-rw-r--r--sway/tree/container.c47
3 files changed, 55 insertions, 0 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 37a6b2b3..93f6bfbb 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -91,6 +91,10 @@ struct sway_container {
91 } border; 91 } border;
92 92
93 struct wlr_scene_tree *content_tree; 93 struct wlr_scene_tree *content_tree;
94 struct wlr_scene_buffer *output_handler;
95
96 struct wl_listener output_enter;
97 struct wl_listener output_leave;
94 98
95 struct sway_container_state current; 99 struct sway_container_state current;
96 struct sway_container_state pending; 100 struct sway_container_state pending;
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index 980e839e..acc3e3f9 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -385,6 +385,10 @@ static void arrange_container(struct sway_container *con,
385 // make sure it's enabled for viewing 385 // make sure it's enabled for viewing
386 wlr_scene_node_set_enabled(&con->scene_tree->node, true); 386 wlr_scene_node_set_enabled(&con->scene_tree->node, true);
387 387
388 if (con->output_handler) {
389 wlr_scene_buffer_set_dest_size(con->output_handler, width, height);
390 }
391
388 if (con->view) { 392 if (con->view) {
389 int border_top = container_titlebar_height(); 393 int border_top = container_titlebar_height();
390 int border_width = con->current.border_thickness; 394 int border_width = con->current.border_thickness;
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
28static 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
40static 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
52static bool handle_point_accepts_input(
53 struct wlr_scene_buffer *buffer, double *x, double *y) {
54 return false;
55}
56
28static struct wlr_scene_rect *alloc_rect_node(struct wlr_scene_tree *parent, 57static 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 }