autocommit 2022-03-26 22:58:30 CET
This commit is contained in:
parent
3b1b843821
commit
707ff6066c
28 changed files with 2307 additions and 707 deletions
|
|
@ -315,7 +315,10 @@ impl ContainerNode {
|
|||
|
||||
fn perform_mono_layout(self: &Rc<Self>, child: &ContainerChild) {
|
||||
let mb = self.mono_body.get();
|
||||
child.node.clone().change_extents(&mb.move_(self.abs_x1.get(), self.abs_y1.get()));
|
||||
child
|
||||
.node
|
||||
.clone()
|
||||
.change_extents(&mb.move_(self.abs_x1.get(), self.abs_y1.get()));
|
||||
self.mono_content
|
||||
.set(child.content.get().at_point(mb.x1(), mb.y1()));
|
||||
}
|
||||
|
|
@ -566,7 +569,8 @@ impl ContainerNode {
|
|||
let mut pos = 0;
|
||||
for (i, c) in self.children.iter().enumerate() {
|
||||
if i > 0 {
|
||||
rd.border_rects.push(Rect::new_sized(pos - bw, 0, bw, th).unwrap());
|
||||
rd.border_rects
|
||||
.push(Rect::new_sized(pos - bw, 0, bw, th).unwrap());
|
||||
}
|
||||
let mut width = space_per_child;
|
||||
if rem > 0 {
|
||||
|
|
@ -583,9 +587,9 @@ impl ContainerNode {
|
|||
let title = c.title.borrow_mut();
|
||||
match text::render(&ctx, width, th, &font, &title, Color::GREY) {
|
||||
Ok(t) => rd.titles.push(ContainerTitle {
|
||||
x: pos,
|
||||
y: 0,
|
||||
tex: t,
|
||||
x: pos,
|
||||
y: 0,
|
||||
tex: t,
|
||||
}),
|
||||
Err(e) => {
|
||||
log::error!("Could not render title {}: {}", title, ErrorFmt(e));
|
||||
|
|
@ -594,7 +598,8 @@ impl ContainerNode {
|
|||
}
|
||||
pos += width + bw;
|
||||
}
|
||||
rd.underline_rects.push(Rect::new_sized(0, th, cwidth, 1).unwrap());
|
||||
rd.underline_rects
|
||||
.push(Rect::new_sized(0, th, cwidth, 1).unwrap());
|
||||
} else {
|
||||
let split = self.split.get();
|
||||
for (i, c) in self.children.iter().enumerate() {
|
||||
|
|
@ -607,7 +612,8 @@ impl ContainerNode {
|
|||
};
|
||||
rd.border_rects.push(rect);
|
||||
}
|
||||
let rect = Rect::new_sized(body.x1(), body.y1() - th - 1, body.width(), th).unwrap();
|
||||
let rect =
|
||||
Rect::new_sized(body.x1(), body.y1() - th - 1, body.width(), th).unwrap();
|
||||
if c.active.get() {
|
||||
rd.active_title_rects.push(rect);
|
||||
} else {
|
||||
|
|
@ -799,7 +805,9 @@ impl Node for ContainerNode {
|
|||
matches!(direction, Direction::Left | Direction::Right)
|
||||
} else {
|
||||
match self.split.get() {
|
||||
ContainerSplit::Horizontal => matches!(direction, Direction::Left | Direction::Right),
|
||||
ContainerSplit::Horizontal => {
|
||||
matches!(direction, Direction::Left | Direction::Right)
|
||||
}
|
||||
ContainerSplit::Vertical => matches!(direction, Direction::Up | Direction::Down),
|
||||
}
|
||||
};
|
||||
|
|
@ -831,8 +839,12 @@ impl Node for ContainerNode {
|
|||
if mc.is_some() {
|
||||
self.mono_child.set(Some(sibling.clone()));
|
||||
let body = self.mono_body.get();
|
||||
self.mono_content.set(sibling.content.get().at_point(body.x1(), body.y1()));
|
||||
sibling.node.clone().change_extents(&body.move_(self.abs_x1.get(), self.abs_y1.get()));
|
||||
self.mono_content
|
||||
.set(sibling.content.get().at_point(body.x1(), body.y1()));
|
||||
sibling
|
||||
.node
|
||||
.clone()
|
||||
.change_extents(&body.move_(self.abs_x1.get(), self.abs_y1.get()));
|
||||
}
|
||||
sibling.node.clone().do_focus(seat, direction);
|
||||
}
|
||||
|
|
@ -1167,7 +1179,10 @@ impl Node for ContainerNode {
|
|||
.child_size_changed(&*self, rect.width(), rect.height());
|
||||
} else {
|
||||
if let Some(c) = self.mono_child.get() {
|
||||
let body = self.mono_body.get().move_(self.abs_x1.get(), self.abs_y1.get());
|
||||
let body = self
|
||||
.mono_body
|
||||
.get()
|
||||
.move_(self.abs_x1.get(), self.abs_y1.get());
|
||||
c.node.clone().change_extents(&body);
|
||||
} else {
|
||||
for child in self.children.iter() {
|
||||
|
|
@ -1187,7 +1202,9 @@ impl Node for ContainerNode {
|
|||
|
||||
fn set_parent(self: Rc<Self>, parent: Rc<dyn Node>) {
|
||||
self.parent.set(parent.clone());
|
||||
parent.clone().child_active_changed(&*self, self.active.get());
|
||||
parent
|
||||
.clone()
|
||||
.child_active_changed(&*self, self.active.get());
|
||||
parent.child_size_changed(&*self, self.width.get(), self.height.get());
|
||||
parent
|
||||
.clone()
|
||||
|
|
|
|||
|
|
@ -1,19 +1,55 @@
|
|||
use crate::ifs::wl_seat::WlSeatGlobal;
|
||||
use crate::ifs::wl_seat::{SeatId};
|
||||
use crate::ifs::wl_surface::WlSurface;
|
||||
use crate::tree::Node;
|
||||
use crate::tree::{Node, WorkspaceNode};
|
||||
use crate::utils::linkedlist::LinkedNode;
|
||||
use std::rc::Rc;
|
||||
use crate::NumCell;
|
||||
use crate::utils::smallmap::SmallMap;
|
||||
|
||||
pub trait ToplevelNode: Node {
|
||||
pub trait ToplevelNode {
|
||||
fn data(&self) -> &ToplevelData;
|
||||
fn parent(&self) -> Option<Rc<dyn Node>>;
|
||||
fn focus_surface(&self, seat: &WlSeatGlobal) -> Rc<WlSurface>;
|
||||
fn set_focus_history_link(&self, seat: &WlSeatGlobal, link: LinkedNode<Rc<dyn ToplevelNode>>);
|
||||
fn workspace(&self) -> Option<Rc<WorkspaceNode>>;
|
||||
fn as_node(&self) -> &dyn Node;
|
||||
fn into_node(self: Rc<Self>) -> Rc<dyn Node>;
|
||||
fn accepts_keyboard_focus(&self) -> bool;
|
||||
fn default_surface(&self) -> Rc<WlSurface>;
|
||||
fn set_active(&self, active: bool);
|
||||
fn activate(&self);
|
||||
fn toggle_floating(self: Rc<Self>);
|
||||
}
|
||||
|
||||
fn parent_is_float(&self) -> bool {
|
||||
if let Some(parent) = self.parent() {
|
||||
return parent.is_float();
|
||||
}
|
||||
false
|
||||
#[derive(Default)]
|
||||
pub struct ToplevelData {
|
||||
pub active_surfaces: NumCell<u32>,
|
||||
pub focus_surface: SmallMap<SeatId, Rc<WlSurface>, 1>,
|
||||
pub toplevel_history: SmallMap<SeatId, LinkedNode<Rc<dyn ToplevelNode>>, 1>,
|
||||
}
|
||||
|
||||
impl ToplevelData {
|
||||
pub fn clear(&self) {
|
||||
self.focus_surface.clear();
|
||||
self.toplevel_history.clear();
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> dyn ToplevelNode + 'a {
|
||||
pub fn surface_active_changed(&self, active: bool) {
|
||||
if active {
|
||||
if self.data().active_surfaces.fetch_add(1) == 0 {
|
||||
self.set_active(true);
|
||||
}
|
||||
} else {
|
||||
if self.data().active_surfaces.fetch_sub(1) == 1 {
|
||||
self.set_active(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn focus_surface(&self, seat: SeatId) -> Rc<WlSurface> {
|
||||
self.data()
|
||||
.focus_surface
|
||||
.get(&seat)
|
||||
.unwrap_or_else(|| self.default_surface())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue