diff options
author | Alexander Orzechowski <alex@ozal.ski> | 2023-02-21 20:58:17 -0500 |
---|---|---|
committer | Kirill Primak <vyivel@eclair.cafe> | 2024-01-18 18:36:54 +0300 |
commit | 5f0801b6f245cc789ea93b9449dd0c573ef36e66 (patch) | |
tree | 657615d28252b0b3bd01ef240ac6ae49dad15f74 | |
parent | Delete old damage tracking code (diff) | |
download | sway-5f0801b6f245cc789ea93b9449dd0c573ef36e66.tar.gz sway-5f0801b6f245cc789ea93b9449dd0c573ef36e66.tar.zst sway-5f0801b6f245cc789ea93b9449dd0c573ef36e66.zip |
container: Don't track outputs
The scene graph abstraction does this for us
-rw-r--r-- | include/sway/surface.h | 10 | ||||
-rw-r--r-- | include/sway/tree/container.h | 12 | ||||
-rw-r--r-- | sway/desktop/layer_shell.c | 1 | ||||
-rw-r--r-- | sway/desktop/surface.c | 31 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 4 | ||||
-rw-r--r-- | sway/lock.c | 1 | ||||
-rw-r--r-- | sway/meson.build | 1 | ||||
-rw-r--r-- | sway/tree/container.c | 72 | ||||
-rw-r--r-- | sway/tree/output.c | 10 | ||||
-rw-r--r-- | sway/tree/view.c | 1 |
10 files changed, 0 insertions, 143 deletions
diff --git a/include/sway/surface.h b/include/sway/surface.h deleted file mode 100644 index 81eb80d5..00000000 --- a/include/sway/surface.h +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | #ifndef _SWAY_SURFACE_H | ||
2 | #define _SWAY_SURFACE_H | ||
3 | #include <wlr/types/wlr_compositor.h> | ||
4 | |||
5 | void surface_enter_output(struct wlr_surface *surface, | ||
6 | struct sway_output *output); | ||
7 | void surface_leave_output(struct wlr_surface *surface, | ||
8 | struct sway_output *output); | ||
9 | |||
10 | #endif | ||
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 4cd4c847..37a6b2b3 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -125,9 +125,6 @@ struct sway_container { | |||
125 | double child_total_width; | 125 | double child_total_width; |
126 | double child_total_height; | 126 | double child_total_height; |
127 | 127 | ||
128 | // Outputs currently being intersected | ||
129 | list_t *outputs; // struct sway_output | ||
130 | |||
131 | // Indicates that the container is a scratchpad container. | 128 | // Indicates that the container is a scratchpad container. |
132 | // Both hidden and visible scratchpad containers have scratchpad=true. | 129 | // Both hidden and visible scratchpad containers have scratchpad=true. |
133 | // Hidden scratchpad containers have a NULL parent. | 130 | // Hidden scratchpad containers have a NULL parent. |
@@ -280,15 +277,6 @@ bool container_is_floating_or_child(struct sway_container *container); | |||
280 | */ | 277 | */ |
281 | bool container_is_fullscreen_or_child(struct sway_container *container); | 278 | bool container_is_fullscreen_or_child(struct sway_container *container); |
282 | 279 | ||
283 | /** | ||
284 | * Return the output which will be used for scale purposes. | ||
285 | * This is the most recently entered output. | ||
286 | * If the container is not on any output, return NULL. | ||
287 | */ | ||
288 | struct sway_output *container_get_effective_output(struct sway_container *con); | ||
289 | |||
290 | void container_discover_outputs(struct sway_container *con); | ||
291 | |||
292 | enum sway_container_layout container_parent_layout(struct sway_container *con); | 280 | enum sway_container_layout container_parent_layout(struct sway_container *con); |
293 | 281 | ||
294 | list_t *container_get_siblings(struct sway_container *container); | 282 | list_t *container_get_siblings(struct sway_container *container); |
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index a52d27fa..aca99c97 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include "sway/layers.h" | 14 | #include "sway/layers.h" |
15 | #include "sway/output.h" | 15 | #include "sway/output.h" |
16 | #include "sway/server.h" | 16 | #include "sway/server.h" |
17 | #include "sway/surface.h" | ||
18 | #include "sway/tree/arrange.h" | 17 | #include "sway/tree/arrange.h" |
19 | #include "sway/tree/workspace.h" | 18 | #include "sway/tree/workspace.h" |
20 | #include <wlr/types/wlr_scene.h> | 19 | #include <wlr/types/wlr_scene.h> |
diff --git a/sway/desktop/surface.c b/sway/desktop/surface.c deleted file mode 100644 index af17a8bb..00000000 --- a/sway/desktop/surface.c +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | #define _POSIX_C_SOURCE 200112L | ||
2 | #include <stdlib.h> | ||
3 | #include <wlr/types/wlr_compositor.h> | ||
4 | #include <wlr/types/wlr_fractional_scale_v1.h> | ||
5 | #include "sway/server.h" | ||
6 | #include "sway/surface.h" | ||
7 | #include "sway/output.h" | ||
8 | |||
9 | static void surface_update_outputs(struct wlr_surface *surface) { | ||
10 | float scale = 1; | ||
11 | struct wlr_surface_output *surface_output; | ||
12 | wl_list_for_each(surface_output, &surface->current_outputs, link) { | ||
13 | if (surface_output->output->scale > scale) { | ||
14 | scale = surface_output->output->scale; | ||
15 | } | ||
16 | } | ||
17 | wlr_fractional_scale_v1_notify_scale(surface, scale); | ||
18 | wlr_surface_set_preferred_buffer_scale(surface, ceil(scale)); | ||
19 | } | ||
20 | |||
21 | void surface_enter_output(struct wlr_surface *surface, | ||
22 | struct sway_output *output) { | ||
23 | wlr_surface_send_enter(surface, output->wlr_output); | ||
24 | surface_update_outputs(surface); | ||
25 | } | ||
26 | |||
27 | void surface_leave_output(struct wlr_surface *surface, | ||
28 | struct sway_output *output) { | ||
29 | wlr_surface_send_leave(surface, output->wlr_output); | ||
30 | surface_update_outputs(surface); | ||
31 | } | ||
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 5f104aa3..ba9d0648 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -250,10 +250,6 @@ static void apply_container_state(struct sway_container *container, | |||
250 | view_center_surface(view); | 250 | view_center_surface(view); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | |||
254 | if (!container->node.destroying) { | ||
255 | container_discover_outputs(container); | ||
256 | } | ||
257 | } | 253 | } |
258 | 254 | ||
259 | /** | 255 | /** |
diff --git a/sway/lock.c b/sway/lock.c index 2856ae67..8ad9c3f6 100644 --- a/sway/lock.c +++ b/sway/lock.c | |||
@@ -8,7 +8,6 @@ | |||
8 | #include "sway/layers.h" | 8 | #include "sway/layers.h" |
9 | #include "sway/output.h" | 9 | #include "sway/output.h" |
10 | #include "sway/server.h" | 10 | #include "sway/server.h" |
11 | #include "sway/surface.h" | ||
12 | 11 | ||
13 | struct sway_session_lock_output { | 12 | struct sway_session_lock_output { |
14 | struct wlr_scene_tree *tree; | 13 | struct wlr_scene_tree *tree; |
diff --git a/sway/meson.build b/sway/meson.build index 1079c749..d937e425 100644 --- a/sway/meson.build +++ b/sway/meson.build | |||
@@ -18,7 +18,6 @@ sway_sources = files( | |||
18 | 'desktop/idle_inhibit_v1.c', | 18 | 'desktop/idle_inhibit_v1.c', |
19 | 'desktop/layer_shell.c', | 19 | 'desktop/layer_shell.c', |
20 | 'desktop/output.c', | 20 | 'desktop/output.c', |
21 | 'desktop/surface.c', | ||
22 | 'desktop/transaction.c', | 21 | 'desktop/transaction.c', |
23 | 'desktop/xdg_shell.c', | 22 | 'desktop/xdg_shell.c', |
24 | 'desktop/launcher.c', | 23 | 'desktop/launcher.c', |
diff --git a/sway/tree/container.c b/sway/tree/container.c index cde9dff5..b19081fc 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include "sway/sway_text_node.h" | 17 | #include "sway/sway_text_node.h" |
18 | #include "sway/output.h" | 18 | #include "sway/output.h" |
19 | #include "sway/server.h" | 19 | #include "sway/server.h" |
20 | #include "sway/surface.h" | ||
21 | #include "sway/tree/arrange.h" | 20 | #include "sway/tree/arrange.h" |
22 | #include "sway/tree/view.h" | 21 | #include "sway/tree/view.h" |
23 | #include "sway/tree/workspace.h" | 22 | #include "sway/tree/workspace.h" |
@@ -113,7 +112,6 @@ struct sway_container *container_create(struct sway_view *view) { | |||
113 | c->view = view; | 112 | c->view = view; |
114 | c->alpha = 1.0f; | 113 | c->alpha = 1.0f; |
115 | c->marks = create_list(); | 114 | c->marks = create_list(); |
116 | c->outputs = create_list(); | ||
117 | 115 | ||
118 | wl_signal_init(&c->events.destroy); | 116 | wl_signal_init(&c->events.destroy); |
119 | wl_signal_emit_mutable(&root->events.new_node, &c->node); | 117 | wl_signal_emit_mutable(&root->events.new_node, &c->node); |
@@ -453,7 +451,6 @@ void container_destroy(struct sway_container *con) { | |||
453 | free(con->formatted_title); | 451 | free(con->formatted_title); |
454 | list_free(con->pending.children); | 452 | list_free(con->pending.children); |
455 | list_free(con->current.children); | 453 | list_free(con->current.children); |
456 | list_free(con->outputs); | ||
457 | 454 | ||
458 | list_free_items_and_destroy(con->marks); | 455 | list_free_items_and_destroy(con->marks); |
459 | 456 | ||
@@ -597,18 +594,6 @@ bool container_has_ancestor(struct sway_container *descendant, | |||
597 | return false; | 594 | return false; |
598 | } | 595 | } |
599 | 596 | ||
600 | |||
601 | /** | ||
602 | * Return the output which will be used for scale purposes. | ||
603 | * This is the most recently entered output. | ||
604 | */ | ||
605 | struct sway_output *container_get_effective_output(struct sway_container *con) { | ||
606 | if (con->outputs->length == 0) { | ||
607 | return NULL; | ||
608 | } | ||
609 | return con->outputs->items[con->outputs->length - 1]; | ||
610 | } | ||
611 | |||
612 | /** | 597 | /** |
613 | * Calculate and return the length of the tree representation. | 598 | * Calculate and return the length of the tree representation. |
614 | * An example tree representation is: V[Terminal, Firefox] | 599 | * An example tree representation is: V[Terminal, Firefox] |
@@ -1267,63 +1252,6 @@ bool container_is_fullscreen_or_child(struct sway_container *container) { | |||
1267 | return false; | 1252 | return false; |
1268 | } | 1253 | } |
1269 | 1254 | ||
1270 | static void surface_send_enter_iterator(struct wlr_surface *surface, | ||
1271 | int x, int y, void *data) { | ||
1272 | struct sway_output *output = data; | ||
1273 | surface_enter_output(surface, output); | ||
1274 | } | ||
1275 | |||
1276 | static void surface_send_leave_iterator(struct wlr_surface *surface, | ||
1277 | int x, int y, void *data) { | ||
1278 | struct sway_output *output = data; | ||
1279 | surface_leave_output(surface, output); | ||
1280 | } | ||
1281 | |||
1282 | void container_discover_outputs(struct sway_container *con) { | ||
1283 | struct wlr_box con_box = { | ||
1284 | .x = con->current.x, | ||
1285 | .y = con->current.y, | ||
1286 | .width = con->current.width, | ||
1287 | .height = con->current.height, | ||
1288 | }; | ||
1289 | |||
1290 | for (int i = 0; i < root->outputs->length; ++i) { | ||
1291 | struct sway_output *output = root->outputs->items[i]; | ||
1292 | struct wlr_box output_box; | ||
1293 | output_get_box(output, &output_box); | ||
1294 | struct wlr_box intersection; | ||
1295 | bool intersects = | ||
1296 | wlr_box_intersection(&intersection, &con_box, &output_box); | ||
1297 | int index = list_find(con->outputs, output); | ||
1298 | |||
1299 | if (intersects && index == -1) { | ||
1300 | // Send enter | ||
1301 | sway_log(SWAY_DEBUG, "Container %p entered output %p", con, output); | ||
1302 | if (con->view) { | ||
1303 | view_for_each_surface(con->view, | ||
1304 | surface_send_enter_iterator, output); | ||
1305 | if (con->view->foreign_toplevel) { | ||
1306 | wlr_foreign_toplevel_handle_v1_output_enter( | ||
1307 | con->view->foreign_toplevel, output->wlr_output); | ||
1308 | } | ||
1309 | } | ||
1310 | list_add(con->outputs, output); | ||
1311 | } else if (!intersects && index != -1) { | ||
1312 | // Send leave | ||
1313 | sway_log(SWAY_DEBUG, "Container %p left output %p", con, output); | ||
1314 | if (con->view) { | ||
1315 | view_for_each_surface(con->view, | ||
1316 | surface_send_leave_iterator, output); | ||
1317 | if (con->view->foreign_toplevel) { | ||
1318 | wlr_foreign_toplevel_handle_v1_output_leave( | ||
1319 | con->view->foreign_toplevel, output->wlr_output); | ||
1320 | } | ||
1321 | } | ||
1322 | list_del(con->outputs, index); | ||
1323 | } | ||
1324 | } | ||
1325 | } | ||
1326 | |||
1327 | enum sway_container_layout container_parent_layout(struct sway_container *con) { | 1255 | enum sway_container_layout container_parent_layout(struct sway_container *con) { |
1328 | if (con->pending.parent) { | 1256 | if (con->pending.parent) { |
1329 | return con->pending.parent->pending.layout; | 1257 | return con->pending.parent->pending.layout; |
diff --git a/sway/tree/output.c b/sway/tree/output.c index 3c8823dc..cd7bf0c2 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c | |||
@@ -283,14 +283,6 @@ void output_destroy(struct sway_output *output) { | |||
283 | free(output); | 283 | free(output); |
284 | } | 284 | } |
285 | 285 | ||
286 | static void untrack_output(struct sway_container *con, void *data) { | ||
287 | struct sway_output *output = data; | ||
288 | int index = list_find(con->outputs, output); | ||
289 | if (index != -1) { | ||
290 | list_del(con->outputs, index); | ||
291 | } | ||
292 | } | ||
293 | |||
294 | void output_disable(struct sway_output *output) { | 286 | void output_disable(struct sway_output *output) { |
295 | if (!sway_assert(output->enabled, "Expected an enabled output")) { | 287 | if (!sway_assert(output->enabled, "Expected an enabled output")) { |
296 | return; | 288 | return; |
@@ -305,8 +297,6 @@ void output_disable(struct sway_output *output) { | |||
305 | 297 | ||
306 | output_evacuate(output); | 298 | output_evacuate(output); |
307 | 299 | ||
308 | root_for_each_container(untrack_output, output); | ||
309 | |||
310 | list_del(root->outputs, index); | 300 | list_del(root->outputs, index); |
311 | 301 | ||
312 | output->enabled = false; | 302 | output->enabled = false; |
diff --git a/sway/tree/view.c b/sway/tree/view.c index 2874e88b..3bc0855b 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include "sway/input/seat.h" | 25 | #include "sway/input/seat.h" |
26 | #include "sway/scene_descriptor.h" | 26 | #include "sway/scene_descriptor.h" |
27 | #include "sway/server.h" | 27 | #include "sway/server.h" |
28 | #include "sway/surface.h" | ||
29 | #include "sway/sway_text_node.h" | 28 | #include "sway/sway_text_node.h" |
30 | #include "sway/tree/arrange.h" | 29 | #include "sway/tree/arrange.h" |
31 | #include "sway/tree/container.h" | 30 | #include "sway/tree/container.h" |