toplevel: remove focus_node
This commit is contained in:
parent
8c26e56b65
commit
f4e8d132f3
8 changed files with 19 additions and 46 deletions
|
|
@ -923,7 +923,7 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
pub fn focus_toplevel(self: &Rc<Self>, n: Rc<dyn ToplevelNode>) {
|
||||
let node = match n.tl_focus_child(self.id) {
|
||||
let node = match n.tl_focus_child() {
|
||||
Some(n) => n,
|
||||
_ => n.tl_into_node(),
|
||||
};
|
||||
|
|
@ -1153,7 +1153,7 @@ impl WlSeatGlobal {
|
|||
});
|
||||
self.surface_pointer_frame(surface);
|
||||
if pressed {
|
||||
if let Some(node) = surface.get_focus_node(self.id) {
|
||||
if let Some(node) = surface.get_focus_node() {
|
||||
self.focus_node_with_serial(node, serial);
|
||||
}
|
||||
}
|
||||
|
|
@ -1372,7 +1372,7 @@ impl WlSeatGlobal {
|
|||
self.surface_touch_event(Version::ALL, surface, |t| {
|
||||
t.send_down(serial, time, surface.id, id, x, y)
|
||||
});
|
||||
if let Some(node) = surface.get_focus_node(self.id) {
|
||||
if let Some(node) = surface.get_focus_node() {
|
||||
self.focus_node_with_serial(node, serial);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ impl TabletTool {
|
|||
});
|
||||
if state == ToolButtonState::Pressed {
|
||||
n.client.focus_stealing_serial.set(Some(serial.get()));
|
||||
if let Some(node) = n.get_focus_node(self.tablet.seat.id) {
|
||||
if let Some(node) = n.get_focus_node() {
|
||||
self.tablet.seat.focus_node_with_serial(node, serial.get());
|
||||
}
|
||||
}
|
||||
|
|
@ -261,7 +261,7 @@ impl TabletTool {
|
|||
if let Some(changes) = changes {
|
||||
if changes.down == Some(true) {
|
||||
n.client.focus_stealing_serial.set(Some(serial.get()));
|
||||
if let Some(node) = n.get_focus_node(self.tablet.seat.id) {
|
||||
if let Some(node) = n.get_focus_node() {
|
||||
self.tablet.seat.focus_node_with_serial(node, serial.get());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -777,9 +777,9 @@ impl WlSurface {
|
|||
Ok(cursor)
|
||||
}
|
||||
|
||||
pub fn get_focus_node(&self, seat: SeatId) -> Option<Rc<dyn Node>> {
|
||||
pub fn get_focus_node(&self) -> Option<Rc<dyn Node>> {
|
||||
match self.toplevel.get() {
|
||||
Some(tl) if tl.tl_accepts_keyboard_focus() => tl.tl_focus_child(seat),
|
||||
Some(tl) if tl.tl_accepts_keyboard_focus() => tl.tl_focus_child(),
|
||||
Some(_) => None,
|
||||
_ => self.ext.get().focus_node(),
|
||||
}
|
||||
|
|
@ -1591,18 +1591,6 @@ impl WlSurface {
|
|||
ss.surface.detach_node(set_invisible);
|
||||
}
|
||||
}
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
let data = tl.tl_data();
|
||||
let mut remove = vec![];
|
||||
for (seat, s) in data.focus_node.iter() {
|
||||
if s.node_id() == self.node_id() {
|
||||
remove.push(seat);
|
||||
}
|
||||
}
|
||||
for seat in remove {
|
||||
data.focus_node.remove(&seat);
|
||||
}
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
if self.visible.get() && self.toplevel.is_none() {
|
||||
self.client.state.damage(self.buffer_abs_pos.get());
|
||||
|
|
@ -1802,7 +1790,6 @@ impl Node for WlSurface {
|
|||
|
||||
fn node_on_focus(self: Rc<Self>, seat: &WlSeatGlobal) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
tl.tl_data().focus_node.insert(seat.id(), self.clone());
|
||||
tl.tl_on_activate();
|
||||
}
|
||||
seat.focus_surface(&self);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
tree::Node,
|
||||
utils::{
|
||||
clonecell::CloneCell,
|
||||
linkedlist::{LinkedNode, NodeRef},
|
||||
|
|
@ -375,6 +376,10 @@ impl SurfaceExt for WlSubsurface {
|
|||
Some(self)
|
||||
}
|
||||
|
||||
fn focus_node(&self) -> Option<Rc<dyn Node>> {
|
||||
self.parent.ext.get().focus_node()
|
||||
}
|
||||
|
||||
fn consume_pending_child(
|
||||
&self,
|
||||
surface: &WlSurface,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use {
|
|||
cursor::KnownCursor,
|
||||
fixed::Fixed,
|
||||
ifs::{
|
||||
wl_seat::{tablet::TabletTool, NodeSeatState, SeatId, WlSeatGlobal},
|
||||
wl_seat::{tablet::TabletTool, NodeSeatState, WlSeatGlobal},
|
||||
wl_surface::{x_surface::XSurface, WlSurface, WlSurfaceError},
|
||||
},
|
||||
rect::Rect,
|
||||
|
|
@ -406,7 +406,7 @@ impl ToplevelNodeBase for Xwindow {
|
|||
.push(XWaylandEvent::Activate(self.data.clone()));
|
||||
}
|
||||
|
||||
fn tl_focus_child(&self, _seat: SeatId) -> Option<Rc<dyn Node>> {
|
||||
fn tl_focus_child(&self) -> Option<Rc<dyn Node>> {
|
||||
Some(self.x.surface.clone())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use {
|
|||
fixed::Fixed,
|
||||
ifs::{
|
||||
ext_foreign_toplevel_list_v1::ExtForeignToplevelListV1,
|
||||
wl_seat::{tablet::TabletTool, NodeSeatState, SeatId, WlSeatGlobal},
|
||||
wl_seat::{tablet::TabletTool, NodeSeatState, WlSeatGlobal},
|
||||
wl_surface::{
|
||||
xdg_surface::{
|
||||
xdg_toplevel::xdg_dialog_v1::XdgDialogV1, XdgSurface, XdgSurfaceError,
|
||||
|
|
@ -582,7 +582,7 @@ impl ToplevelNodeBase for XdgToplevel {
|
|||
}
|
||||
}
|
||||
|
||||
fn tl_focus_child(&self, _seat: SeatId) -> Option<Rc<dyn Node>> {
|
||||
fn tl_focus_child(&self) -> Option<Rc<dyn Node>> {
|
||||
Some(self.xdg.surface.clone())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2059,14 +2059,6 @@ impl ToplevelNodeBase for ContainerNode {
|
|||
&self.toplevel_data
|
||||
}
|
||||
|
||||
fn tl_default_focus_child(&self) -> Option<Rc<dyn Node>> {
|
||||
self.focus_history
|
||||
.last()
|
||||
.map(|v| v.node.clone())
|
||||
.or_else(|| self.children.first().map(|c| c.node.clone()))
|
||||
.map(|tl| tl.tl_into_node())
|
||||
}
|
||||
|
||||
fn tl_set_workspace_ext(&self, ws: &Rc<WorkspaceNode>) {
|
||||
for child in self.children.iter() {
|
||||
child.node.clone().tl_set_workspace(ws);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use {
|
|||
ext_image_copy::ext_image_copy_capture_session_v1::ExtImageCopyCaptureSessionV1,
|
||||
jay_screencast::JayScreencast,
|
||||
jay_toplevel::JayToplevel,
|
||||
wl_seat::{collect_kb_foci, collect_kb_foci2, NodeSeatState, SeatId},
|
||||
wl_seat::{collect_kb_foci, collect_kb_foci2, NodeSeatState},
|
||||
wl_surface::WlSurface,
|
||||
},
|
||||
rect::Rect,
|
||||
|
|
@ -22,7 +22,6 @@ use {
|
|||
copyhashmap::CopyHashMap,
|
||||
hash_map_ext::HashMapExt,
|
||||
numcell::NumCell,
|
||||
smallmap::SmallMap,
|
||||
threshold_counter::ThresholdCounter,
|
||||
toplevel_identifier::{toplevel_identifier, ToplevelIdentifier},
|
||||
},
|
||||
|
|
@ -172,10 +171,6 @@ impl<T: ToplevelNodeBase> ToplevelNode for T {
|
|||
pub trait ToplevelNodeBase: Node {
|
||||
fn tl_data(&self) -> &ToplevelData;
|
||||
|
||||
fn tl_default_focus_child(&self) -> Option<Rc<dyn Node>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn tl_accepts_keyboard_focus(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
|
@ -188,11 +183,8 @@ pub trait ToplevelNodeBase: Node {
|
|||
// nothing
|
||||
}
|
||||
|
||||
fn tl_focus_child(&self, seat: SeatId) -> Option<Rc<dyn Node>> {
|
||||
self.tl_data()
|
||||
.focus_node
|
||||
.get(&seat)
|
||||
.or_else(|| self.tl_default_focus_child())
|
||||
fn tl_focus_child(&self) -> Option<Rc<dyn Node>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn tl_set_workspace_ext(&self, ws: &Rc<WorkspaceNode>) {
|
||||
|
|
@ -259,7 +251,6 @@ pub struct ToplevelData {
|
|||
pub client: Option<Rc<Client>>,
|
||||
pub state: Rc<State>,
|
||||
pub active_surfaces: ThresholdCounter,
|
||||
pub focus_node: SmallMap<SeatId, Rc<dyn Node>, 1>,
|
||||
pub visible: Cell<bool>,
|
||||
pub is_floating: Cell<bool>,
|
||||
pub float_width: Cell<i32>,
|
||||
|
|
@ -300,7 +291,6 @@ impl ToplevelData {
|
|||
client,
|
||||
state: state.clone(),
|
||||
active_surfaces: Default::default(),
|
||||
focus_node: Default::default(),
|
||||
visible: Cell::new(false),
|
||||
is_floating: Default::default(),
|
||||
float_width: Default::default(),
|
||||
|
|
@ -393,7 +383,6 @@ impl ToplevelData {
|
|||
}
|
||||
self.workspace.take();
|
||||
self.seat_state.destroy_node(node);
|
||||
self.focus_node.clear();
|
||||
}
|
||||
|
||||
pub fn broadcast(&self, toplevel: Rc<dyn ToplevelNode>) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue