1
0
Fork 0
forked from wry/wry

autocommit 2022-04-02 00:31:30 CEST

This commit is contained in:
Julian Orth 2022-04-02 00:31:30 +02:00
parent 2dd433aa04
commit 6ad6d83b7e
34 changed files with 446 additions and 161 deletions

View file

@ -192,8 +192,14 @@ impl WlSeatGlobal {
}
pub fn last_tiled_keyboard_toplevel(&self, new: &dyn Node) -> Option<Rc<dyn ToplevelNode>> {
let output = self.output.get();
let workspace = output.workspace.get().unwrap();
let is_container = new.is_container();
for tl in self.toplevel_focus_history.rev_iter() {
match tl.as_node().get_workspace() {
Some(ws) if ws.id == workspace.id => { },
_ => continue,
};
let parent_is_float = match tl.parent() {
Some(pn) => pn.is_float(),
_ => false,

View file

@ -1,5 +1,6 @@
use std::ops::Deref;
use crate::ifs::wl_seat::WlSeatGlobal;
use crate::tree::Node;
use crate::tree::{Node, OutputNode};
use crate::utils::clonecell::CloneCell;
use std::rc::Rc;
@ -29,6 +30,10 @@ impl KbOwnerHolder {
pub fn set_kb_node(&self, seat: &Rc<WlSeatGlobal>, node: Rc<dyn Node>) {
self.owner.get().set_kb_node(seat, node);
}
pub fn workspace_changed(&self, seat: &Rc<WlSeatGlobal>, output: &Rc<OutputNode>) {
self.owner.get().workspace_changed(seat, output);
}
}
struct DefaultKbOwner;
@ -39,6 +44,7 @@ trait KbOwner {
fn grab(&self, seat: &Rc<WlSeatGlobal>, node: Rc<dyn Node>) -> bool;
fn ungrab(&self, seat: &Rc<WlSeatGlobal>);
fn set_kb_node(&self, seat: &Rc<WlSeatGlobal>, node: Rc<dyn Node>);
fn workspace_changed(&self, seat: &Rc<WlSeatGlobal>, output: &Rc<OutputNode>);
}
impl KbOwner for DefaultKbOwner {
@ -68,6 +74,31 @@ impl KbOwner for DefaultKbOwner {
node.clone().focus(seat);
seat.keyboard_node.set(node.clone());
}
fn workspace_changed(&self, seat: &Rc<WlSeatGlobal>, output: &Rc<OutputNode>) {
let new_ws = match output.workspace.get() {
Some(ws) => ws,
_ => return,
};
let node = seat.keyboard_node.get();
let ws = match node.get_workspace() {
None => return,
Some(ws) => ws,
};
let ws_output = ws.output.get();
if ws_output.id != output.id {
return;
}
for tl in seat.toplevel_focus_history.rev_iter() {
if let Some(tl_ws) = tl.as_node().get_workspace() {
if tl_ws.id == new_ws.id {
self.set_kb_node(seat, tl.deref().clone().into_node());
return;
}
}
}
self.set_kb_node(seat, seat.state.root.clone());
}
}
impl KbOwner for GrabKbOwner {
@ -82,4 +113,8 @@ impl KbOwner for GrabKbOwner {
fn set_kb_node(&self, _seat: &Rc<WlSeatGlobal>, _node: Rc<dyn Node>) {
// nothing
}
fn workspace_changed(&self, _seat: &Rc<WlSeatGlobal>, _output: &Rc<OutputNode>) {
// nothing
}
}