From 0f6d212629964c6a131b5675fa6c9f4d48da43aa Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 19 Aug 2018 11:01:51 +1000 Subject: Send output enter/leave events correctly Previously we used a reparent event to detect when a view changes parent, then sent an output enter/leave to the surfaces if needed. This worked for tiling views but not floating views, as floating views can intersect another output without changing parent. The solution implemented for floating views also applies cleanly to tiling views, so the previous method has been completely replaced and the reparent event has been removed. This introduces a new function container_discover_outputs. This function compares the container's `current` position to the outputs, sends enter and leave events as needed, and keeps track of which outputs it's intersecting in a new `container->outputs` list. If it has entered a new output with a different scale then the title and marks textures will also be recreated at the new scale. The function is called when a transaction applies. This is convenient as it means we don't have to call it from various places. There is imperfect rendering when a floating view overlaps two outputs with different scales. It renders correctly for the most recently entered output, but there is only one title texture so it renders incorrectly on the old output. Fixes #2482 --- include/sway/tree/container.h | 10 +++++----- include/sway/tree/view.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'include/sway') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 5eccedc1..e0cda17c 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -138,6 +138,9 @@ struct sway_container { struct sway_container *parent; + // Outputs currently being intersected + list_t *outputs; // struct sway_output + // Indicates that the container is a scratchpad container. // Both hidden and visible scratchpad containers have scratchpad=true. // Hidden scratchpad containers have a NULL parent. @@ -166,12 +169,7 @@ struct sway_container { struct { struct wl_signal destroy; - // Raised after the tree updates, but before arrange_windows - // Passed the previous parent - struct wl_signal reparent; } events; - - struct wl_listener reparent; }; struct sway_container *container_create(enum sway_container_type type); @@ -353,4 +351,6 @@ bool container_is_floating_or_child(struct sway_container *container); */ bool container_is_fullscreen_or_child(struct sway_container *container); +void container_discover_outputs(struct sway_container *con); + #endif diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 2747e7c4..5fdecc2b 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -120,7 +120,6 @@ struct sway_view { } events; struct wl_listener surface_new_subsurface; - struct wl_listener container_reparent; }; struct sway_xdg_shell_v6_view { -- cgit v1.2.3 From e1955c5c08d4131fd5d3e2a91ec8af05c3117eca Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 20 Aug 2018 10:37:52 +1000 Subject: Fix crash when adding output --- include/sway/tree/container.h | 6 ++++++ sway/tree/container.c | 3 +-- sway/tree/view.c | 6 ++++-- 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'include/sway') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index e0cda17c..cd886cd0 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -351,6 +351,12 @@ bool container_is_floating_or_child(struct sway_container *container); */ bool container_is_fullscreen_or_child(struct sway_container *container); +/** + * Return the output which will be used for scale purposes. + * This is the most recently entered output. + */ +struct sway_output *container_get_effective_output(struct sway_container *con); + void container_discover_outputs(struct sway_container *con); #endif diff --git a/sway/tree/container.c b/sway/tree/container.c index b932925d..6ea0cc94 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -764,8 +764,7 @@ void container_damage_whole(struct sway_container *container) { * Return the output which will be used for scale purposes. * This is the most recently entered output. */ -static struct sway_output *container_get_effective_output( - struct sway_container *con) { +struct sway_output *container_get_effective_output(struct sway_container *con) { if (con->outputs->length == 0) { return NULL; } diff --git a/sway/tree/view.c b/sway/tree/view.c index 4abf1abb..2c0c1aa9 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -889,8 +889,10 @@ void view_add_mark(struct sway_view *view, char *mark) { static void update_marks_texture(struct sway_view *view, struct wlr_texture **texture, struct border_colors *class) { - struct sway_output *output = - view->swayc->outputs->items[view->swayc->outputs->length - 1]; + struct sway_output *output = container_get_effective_output(view->swayc); + if (!output) { + return; + } if (*texture) { wlr_texture_destroy(*texture); *texture = NULL; -- cgit v1.2.3