1
1
mirror of https://github.com/swaywm/sway synced 2024-11-23 05:02:01 +01:00

container: Don't track outputs

The scene graph abstraction does this for us
This commit is contained in:
Alexander Orzechowski 2023-02-21 20:58:17 -05:00 committed by Kirill Primak
parent 1e018e72b4
commit 5f0801b6f2
10 changed files with 0 additions and 143 deletions

@ -1,10 +0,0 @@
#ifndef _SWAY_SURFACE_H
#define _SWAY_SURFACE_H
#include <wlr/types/wlr_compositor.h>
void surface_enter_output(struct wlr_surface *surface,
struct sway_output *output);
void surface_leave_output(struct wlr_surface *surface,
struct sway_output *output);
#endif

@ -125,9 +125,6 @@ struct sway_container {
double child_total_width;
double child_total_height;
// 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.
@ -280,15 +277,6 @@ 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.
* 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);
list_t *container_get_siblings(struct sway_container *container);

@ -14,7 +14,6 @@
#include "sway/layers.h"
#include "sway/output.h"
#include "sway/server.h"
#include "sway/surface.h"
#include "sway/tree/arrange.h"
#include "sway/tree/workspace.h"
#include <wlr/types/wlr_scene.h>

@ -1,31 +0,0 @@
#define _POSIX_C_SOURCE 200112L
#include <stdlib.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_fractional_scale_v1.h>
#include "sway/server.h"
#include "sway/surface.h"
#include "sway/output.h"
static void surface_update_outputs(struct wlr_surface *surface) {
float scale = 1;
struct wlr_surface_output *surface_output;
wl_list_for_each(surface_output, &surface->current_outputs, link) {
if (surface_output->output->scale > scale) {
scale = surface_output->output->scale;
}
}
wlr_fractional_scale_v1_notify_scale(surface, scale);
wlr_surface_set_preferred_buffer_scale(surface, ceil(scale));
}
void surface_enter_output(struct wlr_surface *surface,
struct sway_output *output) {
wlr_surface_send_enter(surface, output->wlr_output);
surface_update_outputs(surface);
}
void surface_leave_output(struct wlr_surface *surface,
struct sway_output *output) {
wlr_surface_send_leave(surface, output->wlr_output);
surface_update_outputs(surface);
}

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

@ -8,7 +8,6 @@
#include "sway/layers.h"
#include "sway/output.h"
#include "sway/server.h"
#include "sway/surface.h"
struct sway_session_lock_output {
struct wlr_scene_tree *tree;

@ -18,7 +18,6 @@ sway_sources = files(
'desktop/idle_inhibit_v1.c',
'desktop/layer_shell.c',
'desktop/output.c',
'desktop/surface.c',
'desktop/transaction.c',
'desktop/xdg_shell.c',
'desktop/launcher.c',

@ -17,7 +17,6 @@
#include "sway/sway_text_node.h"
#include "sway/output.h"
#include "sway/server.h"
#include "sway/surface.h"
#include "sway/tree/arrange.h"
#include "sway/tree/view.h"
#include "sway/tree/workspace.h"
@ -113,7 +112,6 @@ struct sway_container *container_create(struct sway_view *view) {
c->view = view;
c->alpha = 1.0f;
c->marks = create_list();
c->outputs = create_list();
wl_signal_init(&c->events.destroy);
wl_signal_emit_mutable(&root->events.new_node, &c->node);
@ -453,7 +451,6 @@ void container_destroy(struct sway_container *con) {
free(con->formatted_title);
list_free(con->pending.children);
list_free(con->current.children);
list_free(con->outputs);
list_free_items_and_destroy(con->marks);
@ -597,18 +594,6 @@ bool container_has_ancestor(struct sway_container *descendant,
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.
* An example tree representation is: V[Terminal, Firefox]
@ -1267,63 +1252,6 @@ bool container_is_fullscreen_or_child(struct sway_container *container) {
return false;
}
static void surface_send_enter_iterator(struct wlr_surface *surface,
int x, int y, void *data) {
struct sway_output *output = data;
surface_enter_output(surface, output);
}
static void surface_send_leave_iterator(struct wlr_surface *surface,
int x, int y, void *data) {
struct sway_output *output = data;
surface_leave_output(surface, 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,
};
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);
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);
if (con->view->foreign_toplevel) {
wlr_foreign_toplevel_handle_v1_output_leave(
con->view->foreign_toplevel, output->wlr_output);
}
}
list_del(con->outputs, index);
}
}
}
enum sway_container_layout container_parent_layout(struct sway_container *con) {
if (con->pending.parent) {
return con->pending.parent->pending.layout;

@ -283,14 +283,6 @@ void output_destroy(struct sway_output *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) {
if (!sway_assert(output->enabled, "Expected an enabled output")) {
return;
@ -305,8 +297,6 @@ void output_disable(struct sway_output *output) {
output_evacuate(output);
root_for_each_container(untrack_output, output);
list_del(root->outputs, index);
output->enabled = false;

@ -25,7 +25,6 @@
#include "sway/input/seat.h"
#include "sway/scene_descriptor.h"
#include "sway/server.h"
#include "sway/surface.h"
#include "sway/sway_text_node.h"
#include "sway/tree/arrange.h"
#include "sway/tree/container.h"