autocommit 2022-02-19 19:41:18 CET
This commit is contained in:
parent
bb0468feea
commit
ae66acef73
32 changed files with 880 additions and 164 deletions
|
|
@ -199,6 +199,10 @@ impl WlSeatGlobal {
|
|||
self.keyboard_node.get().create_split(axis)
|
||||
}
|
||||
|
||||
pub fn focus_parent(self: &Rc<Self>) {
|
||||
self.keyboard_node.get().focus_parent(self);
|
||||
}
|
||||
|
||||
pub fn get_rate(&self) -> (i32, i32) {
|
||||
self.repeat_rate.get()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,12 +212,12 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
fn focus_xdg_surface(self: &Rc<Self>, xdg: &Rc<XdgSurface>) {
|
||||
self.focus_surface(&xdg.focus_surface(self));
|
||||
self.focus_node(xdg.focus_surface(self));
|
||||
}
|
||||
|
||||
fn focus_surface(self: &Rc<Self>, surface: &Rc<WlSurface>) {
|
||||
pub fn focus_node(self: &Rc<Self>, node: Rc<dyn Node>) {
|
||||
let old = self.keyboard_node.get();
|
||||
if old.id() == surface.node_id {
|
||||
if old.id() == node.id() {
|
||||
return;
|
||||
}
|
||||
old.unfocus(self);
|
||||
|
|
@ -225,36 +225,11 @@ impl WlSeatGlobal {
|
|||
old.active_changed(false);
|
||||
}
|
||||
|
||||
if surface.seat_state().focus(self) {
|
||||
surface.active_changed(true);
|
||||
}
|
||||
surface.clone().focus(self);
|
||||
self.keyboard_node.set(surface.clone());
|
||||
|
||||
let pressed_keys: Vec<_> = self.pressed_keys.borrow().iter().copied().collect();
|
||||
let serial = self.serial.fetch_add(1);
|
||||
self.surface_kb_event(0, &surface, |k| {
|
||||
k.send_enter(serial, surface.id, &pressed_keys)
|
||||
});
|
||||
let ModifierState {
|
||||
mods_depressed,
|
||||
mods_latched,
|
||||
mods_locked,
|
||||
group,
|
||||
..
|
||||
} = self.kb_state.borrow().mods();
|
||||
let serial = self.serial.fetch_add(1);
|
||||
self.surface_kb_event(0, &surface, |k| {
|
||||
k.send_modifiers(serial, mods_depressed, mods_latched, mods_locked, group)
|
||||
});
|
||||
|
||||
if old.client_id() != Some(surface.client.id) {
|
||||
self.offer_selection::<WlDataDevice>(&self.selection, &surface.client);
|
||||
self.offer_selection::<ZwpPrimarySelectionDeviceV1>(
|
||||
&self.primary_selection,
|
||||
&surface.client,
|
||||
);
|
||||
if node.seat_state().focus(self) {
|
||||
node.active_changed(true);
|
||||
}
|
||||
node.clone().focus(self);
|
||||
self.keyboard_node.set(node.clone());
|
||||
}
|
||||
|
||||
fn offer_selection<T: ipc::Vtable>(
|
||||
|
|
@ -405,7 +380,7 @@ impl WlSeatGlobal {
|
|||
self.surface_pointer_event(0, surface, |p| p.send_button(serial, 0, button, state));
|
||||
self.surface_pointer_frame(surface);
|
||||
if pressed && surface.belongs_to_toplevel() {
|
||||
self.focus_surface(surface);
|
||||
self.focus_node(surface.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -463,6 +438,36 @@ impl WlSeatGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
// Focus callbacks
|
||||
impl WlSeatGlobal {
|
||||
pub fn focus_surface(&self, surface: &WlSurface) {
|
||||
let pressed_keys: Vec<_> = self.pressed_keys.borrow().iter().copied().collect();
|
||||
let serial = self.serial.fetch_add(1);
|
||||
self.surface_kb_event(0, &surface, |k| {
|
||||
k.send_enter(serial, surface.id, &pressed_keys)
|
||||
});
|
||||
let ModifierState {
|
||||
mods_depressed,
|
||||
mods_latched,
|
||||
mods_locked,
|
||||
group,
|
||||
..
|
||||
} = self.kb_state.borrow().mods();
|
||||
let serial = self.serial.fetch_add(1);
|
||||
self.surface_kb_event(0, &surface, |k| {
|
||||
k.send_modifiers(serial, mods_depressed, mods_latched, mods_locked, group)
|
||||
});
|
||||
|
||||
if self.keyboard_node.get().client_id() != Some(surface.client.id) {
|
||||
self.offer_selection::<WlDataDevice>(&self.selection, &surface.client);
|
||||
self.offer_selection::<ZwpPrimarySelectionDeviceV1>(
|
||||
&self.primary_selection,
|
||||
&surface.client,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Key callbacks
|
||||
impl WlSeatGlobal {
|
||||
pub fn key_surface(&self, surface: &WlSurface, key: u32, state: u32) {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use crate::object::Object;
|
|||
use crate::pixman::Region;
|
||||
use crate::rect::Rect;
|
||||
use crate::render::Renderer;
|
||||
use crate::tree::walker::NodeVisitor;
|
||||
use crate::tree::{ContainerSplit, Node, NodeId};
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
|
|
@ -578,6 +579,12 @@ dedicated_add_obj!(WlSurface, WlSurfaceId, surfaces);
|
|||
|
||||
tree_id!(SurfaceNodeId);
|
||||
impl Node for WlSurface {
|
||||
fn focus_parent(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
if let Some(xdg) = self.xdg.get() {
|
||||
xdg.focus_parent(seat);
|
||||
}
|
||||
}
|
||||
|
||||
fn id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
}
|
||||
|
|
@ -658,8 +665,9 @@ impl Node for WlSurface {
|
|||
|
||||
fn focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
if let Some(xdg) = self.xdg.get() {
|
||||
xdg.focus_surface.insert(seat.id(), self);
|
||||
xdg.focus_surface.insert(seat.id(), self.clone());
|
||||
}
|
||||
seat.focus_surface(&self);
|
||||
}
|
||||
|
||||
fn unfocus(&self, seat: &WlSeatGlobal) {
|
||||
|
|
@ -705,6 +713,19 @@ impl Node for WlSurface {
|
|||
fn dnd_motion(&self, dnd: &Dnd, x: Fixed, y: Fixed) {
|
||||
dnd.seat.dnd_surface_motion(self, dnd, x, y);
|
||||
}
|
||||
|
||||
fn visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_surface(&self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
let children = self.children.borrow_mut();
|
||||
if let Some(c) = children.deref() {
|
||||
for child in c.subsurfaces.values() {
|
||||
visitor.visit_surface(&child.surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
|
|
@ -75,6 +75,10 @@ struct PendingXdgSurfaceData {
|
|||
}
|
||||
|
||||
pub trait XdgSurfaceExt: Debug {
|
||||
fn focus_parent(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
let _ = seat;
|
||||
}
|
||||
|
||||
fn get_split(&self) -> Option<ContainerSplit> {
|
||||
None
|
||||
}
|
||||
|
|
@ -203,6 +207,12 @@ impl XdgSurface {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn focus_parent(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
if let Some(ext) = self.ext.get() {
|
||||
ext.focus_parent(seat);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn focus_surface(&self, seat: &WlSeatGlobal) -> Rc<WlSurface> {
|
||||
self.focus_surface
|
||||
.get(&seat.id())
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use crate::leaks::Tracker;
|
|||
use crate::object::Object;
|
||||
use crate::rect::Rect;
|
||||
use crate::render::Renderer;
|
||||
use crate::tree::walker::NodeVisitor;
|
||||
use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
|
|
@ -272,6 +273,14 @@ impl Node for XdgPopup {
|
|||
self.xdg.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_popup(&self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_surface(&self.xdg.surface);
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
self.xdg.absolute_desired_extents.get()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use crate::leaks::Tracker;
|
|||
use crate::object::Object;
|
||||
use crate::rect::Rect;
|
||||
use crate::render::Renderer;
|
||||
use crate::tree::walker::NodeVisitor;
|
||||
use crate::tree::{ContainerNode, ContainerSplit, FindTreeResult};
|
||||
use crate::tree::{FloatNode, FoundNode, Node, NodeId, ToplevelNodeId, WorkspaceNode};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
|
|
@ -81,6 +82,7 @@ pub struct XdgToplevel {
|
|||
min_height: Cell<Option<i32>>,
|
||||
max_width: Cell<Option<i32>>,
|
||||
max_height: Cell<Option<i32>>,
|
||||
title: RefCell<String>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +115,7 @@ impl XdgToplevel {
|
|||
min_height: Cell::new(None),
|
||||
max_width: Cell::new(None),
|
||||
max_height: Cell::new(None),
|
||||
title: RefCell::new("".to_string()),
|
||||
tracker: Default::default(),
|
||||
}
|
||||
}
|
||||
|
|
@ -210,7 +213,13 @@ impl XdgToplevel {
|
|||
}
|
||||
|
||||
fn set_title(&self, parser: MsgParser<'_, '_>) -> Result<(), SetTitleError> {
|
||||
let _req: SetTitle = self.xdg.surface.client.parse(self, parser)?;
|
||||
let req: SetTitle = self.xdg.surface.client.parse(self, parser)?;
|
||||
let mut title = self.title.borrow_mut();
|
||||
title.clear();
|
||||
title.push_str(req.title);
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
parent.child_title_changed(self, &title);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -302,6 +311,16 @@ impl XdgToplevel {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn notify_parent(&self) {
|
||||
let parent = match self.parent_node.get() {
|
||||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
let extents = self.xdg.extents.get();
|
||||
parent.child_size_changed(self, extents.width(), extents.height());
|
||||
parent.child_title_changed(self, self.title.borrow_mut().deref());
|
||||
}
|
||||
|
||||
fn map_child(self: &Rc<Self>, parent: &XdgToplevel) {
|
||||
let workspace = match parent.xdg.workspace.get() {
|
||||
Some(w) => w,
|
||||
|
|
@ -311,8 +330,8 @@ impl XdgToplevel {
|
|||
let output = workspace.output.get();
|
||||
let output_rect = output.position.get();
|
||||
log::info!("or = {:?}", output_rect);
|
||||
let extents = self.xdg.extents.get();
|
||||
let position = {
|
||||
let extents = self.xdg.extents.get().to_origin();
|
||||
let width = extents.width();
|
||||
let height = extents.height();
|
||||
let mut x1 = output_rect.x1();
|
||||
|
|
@ -345,6 +364,7 @@ impl XdgToplevel {
|
|||
floater
|
||||
.workspace_link
|
||||
.set(Some(workspace.stacked.add_last(floater.clone())));
|
||||
self.notify_parent();
|
||||
}
|
||||
|
||||
fn map_tiled(self: &Rc<Self>) {
|
||||
|
|
@ -442,6 +462,14 @@ impl Node for XdgToplevel {
|
|||
self.xdg.seat_state.destroy_node(self)
|
||||
}
|
||||
|
||||
fn visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_toplevel(&self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_surface(&self.xdg.surface);
|
||||
}
|
||||
|
||||
fn do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(&self);
|
||||
}
|
||||
|
|
@ -488,6 +516,10 @@ impl Node for XdgToplevel {
|
|||
}
|
||||
|
||||
impl XdgSurfaceExt for XdgToplevel {
|
||||
fn focus_parent(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
self.parent_node.get().map(|p| p.focus_self(seat));
|
||||
}
|
||||
|
||||
fn get_split(&self) -> Option<ContainerSplit> {
|
||||
self.parent_node.get().and_then(|p| p.get_split())
|
||||
}
|
||||
|
|
@ -514,6 +546,7 @@ impl XdgSurfaceExt for XdgToplevel {
|
|||
));
|
||||
self.parent_node.set(Some(cn.clone()));
|
||||
pn.replace_child(&*self, cn);
|
||||
self.notify_parent();
|
||||
}
|
||||
|
||||
fn move_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
|
|
@ -574,9 +607,8 @@ impl XdgSurfaceExt for XdgToplevel {
|
|||
}
|
||||
|
||||
fn extents_changed(&self) {
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
let extents = self.xdg.extents.get();
|
||||
parent.child_size_changed(self, extents.width(), extents.height());
|
||||
self.notify_parent();
|
||||
if self.parent_node.get().is_some() {
|
||||
self.xdg.surface.client.state.tree_changed();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue