From 1cbc7a64458606d010edacca70bc19c761cbc774 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Mon, 21 Feb 2022 16:23:44 +0100 Subject: [PATCH] autocommit 2022-02-21 16:23:44 CET --- src/ifs/wl_seat/pointer_owner.rs | 12 +-- src/ifs/wl_surface.rs | 4 +- src/ifs/wl_surface/xdg_surface/xdg_popup.rs | 4 +- .../wl_surface/xdg_surface/xdg_toplevel.rs | 4 +- src/tree/container.rs | 10 +- src/tree/float.rs | 96 +++++++++---------- src/tree/mod.rs | 12 +-- src/tree/workspace.rs | 2 +- 8 files changed, 70 insertions(+), 74 deletions(-) diff --git a/src/ifs/wl_seat/pointer_owner.rs b/src/ifs/wl_seat/pointer_owner.rs index 32869c58..6e2d62a6 100644 --- a/src/ifs/wl_seat/pointer_owner.rs +++ b/src/ifs/wl_seat/pointer_owner.rs @@ -149,11 +149,11 @@ impl PointerOwner for DefaultPointerOwner { if let Some(node) = found_tree.last() { node.node .clone() - .motion(seat, x.apply_fract(node.x), y.apply_fract(node.y)); + .pointer_motion(seat, x.apply_fract(node.x), y.apply_fract(node.y)); } } else { if let Some(last) = stack.last() { - last.pointer_untarget(seat); + last.pointer_unfocus(seat); } for old in stack.drain(divergence..).rev() { old.leave(seat); @@ -163,19 +163,19 @@ impl PointerOwner for DefaultPointerOwner { if let Some(node) = found_tree.last() { node.node .clone() - .motion(seat, x.apply_fract(node.x), y.apply_fract(node.y)); + .pointer_motion(seat, x.apply_fract(node.x), y.apply_fract(node.y)); } } else { for new in found_tree.drain(divergence..) { new.node.seat_state().enter(seat); new.node .clone() - .enter(seat, x.apply_fract(new.x), y.apply_fract(new.y)); + .pointer_enter(seat, x.apply_fract(new.x), y.apply_fract(new.y)); stack.push(new.node); } } if let Some(node) = stack.last() { - node.pointer_target(seat); + node.pointer_focus(seat); } } found_tree.clear(); @@ -245,7 +245,7 @@ impl PointerOwner for GrabPointerOwner { let (x_int, y_int) = pos.translate(x.round_down(), y.round_down()); self.node .clone() - .motion(seat, x.apply_fract(x_int), y.apply_fract(y_int)); + .pointer_motion(seat, x.apply_fract(x_int), y.apply_fract(y_int)); } fn start_drag( diff --git a/src/ifs/wl_surface.rs b/src/ifs/wl_surface.rs index 599b284c..e094dca4 100644 --- a/src/ifs/wl_surface.rs +++ b/src/ifs/wl_surface.rs @@ -705,11 +705,11 @@ impl Node for WlSurface { seat.leave_surface(self); } - fn enter(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { + fn pointer_enter(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { seat.enter_surface(&self, x, y) } - fn motion(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { + fn pointer_motion(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { seat.motion_surface(&*self, x, y) } diff --git a/src/ifs/wl_surface/xdg_surface/xdg_popup.rs b/src/ifs/wl_surface/xdg_surface/xdg_popup.rs index 2476b6a3..ae880887 100644 --- a/src/ifs/wl_surface/xdg_surface/xdg_popup.rs +++ b/src/ifs/wl_surface/xdg_surface/xdg_popup.rs @@ -293,11 +293,11 @@ impl Node for XdgPopup { self.xdg.find_tree_at(x, y, tree) } - fn enter(self: Rc, seat: &Rc, _x: Fixed, _y: Fixed) { + fn pointer_enter(self: Rc, seat: &Rc, _x: Fixed, _y: Fixed) { seat.enter_popup(&self); } - fn pointer_target(&self, seat: &Rc) { + fn pointer_focus(&self, seat: &Rc) { seat.set_known_cursor(KnownCursor::Default); } diff --git a/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs b/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs index 6e417d1f..a9c954f5 100644 --- a/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs +++ b/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs @@ -439,11 +439,11 @@ impl Node for XdgToplevel { self.xdg.find_tree_at(x, y, tree) } - fn enter(self: Rc, seat: &Rc, _x: Fixed, _y: Fixed) { + fn pointer_enter(self: Rc, seat: &Rc, _x: Fixed, _y: Fixed) { seat.enter_toplevel(&self); } - fn pointer_target(&self, seat: &Rc) { + fn pointer_focus(&self, seat: &Rc) { seat.set_known_cursor(KnownCursor::Default); } diff --git a/src/tree/container.rs b/src/tree/container.rs index ba745710..143f68b9 100644 --- a/src/tree/container.rs +++ b/src/tree/container.rs @@ -345,7 +345,7 @@ impl ContainerNode { } _ => { let height = body.height() + add; - (0, pos, other_content_size, height, height) + (0, pos + title_height + 1, other_content_size, height, height) } }; body = Rect::new_sized(x1, y1, width, height).unwrap(); @@ -959,18 +959,18 @@ impl Node for ContainerNode { node.active.set(active); } - fn enter(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { + fn pointer_enter(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { self.pointer_move(seat, x.round_down(), y.round_down()); } - fn pointer_untarget(&self, seat: &Rc) { + fn pointer_unfocus(&self, seat: &Rc) { let mut seats = self.seats.borrow_mut(); if let Some(seat_state) = seats.get_mut(&seat.id()) { seat_state.target = false; } } - fn pointer_target(&self, seat: &Rc) { + fn pointer_focus(&self, seat: &Rc) { let mut seats = self.seats.borrow_mut(); if let Some(seat_state) = seats.get_mut(&seat.id()) { seat_state.target = true; @@ -978,7 +978,7 @@ impl Node for ContainerNode { } } - fn motion(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { + fn pointer_motion(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { self.pointer_move(seat, x.round_down(), y.round_down()); } diff --git a/src/tree/float.rs b/src/tree/float.rs index 933b4828..b56bd449 100644 --- a/src/tree/float.rs +++ b/src/tree/float.rs @@ -1,24 +1,20 @@ +use crate::backend::KeyState; use crate::cursor::KnownCursor; -use crate::ifs::wl_seat::{BTN_LEFT, Dnd, NodeSeatState, SeatId, WlSeatGlobal}; +use crate::fixed::Fixed; +use crate::ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal, BTN_LEFT}; use crate::rect::Rect; use crate::render::{Renderer, Texture}; use crate::theme::Color; use crate::tree::walker::NodeVisitor; -use crate::tree::{ContainerNode, ContainerSplit, FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode}; -use crate::utils::linkedlist::{LinkedNode}; +use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode}; +use crate::utils::linkedlist::LinkedNode; use crate::{text, CloneCell, ErrorFmt, State}; +use ahash::AHashMap; use std::cell::{Cell, RefCell}; use std::fmt::{Debug, Formatter}; use std::mem; use std::ops::Deref; use std::rc::Rc; -use ahash::AHashMap; -use i4config::Direction; -use crate::backend::{KeyState, ScrollAxis}; -use crate::client::{Client, ClientId}; -use crate::fixed::Fixed; -use crate::ifs::wl_surface::WlSurface; -use crate::xkbcommon::ModifierState; tree_id!(FloatNodeId); pub struct FloatNode { @@ -174,7 +170,8 @@ impl FloatNode { Some(c) => c, _ => return, }; - let texture = match text::render(&ctx, pos.width() - 2 * bw, th, &font, &title, Color::GREY) { + let texture = match text::render(&ctx, pos.width() - 2 * bw, th, &font, &title, Color::GREY) + { Ok(t) => t, Err(e) => { log::error!("Could not render title {}: {}", title, ErrorFmt(e)); @@ -197,7 +194,7 @@ impl FloatNode { op_type: OpType::Move, op_active: false, dist_hor: 0, - dist_ver: 0 + dist_ver: 0, }); seat_state.x = x; seat_state.y = y; @@ -307,7 +304,6 @@ impl FloatNode { } } } - } impl Debug for FloatNode { @@ -344,6 +340,19 @@ 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() + } + fn button(self: Rc, seat: &Rc, button: u32, state: KeyState) { if button != BTN_LEFT { return; @@ -363,7 +372,7 @@ impl Node for FloatNode { OpType::Move => { seat_data.dist_hor = seat_data.x; seat_data.dist_ver = seat_data.y; - }, + } OpType::ResizeLeft => seat_data.dist_hor = seat_data.x, OpType::ResizeTop => seat_data.dist_ver = seat_data.y, OpType::ResizeRight => seat_data.dist_hor = pos.width() - seat_data.x, @@ -390,19 +399,6 @@ 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() - } - fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec) -> FindTreeResult { let theme = &self.state.theme; let th = theme.title_height.get(); @@ -428,29 +424,6 @@ impl Node for FloatNode { child.find_tree_at(x, y, tree) } - fn enter(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { - self.pointer_move(seat, x.round_down(), y.round_down()); - } - - fn pointer_untarget(&self, seat: &Rc) { - let mut seats = self.seats.borrow_mut(); - if let Some(seat_state) = seats.get_mut(&seat.id()) { - seat_state.target = false; - } - } - - fn pointer_target(&self, seat: &Rc) { - let mut seats = self.seats.borrow_mut(); - if let Some(seat_state) = seats.get_mut(&seat.id()) { - seat_state.target = true; - seat.set_known_cursor(seat_state.cursor); - } - } - - fn motion(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { - self.pointer_move(seat, x.round_down(), y.round_down()); - } - fn replace_child(self: Rc, _old: &dyn Node, new: Rc) { self.child.set(Some(new.clone())); new.clone().set_parent(self.clone()); @@ -468,6 +441,29 @@ impl Node for FloatNode { self.active.set(active); } + fn pointer_enter(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { + self.pointer_move(seat, x.round_down(), y.round_down()); + } + + fn pointer_unfocus(&self, seat: &Rc) { + let mut seats = self.seats.borrow_mut(); + if let Some(seat_state) = seats.get_mut(&seat.id()) { + seat_state.target = false; + } + } + + fn pointer_focus(&self, seat: &Rc) { + let mut seats = self.seats.borrow_mut(); + if let Some(seat_state) = seats.get_mut(&seat.id()) { + seat_state.target = true; + seat.set_known_cursor(seat_state.cursor); + } + } + + fn pointer_motion(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { + self.pointer_move(seat, x.round_down(), y.round_down()); + } + fn render(&self, renderer: &mut Renderer, x: i32, y: i32) { renderer.render_floating(self, x, y) } diff --git a/src/tree/mod.rs b/src/tree/mod.rs index 518f8b95..f5df15f5 100644 --- a/src/tree/mod.rs +++ b/src/tree/mod.rs @@ -216,21 +216,21 @@ pub trait Node { let _ = seat; } - fn enter(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { + fn pointer_enter(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { let _ = seat; let _ = x; let _ = y; } - fn pointer_untarget(&self, seat: &Rc) { + fn pointer_unfocus(&self, seat: &Rc) { let _ = seat; } - fn pointer_target(&self, seat: &Rc) { + fn pointer_focus(&self, seat: &Rc) { let _ = seat; } - fn motion(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { + fn pointer_motion(self: Rc, seat: &Rc, x: Fixed, y: Fixed) { let _ = seat; let _ = x; let _ = y; @@ -418,7 +418,7 @@ impl Node for DisplayNode { FindTreeResult::AcceptsInput } - fn pointer_target(&self, seat: &Rc) { + fn pointer_focus(&self, seat: &Rc) { seat.set_known_cursor(KnownCursor::Default); } } @@ -491,7 +491,7 @@ impl Node for OutputNode { self.workspace.set(None); } - fn pointer_target(&self, seat: &Rc) { + fn pointer_focus(&self, seat: &Rc) { seat.set_known_cursor(KnownCursor::Default); } diff --git a/src/tree/workspace.rs b/src/tree/workspace.rs index 8fbe7253..639f430d 100644 --- a/src/tree/workspace.rs +++ b/src/tree/workspace.rs @@ -82,7 +82,7 @@ impl Node for WorkspaceNode { self.container.set(None); } - fn pointer_target(&self, seat: &Rc) { + fn pointer_focus(&self, seat: &Rc) { seat.set_known_cursor(KnownCursor::Default); }