autocommit 2022-04-10 18:26:13 CEST
This commit is contained in:
parent
af152f7f3e
commit
6b3316e920
26 changed files with 514 additions and 82 deletions
|
|
@ -3,7 +3,10 @@ use {
|
|||
backend::KeyState,
|
||||
cursor::KnownCursor,
|
||||
fixed::Fixed,
|
||||
ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal, BTN_LEFT},
|
||||
ifs::wl_seat::{
|
||||
wl_pointer::{PendingScroll, VERTICAL_SCROLL},
|
||||
NodeSeatState, SeatId, WlSeatGlobal, BTN_LEFT, PX_PER_SCROLL,
|
||||
},
|
||||
rect::Rect,
|
||||
render::{Renderer, Texture},
|
||||
state::State,
|
||||
|
|
@ -32,8 +35,6 @@ use {
|
|||
rc::Rc,
|
||||
},
|
||||
};
|
||||
use crate::ifs::wl_seat::PX_PER_SCROLL;
|
||||
use crate::ifs::wl_seat::wl_pointer::{PendingScroll, VERTICAL_SCROLL};
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
|
|
@ -290,6 +291,7 @@ impl ContainerNode {
|
|||
};
|
||||
new.clone().set_workspace(&self.workspace.get());
|
||||
new.clone().set_parent(self.clone());
|
||||
new.set_visible(self.visible.get());
|
||||
let num_children = self.num_children.fetch_add(1) + 1;
|
||||
self.update_content_size();
|
||||
let new_child_factor = 1.0 / num_children as f64;
|
||||
|
|
@ -1134,24 +1136,36 @@ impl Node for ContainerNode {
|
|||
Some(c) => c,
|
||||
None => return,
|
||||
};
|
||||
let (have_mc, was_mc) = match self.mono_child.get() {
|
||||
None => (false, false),
|
||||
Some(mc) => (true, mc.node.id() == old.id()),
|
||||
};
|
||||
node.focus_history.set(None);
|
||||
let link = node.append(ContainerChild {
|
||||
node: new.clone(),
|
||||
active: Cell::new(false),
|
||||
body: Cell::new(node.body.get()),
|
||||
content: Cell::new(node.content.get()),
|
||||
content: Default::default(),
|
||||
factor: Cell::new(node.factor.get()),
|
||||
title: Default::default(),
|
||||
title_rect: Cell::new(node.title_rect.get()),
|
||||
focus_history: Cell::new(None),
|
||||
});
|
||||
let body = link.body.get();
|
||||
drop(node);
|
||||
let mut body = None;
|
||||
if was_mc {
|
||||
self.mono_child.set(Some(link.to_ref()));
|
||||
body = Some(self.mono_body.get());
|
||||
} else if !have_mc {
|
||||
body = Some(link.body.get());
|
||||
};
|
||||
self.child_nodes.borrow_mut().insert(new.id(), link);
|
||||
new.clone().set_parent(self.clone());
|
||||
new.clone().set_workspace(&self.workspace.get());
|
||||
let body = body.move_(self.abs_x1.get(), self.abs_y1.get());
|
||||
new.clone().change_extents(&body);
|
||||
if let Some(body) = body {
|
||||
let body = body.move_(self.abs_x1.get(), self.abs_y1.get());
|
||||
new.clone().change_extents(&body);
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_child(self: Rc<Self>, child: &dyn Node) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ use {
|
|||
crate::{
|
||||
backend::Mode,
|
||||
cursor::KnownCursor,
|
||||
fixed::Fixed,
|
||||
ifs::{
|
||||
wl_output::WlOutputGlobal,
|
||||
wl_seat::{NodeSeatState, WlSeatGlobal},
|
||||
|
|
@ -36,6 +35,7 @@ pub struct OutputNode {
|
|||
pub render_data: RefCell<OutputRenderData>,
|
||||
pub state: Rc<State>,
|
||||
pub is_dummy: bool,
|
||||
pub status: CloneCell<Rc<String>>,
|
||||
}
|
||||
|
||||
impl OutputNode {
|
||||
|
|
@ -43,6 +43,7 @@ impl OutputNode {
|
|||
let mut rd = self.render_data.borrow_mut();
|
||||
rd.titles.clear();
|
||||
rd.inactive_workspaces.clear();
|
||||
rd.status = None;
|
||||
let mut pos = 0;
|
||||
let font = self.state.theme.font.borrow_mut();
|
||||
let th = self.state.theme.title_height.get();
|
||||
|
|
@ -54,13 +55,14 @@ impl OutputNode {
|
|||
if th == 0 || ws.name.is_empty() {
|
||||
break 'create_texture;
|
||||
}
|
||||
let title = match text::render_fitting(&ctx, th, &font, &ws.name, Color::GREY) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
log::error!("Could not render title {}: {}", ws.name, ErrorFmt(e));
|
||||
break 'create_texture;
|
||||
}
|
||||
};
|
||||
let title =
|
||||
match text::render_fitting(&ctx, th, &font, &ws.name, Color::GREY, false) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
log::error!("Could not render title {}: {}", ws.name, ErrorFmt(e));
|
||||
break 'create_texture;
|
||||
}
|
||||
};
|
||||
let mut x = pos + 1;
|
||||
if title.width() + 2 > title_width {
|
||||
title_width = title.width() + 2;
|
||||
|
|
@ -82,6 +84,29 @@ impl OutputNode {
|
|||
}
|
||||
pos += title_width;
|
||||
}
|
||||
'set_status: {
|
||||
let ctx = match self.state.render_ctx.get() {
|
||||
Some(ctx) => ctx,
|
||||
_ => break 'set_status,
|
||||
};
|
||||
let status = self.status.get();
|
||||
if status.is_empty() {
|
||||
break 'set_status;
|
||||
}
|
||||
let title = match text::render_fitting(&ctx, th, &font, &status, Color::GREY, true) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
log::error!("Could not render status {}: {}", status, ErrorFmt(e));
|
||||
break 'set_status;
|
||||
}
|
||||
};
|
||||
let pos = self.global.pos.get().width() - title.width() - 1;
|
||||
rd.status = Some(OutputTitle {
|
||||
x: pos,
|
||||
y: 0,
|
||||
tex: title,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ensure_workspace(self: &Rc<Self>) -> Rc<WorkspaceNode> {
|
||||
|
|
@ -106,7 +131,7 @@ impl OutputNode {
|
|||
seat_state: Default::default(),
|
||||
name: name.clone(),
|
||||
output_link: Default::default(),
|
||||
visible: Cell::new(false),
|
||||
visible: Cell::new(true),
|
||||
});
|
||||
self.state.workspaces.set(name, workspace.clone());
|
||||
workspace
|
||||
|
|
@ -122,9 +147,9 @@ impl OutputNode {
|
|||
if old.id == ws.id {
|
||||
return;
|
||||
}
|
||||
old.visible.set(false);
|
||||
old.set_visible(false);
|
||||
}
|
||||
ws.visible.set(true);
|
||||
ws.set_visible(true);
|
||||
ws.clone().change_extents(&self.workspace_rect());
|
||||
}
|
||||
|
||||
|
|
@ -161,6 +186,7 @@ impl OutputNode {
|
|||
|
||||
fn change_extents_(&self, rect: &Rect) {
|
||||
self.global.pos.set(*rect);
|
||||
self.update_render_data();
|
||||
if let Some(c) = self.workspace.get() {
|
||||
c.change_extents(&self.workspace_rect());
|
||||
}
|
||||
|
|
@ -194,6 +220,11 @@ impl OutputNode {
|
|||
}
|
||||
FindTreeResult::Other
|
||||
}
|
||||
|
||||
pub fn set_status(&self, status: &Rc<String>) {
|
||||
self.status.set(status.clone());
|
||||
self.update_render_data();
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OutputTitle {
|
||||
|
|
@ -207,6 +238,7 @@ pub struct OutputRenderData {
|
|||
pub active_workspace: Rect,
|
||||
pub inactive_workspaces: Vec<Rect>,
|
||||
pub titles: Vec<OutputTitle>,
|
||||
pub status: Option<OutputTitle>,
|
||||
}
|
||||
|
||||
impl Debug for OutputNode {
|
||||
|
|
@ -283,10 +315,6 @@ impl Node for OutputNode {
|
|||
unimplemented!();
|
||||
}
|
||||
|
||||
fn pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_output(&self)
|
||||
}
|
||||
|
||||
fn pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ impl WorkspaceNode {
|
|||
let pos = self.position.get();
|
||||
container.clone().change_extents(&pos);
|
||||
container.clone().set_workspace(self);
|
||||
container.set_visible(self.visible.get());
|
||||
self.container.set(Some(container.clone()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue