<commit_before>use std::cmp;

use petgraph::graph::NodeIndex;
use rustwlc::{Geometry, Point, Size, ResizeEdge};

use super::super::{LayoutTree, TreeError};
use super::super::commands::CommandResult;
use super::super::core::container::{Container, ContainerType, Layout};
use ::debug_enabled;
use uuid::Uuid;

#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum LayoutErr {
    /// The node behind the UUID was asked to ground when it was already grounded.
    AlreadyGrounded(Uuid),
    /// The node behind the UUID was asked to float when it was already floating.
    AlreadyFloating(Uuid)
}

impl LayoutTree {
    /// Given the index of some container in the tree, lays out the children of
    /// that container based on what type of container it is and how big of an
    /// area is allocated for it and its children.
    pub fn layout(&mut self, node_ix: NodeIndex) {
        match self.tree[node_ix].get_type() {
            ContainerType::Root => {
                for output_ix in self.tree.children_of(node_ix) {
                    self.layout(output_ix);
                }
            }
            ContainerType::Output => {
                let handle = match self.tree[node_ix] {
                    Container::Output { ref handle, .. } => handle.clone(),
                    _ => unreachable!()
                };
                let size = handle.get_resolution()
                    .expect("Couldn't get resolution");
                let geometry = Geometry {
                    origin: Point { x: 0, y: 0 },
                    size: size
                };
                let mut fullscreen_apps = Vec::new();
                for workspace_ix in self.tree.children_of(node_ix) {
                    self.layout_helper(workspace_ix, geometry.clone(), &mut fullscreen_apps);
                }
                self.layout_fullscreen_apps(fullscreen_apps);
            }
            ContainerType::Workspace => {
                // get geometry from the parent output
                let output_ix = self.tree.ancestor_of_type(node_ix, ContainerType::Output)
                    .expect("Workspace had no output parent");<commit_msg>Fixed background not resizin<commit_after>use std::cmp;

use petgraph::graph::NodeIndex;
use rustwlc::{Geometry, Point, Size, ResizeEdge};

use super::super::{LayoutTree, TreeError};
use super::super::commands::CommandResult;
use super::super::core::container::{Container, ContainerType, Layout};
use ::debug_enabled;
use uuid::Uuid;

#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum LayoutErr {
    /// The node behind the UUID was asked to ground when it was already grounded.
    AlreadyGrounded(Uuid),
    /// The node behind the UUID was asked to float when it was already floating.
    AlreadyFloating(Uuid)
}

impl LayoutTree {
    /// Given the index of some container in the tree, lays out the children of
    /// that container based on what type of container it is and how big of an
    /// area is allocated for it and its children.
    pub fn layout(&mut self, node_ix: NodeIndex) {
        match self.tree[node_ix].get_type() {
            ContainerType::Root => {
                for output_ix in self.tree.children_of(node_ix) {
                    self.layout(output_ix);
                }
            }
            ContainerType::Output => {
                let geometry = match self.tree[node_ix] {
                    Container::Output { ref handle, ref mut background, .. } => {
                        let size = handle.get_resolution()
                            .expect("Could not get resolution");
                        let geometry = Geometry {
                            origin: Point { x: 0, y: 0 },
                            size: size
                        };
                        // update the background size
                        if let Some(background) = *background {
                            background.set_geometry(ResizeEdge::empty(), geometry)
                        }
                        geometry
                    }
                    _ => unreachable!()
                };
                let mut fullscreen_apps = Vec::new();
                for workspace_ix in self.tree.children_of(node_ix) {
                    self.layout_helper(workspace_ix, geometry.clone(), &mut fullscreen_apps);
                }
                self.layout_fullscreen_apps(fullscreen_apps);
            }
            ContainerType::Workspace => {
                // get geometry from the parent output
                let output_ix = self.tree.ancestor_of_type(node_ix, ContainerType::Output)
                    .expect("Workspace had no output parent");
{'fraction_non_alphanumeric': 0.09707903780068729, 'fraction_numerical': 0.000859106529209622, 'mean_word_length': 1.8121980676328502, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2825149', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1159, 'n_words': 354}