autocommit 2022-04-20 17:28:17 CEST
This commit is contained in:
parent
ab3c2e44f4
commit
1227ede560
9 changed files with 137 additions and 25 deletions
|
|
@ -8,7 +8,10 @@ use {
|
|||
wl_surface::WlSurface,
|
||||
},
|
||||
rect::Rect,
|
||||
render::{Renderer, Texture},
|
||||
state::State,
|
||||
text,
|
||||
theme::Color,
|
||||
tree::{
|
||||
FindTreeResult, FoundNode, FullscreenNode, Node, NodeId, NodeVisitor, SizedNode,
|
||||
SizedToplevelNode, ToplevelData, WorkspaceNode,
|
||||
|
|
@ -22,6 +25,7 @@ use {
|
|||
rc::Rc,
|
||||
},
|
||||
};
|
||||
use crate::utils::errorfmt::ErrorFmt;
|
||||
|
||||
tree_id!(DetachedNodeId);
|
||||
pub struct PlaceholderNode {
|
||||
|
|
@ -37,6 +41,7 @@ pub struct PlaceholderNode {
|
|||
toplevel: ToplevelData,
|
||||
active: Cell<bool>,
|
||||
destroyed: Cell<bool>,
|
||||
texture: CloneCell<Option<Rc<Texture>>>,
|
||||
}
|
||||
|
||||
impl PlaceholderNode {
|
||||
|
|
@ -54,9 +59,14 @@ impl PlaceholderNode {
|
|||
toplevel: Default::default(),
|
||||
active: Default::default(),
|
||||
destroyed: Default::default(),
|
||||
texture: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn texture(&self) -> Option<Rc<Texture>> {
|
||||
self.texture.get()
|
||||
}
|
||||
|
||||
pub fn set_title(&self, title: &str) {
|
||||
*self.title.borrow_mut() = title.to_string();
|
||||
if let Some(parent) = self.parent.get() {
|
||||
|
|
@ -67,6 +77,10 @@ impl PlaceholderNode {
|
|||
pub fn is_destroyed(&self) -> bool {
|
||||
self.destroyed.get()
|
||||
}
|
||||
|
||||
pub fn position(&self) -> Rect {
|
||||
self.pos.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl SizedNode for PlaceholderNode {
|
||||
|
|
@ -146,7 +160,32 @@ impl SizedNode for PlaceholderNode {
|
|||
}
|
||||
|
||||
fn change_extents(self: &Rc<Self>, rect: &Rect) {
|
||||
log::info!("{:?}", rect);
|
||||
self.pos.set(*rect);
|
||||
if let Some(p) = self.parent.get() {
|
||||
p.node_child_size_changed(self.deref(), rect.width(), rect.height());
|
||||
}
|
||||
self.texture.set(None);
|
||||
if let Some(ctx) = self.state.render_ctx.get() {
|
||||
if rect.width() != 0 && rect.height() != 0 {
|
||||
let font = format!("monospace {}", rect.width() / 10);
|
||||
match text::render_fitting(
|
||||
&ctx,
|
||||
rect.height(),
|
||||
&font,
|
||||
"Fullscreen",
|
||||
Color::GREY,
|
||||
false,
|
||||
) {
|
||||
Ok(t) => {
|
||||
self.texture.set(Some(t));
|
||||
},
|
||||
Err(e) => {
|
||||
log::warn!("Could not render fullscreen texture: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
|
|
@ -161,6 +200,10 @@ impl SizedNode for PlaceholderNode {
|
|||
fn client(&self) -> Option<Rc<Client>> {
|
||||
self.client.clone()
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_placeholder(self, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
impl SizedToplevelNode for PlaceholderNode {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue