From a8505be462d336d4068a312eaa7892389b50a1f3 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Sun, 20 Feb 2022 22:21:41 +0100 Subject: [PATCH] autocommit 2022-02-20 22:21:41 CET --- src/config/handler.rs | 2 +- src/main.rs | 7 ++-- src/render/renderer/renderer.rs | 25 ++++++++------ src/theme.rs | 7 +--- src/tree/float.rs | 60 ++++++++++++++++----------------- src/tree/mod.rs | 6 ++-- 6 files changed, 54 insertions(+), 53 deletions(-) diff --git a/src/config/handler.rs b/src/config/handler.rs index 228e593d..8a2ac7ea 100644 --- a/src/config/handler.rs +++ b/src/config/handler.rs @@ -1,7 +1,7 @@ use crate::backend::{KeyboardId, MouseId}; use crate::ifs::wl_seat::{SeatId, WlSeatGlobal}; use crate::state::DeviceHandlerData; -use crate::tree::walker::{NodeVisitorBase}; +use crate::tree::walker::NodeVisitorBase; use crate::tree::{ContainerNode, ContainerSplit, FloatNode, Node}; use crate::utils::copyhashmap::CopyHashMap; use crate::utils::debug_fn::debug_fn; diff --git a/src/main.rs b/src/main.rs index 9508e19e..e5e1d222 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,9 @@ use crate::ifs::zxdg_decoration_manager_v1::ZxdgDecorationManagerV1Global; use crate::render::RenderError; use crate::sighand::SighandError; use crate::state::State; -use crate::tree::{container_layout, container_titles, DisplayNode, float_layout, float_titles, NodeIds}; +use crate::tree::{ + container_layout, container_titles, float_layout, float_titles, DisplayNode, NodeIds, +}; use crate::utils::clonecell::CloneCell; use crate::utils::errorfmt::ErrorFmt; use crate::utils::numcell::NumCell; @@ -169,7 +171,8 @@ fn main_() -> Result<(), MainError> { let _global_event_handler = engine.spawn(tasks::handle_backend_events(state.clone())); let _slow_client_handler = engine.spawn(tasks::handle_slow_clients(state.clone())); let _container_do_layout = engine.spawn2(Phase::Layout, container_layout(state.clone())); - let _container_render_titles = engine.spawn2(Phase::PostLayout, container_titles(state.clone())); + let _container_render_titles = + engine.spawn2(Phase::PostLayout, container_titles(state.clone())); let _float_do_layout = engine.spawn2(Phase::Layout, float_layout(state.clone())); let _float_render_titles = engine.spawn2(Phase::PostLayout, float_titles(state.clone())); let socket_path = Acceptor::install(&state)?; diff --git a/src/render/renderer/renderer.rs b/src/render/renderer/renderer.rs index d6d35e0c..7e3c0390 100644 --- a/src/render/renderer/renderer.rs +++ b/src/render/renderer/renderer.rs @@ -13,6 +13,7 @@ use crate::render::gl::sys::{ use crate::render::renderer::context::RenderContext; use crate::render::sys::{glDisable, glEnable, GL_BLEND}; use crate::render::Texture; +use crate::theme::Color; use crate::tree::{ ContainerFocus, ContainerNode, ContainerSplit, FloatNode, OutputNode, WorkspaceNode, }; @@ -20,7 +21,6 @@ use crate::State; use std::ops::Deref; use std::rc::Rc; use std::slice; -use crate::theme::Color; const NON_COLOR: Color = Color::from_rgbaf(0.2, 0.2, 0.2, 1.0); const CHILD_COLOR: Color = Color::from_rgbaf(0.8, 0.8, 0.8, 1.0); @@ -366,23 +366,26 @@ impl Renderer<'_> { let uc = theme.underline_color.get(); let borders = [ Rect::new_sized(x, y, pos.width(), bw).unwrap(), - Rect::new_sized(x, y, bw, pos.height()).unwrap(), - Rect::new_sized(x + pos.width() - bw, y, bw, pos.height()).unwrap(), - Rect::new_sized(x, y + pos.height() - bw, pos.width(), bw).unwrap(), + Rect::new_sized(x, y + bw, bw, pos.height() - bw).unwrap(), + Rect::new_sized(x + pos.width() - bw, y + bw, bw, pos.height() - bw).unwrap(), + Rect::new_sized(x + bw, y + pos.height() - bw, pos.width() - 2 * bw, bw).unwrap(), ]; self.fill_boxes(&borders, &bc); - let title = [ - Rect::new_sized(x + bw, y + bw, pos.width() - 2 * bw, th).unwrap(), - ]; + let title = [Rect::new_sized(x + bw, y + bw, pos.width() - 2 * bw, th).unwrap()]; self.fill_boxes(&title, &tc); - let title_underline = [ - Rect::new_sized(x + bw, y + bw + th, pos.width() - 2 * bw, 1).unwrap(), - ]; + let title_underline = + [Rect::new_sized(x + bw, y + bw + th, pos.width() - 2 * bw, 1).unwrap()]; self.fill_boxes(&title_underline, &uc); if let Some(title) = floating.title_texture.get() { self.render_texture(&title, x + bw, y + bw, ARGB8888); } - let body = Rect::new_sized(x + bw, y + bw + th + 1, pos.width() - 2 * bw, pos.height() - 2 * bw - th - 1).unwrap(); + let body = Rect::new_sized( + x + bw, + y + bw + th + 1, + pos.width() - 2 * bw, + pos.height() - 2 * bw - th - 1, + ) + .unwrap(); unsafe { with_scissor(&body, || { child.render(self, body.x1(), body.y1()); diff --git a/src/theme.rs b/src/theme.rs index d51ecc16..37d5c313 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -32,12 +32,7 @@ impl Color { } pub const fn from_rgbaf(r: f32, g: f32, b: f32, a: f32) -> Self { - Self { - r, - g, - b, - a, - } + Self { r, g, b, a } } } diff --git a/src/tree/float.rs b/src/tree/float.rs index f2477a3a..4cf27e6c 100644 --- a/src/tree/float.rs +++ b/src/tree/float.rs @@ -1,22 +1,16 @@ +use crate::cursor::KnownCursor; +use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal}; +use crate::rect::Rect; +use crate::render::{Renderer, Texture}; +use crate::theme::Color; +use crate::tree::walker::NodeVisitor; +use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode}; +use crate::utils::linkedlist::LinkedNode; +use crate::{text, CloneCell, ErrorFmt, State}; use std::cell::{Cell, RefCell}; use std::fmt::{Debug, Formatter}; use std::ops::Deref; use std::rc::Rc; -use i4config::Direction; -use crate::{CloneCell, ErrorFmt, State, text}; -use crate::backend::{KeyState, ScrollAxis}; -use crate::client::{Client, ClientId}; -use crate::cursor::KnownCursor; -use crate::fixed::Fixed; -use crate::ifs::wl_seat::{Dnd, NodeSeatState, WlSeatGlobal}; -use crate::ifs::wl_surface::WlSurface; -use crate::rect::Rect; -use crate::render::{Renderer, Texture}; -use crate::theme::Color; -use crate::tree::{ContainerNode, ContainerSplit, FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode}; -use crate::tree::walker::NodeVisitor; -use crate::utils::linkedlist::LinkedNode; -use crate::xkbcommon::ModifierState; tree_id!(FloatNodeId); pub struct FloatNode { @@ -55,7 +49,12 @@ pub async fn float_titles(state: Rc) { } impl FloatNode { - pub fn new(state: &Rc, ws: &Rc, position: Rect, child: Rc) -> Rc { + pub fn new( + state: &Rc, + ws: &Rc, + position: Rect, + child: Rc, + ) -> Rc { let floater = Rc::new(FloatNode { id: state.node_ids.next(), state: state.clone(), @@ -112,7 +111,8 @@ impl FloatNode { pos.y1() + bw + th + 1, (pos.width() - 2 * bw).max(0), (pos.height() - 2 * bw - th - 1).max(0), - ).unwrap(); + ) + .unwrap(); child.clone().change_extents(&cpos); self.layout_scheduled.set(false); self.schedule_render_titles(); @@ -181,6 +181,15 @@ impl Node for FloatNode { } } + fn child_title_changed(self: Rc, _child: &dyn Node, title: &str) { + let mut t = self.title.borrow_mut(); + if t.deref() != title { + t.clear(); + t.push_str(title); + self.schedule_render_titles(); + } + } + fn absolute_position(&self) -> Rect { self.position.get() } @@ -216,6 +225,10 @@ impl Node for FloatNode { self.workspace_link.set(None); } + fn child_active_changed(&self, _child: &dyn Node, active: bool) { + self.active.set(active); + } + fn pointer_target(&self, seat: &Rc) { seat.set_known_cursor(KnownCursor::Default); } @@ -244,17 +257,4 @@ impl Node for FloatNode { .set(Some(ws.stacked.add_last(self.clone()))); self.workspace.set(ws.clone()); } - - fn child_active_changed(&self, _child: &dyn Node, active: bool) { - self.active.set(active); - } - - fn child_title_changed(self: Rc, child: &dyn Node, title: &str) { - let mut t = self.title.borrow_mut(); - if t.deref() != title { - t.clear(); - t.push_str(title); - self.schedule_render_titles(); - } - } } diff --git a/src/tree/mod.rs b/src/tree/mod.rs index 40dbd431..a7e2c8cd 100644 --- a/src/tree/mod.rs +++ b/src/tree/mod.rs @@ -10,22 +10,22 @@ use crate::render::Renderer; use crate::tree::walker::NodeVisitor; use crate::utils::clonecell::CloneCell; use crate::utils::copyhashmap::CopyHashMap; -use crate::utils::linkedlist::{LinkedList}; +use crate::utils::linkedlist::LinkedList; use crate::xkbcommon::ModifierState; use crate::NumCell; pub use container::*; +pub use float::*; use i4config::Direction; use std::cell::{Cell, RefCell}; use std::fmt::{Debug, Display, Formatter}; use std::ops::Deref; use std::rc::Rc; pub use workspace::*; -pub use float::*; mod container; +mod float; pub mod walker; mod workspace; -mod float; pub struct NodeIds { next: NumCell,