autocommit 2022-02-20 21:53:46 CET
This commit is contained in:
parent
fbb389b5e9
commit
292fa50fe7
18 changed files with 594 additions and 280 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use crate::backend::{KeyState};
|
||||
use crate::backend::KeyState;
|
||||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal, BTN_LEFT};
|
||||
|
|
@ -19,10 +19,6 @@ use std::mem;
|
|||
use std::ops::{Deref, DerefMut, Sub};
|
||||
use std::rc::Rc;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum ContainerSplit {
|
||||
|
|
@ -135,14 +131,14 @@ impl ContainerNode {
|
|||
parent: Rc<dyn Node>,
|
||||
child: Rc<dyn Node>,
|
||||
split: ContainerSplit,
|
||||
) -> Self {
|
||||
) -> Rc<Self> {
|
||||
child.clone().set_workspace(workspace);
|
||||
let children = LinkedList::new();
|
||||
let mut child_nodes = AHashMap::new();
|
||||
child_nodes.insert(
|
||||
child.id(),
|
||||
children.add_last(ContainerChild {
|
||||
node: child,
|
||||
node: child.clone(),
|
||||
active: Cell::new(false),
|
||||
body: Cell::new(Default::default()),
|
||||
content: Cell::new(Default::default()),
|
||||
|
|
@ -152,7 +148,7 @@ impl ContainerNode {
|
|||
title_texture: Default::default(),
|
||||
}),
|
||||
);
|
||||
Self {
|
||||
let slf = Rc::new(Self {
|
||||
id: state.node_ids.next(),
|
||||
parent: CloneCell::new(parent),
|
||||
active: Cell::new(false),
|
||||
|
|
@ -177,7 +173,9 @@ impl ContainerNode {
|
|||
workspace: CloneCell::new(workspace.clone()),
|
||||
seats: RefCell::new(Default::default()),
|
||||
state: state.clone(),
|
||||
}
|
||||
});
|
||||
child.set_parent(slf.clone());
|
||||
slf
|
||||
}
|
||||
|
||||
pub fn num_children(&self) -> usize {
|
||||
|
|
@ -283,11 +281,15 @@ impl ContainerNode {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn on_theme_changed(self: &Rc<Self>) {
|
||||
pub fn on_spaces_changed(self: &Rc<Self>) {
|
||||
self.update_content_size();
|
||||
self.schedule_layout();
|
||||
}
|
||||
|
||||
pub fn on_colors_changed(self: &Rc<Self>) {
|
||||
self.schedule_render_titles();
|
||||
}
|
||||
|
||||
fn schedule_layout(self: &Rc<Self>) {
|
||||
if !self.layout_scheduled.replace(true) {
|
||||
self.state.pending_container_layout.push(self.clone());
|
||||
|
|
@ -500,6 +502,7 @@ impl ContainerNode {
|
|||
}
|
||||
|
||||
fn render_titles(&self) {
|
||||
self.render_titles_scheduled.set(false);
|
||||
let theme = &self.state.theme;
|
||||
let th = theme.title_height.get();
|
||||
let font = theme.font.borrow_mut();
|
||||
|
|
@ -523,7 +526,6 @@ impl ContainerNode {
|
|||
};
|
||||
c.title_texture.set(Some(texture));
|
||||
}
|
||||
self.render_titles_scheduled.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -547,7 +549,7 @@ pub async fn container_layout(state: Rc<State>) {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn render_titles(state: Rc<State>) {
|
||||
pub async fn container_titles(state: Rc<State>) {
|
||||
loop {
|
||||
let container = state.pending_container_titles.pop().await;
|
||||
if container.render_titles_scheduled.get() {
|
||||
|
|
@ -835,6 +837,21 @@ impl Node for ContainerNode {
|
|||
self.parent.get().focus_self(seat);
|
||||
}
|
||||
|
||||
fn toggle_floating(self: Rc<Self>, _seat: &Rc<WlSeatGlobal>) {
|
||||
let parent = self.parent.get();
|
||||
parent.clone().remove_child(&*self);
|
||||
if parent.is_float() {
|
||||
self.state.map_tiled(self.clone());
|
||||
} else {
|
||||
self.state.map_floating(
|
||||
self.clone(),
|
||||
self.width.get(),
|
||||
self.height.get(),
|
||||
&self.workspace.get(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
let mut recurse = |content: Rect, child: NodeRef<ContainerChild>| {
|
||||
if content.contains(x, y) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue