container: Don't track outputs

The scene graph abstraction does this for us
This commit is contained in:
Alexander Orzechowski 2022-02-21 16:58:37 -05:00 committed by Kirill Primak
parent 1a09cfd95d
commit dc511e3ccd
4 changed files with 0 additions and 104 deletions

View file

@ -125,9 +125,6 @@ struct sway_container {
double child_total_width; double child_total_width;
double child_total_height; double child_total_height;
// Outputs currently being intersected
list_t *outputs; // struct sway_output
// Indicates that the container is a scratchpad container. // Indicates that the container is a scratchpad container.
// Both hidden and visible scratchpad containers have scratchpad=true. // Both hidden and visible scratchpad containers have scratchpad=true.
// Hidden scratchpad containers have a NULL parent. // Hidden scratchpad containers have a NULL parent.
@ -272,15 +269,6 @@ bool container_is_floating_or_child(struct sway_container *container);
*/ */
bool container_is_fullscreen_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.
* If the container is not on any output, return NULL.
*/
struct sway_output *container_get_effective_output(struct sway_container *con);
void container_discover_outputs(struct sway_container *con);
enum sway_container_layout container_parent_layout(struct sway_container *con); enum sway_container_layout container_parent_layout(struct sway_container *con);
list_t *container_get_siblings(struct sway_container *container); list_t *container_get_siblings(struct sway_container *container);

View file

@ -250,10 +250,6 @@ static void apply_container_state(struct sway_container *container,
view_center_surface(view); view_center_surface(view);
} }
} }
if (!container->node.destroying) {
container_discover_outputs(container);
}
} }
/** /**

View file

@ -115,7 +115,6 @@ struct sway_container *container_create(struct sway_view *view) {
c->view = view; c->view = view;
c->alpha = 1.0f; c->alpha = 1.0f;
c->marks = create_list(); c->marks = create_list();
c->outputs = create_list();
wl_signal_init(&c->events.destroy); wl_signal_init(&c->events.destroy);
wl_signal_emit(&root->events.new_node, &c->node); wl_signal_emit(&root->events.new_node, &c->node);
@ -371,7 +370,6 @@ void container_destroy(struct sway_container *con) {
free(con->formatted_title); free(con->formatted_title);
list_free(con->pending.children); list_free(con->pending.children);
list_free(con->current.children); list_free(con->current.children);
list_free(con->outputs);
list_free_items_and_destroy(con->marks); list_free_items_and_destroy(con->marks);
@ -515,17 +513,6 @@ bool container_has_ancestor(struct sway_container *descendant,
return false; return false;
} }
/**
* 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) {
if (con->outputs->length == 0) {
return NULL;
}
return con->outputs->items[con->outputs->length - 1];
}
/** /**
* Calculate and return the length of the tree representation. * Calculate and return the length of the tree representation.
* An example tree representation is: V[Terminal, Firefox] * An example tree representation is: V[Terminal, Firefox]
@ -1240,71 +1227,6 @@ bool container_is_fullscreen_or_child(struct sway_container *container) {
return false; return false;
} }
static void surface_send_enter_iterator(struct wlr_surface *surface,
int x, int y, void *data) {
struct wlr_output *wlr_output = data;
wlr_surface_send_enter(surface, wlr_output);
}
static void surface_send_leave_iterator(struct wlr_surface *surface,
int x, int y, void *data) {
struct wlr_output *wlr_output = data;
wlr_surface_send_leave(surface, wlr_output);
}
void container_discover_outputs(struct sway_container *con) {
struct wlr_box con_box = {
.x = con->current.x,
.y = con->current.y,
.width = con->current.width,
.height = con->current.height,
};
struct sway_output *old_output = container_get_effective_output(con);
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
struct wlr_box output_box;
output_get_box(output, &output_box);
struct wlr_box intersection;
bool intersects =
wlr_box_intersection(&intersection, &con_box, &output_box);
int index = list_find(con->outputs, output);
if (intersects && index == -1) {
// Send enter
sway_log(SWAY_DEBUG, "Container %p entered output %p", con, output);
if (con->view) {
view_for_each_surface(con->view,
surface_send_enter_iterator, output->wlr_output);
if (con->view->foreign_toplevel) {
wlr_foreign_toplevel_handle_v1_output_enter(
con->view->foreign_toplevel, output->wlr_output);
}
}
list_add(con->outputs, output);
} else if (!intersects && index != -1) {
// Send leave
sway_log(SWAY_DEBUG, "Container %p left output %p", con, output);
if (con->view) {
view_for_each_surface(con->view,
surface_send_leave_iterator, output->wlr_output);
if (con->view->foreign_toplevel) {
wlr_foreign_toplevel_handle_v1_output_leave(
con->view->foreign_toplevel, output->wlr_output);
}
}
list_del(con->outputs, index);
}
}
struct sway_output *new_output = container_get_effective_output(con);
double old_scale = old_output && old_output->enabled ?
old_output->wlr_output->scale : -1;
double new_scale = new_output ? new_output->wlr_output->scale : -1;
if (old_scale != new_scale) {
container_update_title_textures(con);
}
}
enum sway_container_layout container_parent_layout(struct sway_container *con) { enum sway_container_layout container_parent_layout(struct sway_container *con) {
if (con->pending.parent) { if (con->pending.parent) {
return con->pending.parent->pending.layout; return con->pending.parent->pending.layout;

View file

@ -284,14 +284,6 @@ void output_destroy(struct sway_output *output) {
free(output); free(output);
} }
static void untrack_output(struct sway_container *con, void *data) {
struct sway_output *output = data;
int index = list_find(con->outputs, output);
if (index != -1) {
list_del(con->outputs, index);
}
}
void output_disable(struct sway_output *output) { void output_disable(struct sway_output *output) {
if (!sway_assert(output->enabled, "Expected an enabled output")) { if (!sway_assert(output->enabled, "Expected an enabled output")) {
return; return;
@ -306,8 +298,6 @@ void output_disable(struct sway_output *output) {
output_evacuate(output); output_evacuate(output);
root_for_each_container(untrack_output, output);
list_del(root->outputs, index); list_del(root->outputs, index);
output->enabled = false; output->enabled = false;