autocommit 2022-02-02 20:01:25 CET
This commit is contained in:
parent
65a7a55b82
commit
89b8396932
12 changed files with 279 additions and 57 deletions
|
|
@ -294,13 +294,28 @@ impl WlSeatGlobal {
|
|||
self.handle_new_position(false);
|
||||
}
|
||||
|
||||
fn handle_new_position(self: &Rc<Self>, changed: bool) {
|
||||
fn handle_new_position(self: &Rc<Self>, pos_changed: bool) {
|
||||
let (x, y) = self.pos.get();
|
||||
if changed {
|
||||
if pos_changed {
|
||||
if let Some(cursor) = self.cursor.get() {
|
||||
cursor.set_position(x.round_down(), y.round_down());
|
||||
}
|
||||
}
|
||||
'handle_grab: {
|
||||
let grab_node = {
|
||||
let grabber = self.grabber.borrow_mut();
|
||||
match grabber.as_ref() {
|
||||
Some(n) => n.node.clone(),
|
||||
None => break 'handle_grab,
|
||||
}
|
||||
};
|
||||
if pos_changed {
|
||||
let pos = grab_node.absolute_position();
|
||||
let (x_int, y_int) = pos.translate(x.round_down(), y.round_down());
|
||||
grab_node.motion(self, x.apply_fract(x_int), y.apply_fract(y_int));
|
||||
}
|
||||
return;
|
||||
}
|
||||
let mut found_tree = self.found_tree.borrow_mut();
|
||||
let mut stack = self.pointer_stack.borrow_mut();
|
||||
// if self.move_.get() {
|
||||
|
|
@ -332,7 +347,7 @@ impl WlSeatGlobal {
|
|||
}
|
||||
}
|
||||
if (stack.len(), found_tree.len()) == (divergence, divergence) {
|
||||
if changed {
|
||||
if pos_changed {
|
||||
if let Some(node) = found_tree.last() {
|
||||
node.node
|
||||
.motion(self, x.apply_fract(node.x), y.apply_fract(node.y));
|
||||
|
|
|
|||
|
|
@ -50,11 +50,25 @@ const TOUCH: u32 = 4;
|
|||
#[allow(dead_code)]
|
||||
const MISSING_CAPABILITY: u32 = 0;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const BTN_LEFT: u32 = 0x110;
|
||||
pub const BTN_LEFT: u32 = 0x110;
|
||||
|
||||
pub const SEAT_NAME_SINCE: u32 = 2;
|
||||
|
||||
pub struct PointerGrab {
|
||||
seat: Rc<WlSeatGlobal>,
|
||||
}
|
||||
|
||||
pub struct PointerGrabber {
|
||||
node: Rc<dyn Node>,
|
||||
}
|
||||
|
||||
impl Drop for PointerGrab {
|
||||
fn drop(&mut self) {
|
||||
*self.seat.grabber.borrow_mut() = None;
|
||||
self.seat.tree_changed();
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WlSeatGlobal {
|
||||
name: GlobalName,
|
||||
state: Rc<State>,
|
||||
|
|
@ -76,6 +90,7 @@ pub struct WlSeatGlobal {
|
|||
layout_size: u32,
|
||||
cursor: CloneCell<Option<Rc<dyn Cursor>>>,
|
||||
serial: NumCell<u32>,
|
||||
grabber: RefCell<Option<PointerGrabber>>,
|
||||
}
|
||||
|
||||
impl WlSeatGlobal {
|
||||
|
|
@ -118,9 +133,23 @@ impl WlSeatGlobal {
|
|||
layout_size,
|
||||
cursor: Default::default(),
|
||||
serial: Default::default(),
|
||||
grabber: RefCell::new(None),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn grab_pointer(self: &Rc<Self>, node: Rc<dyn Node>) -> Option<PointerGrab> {
|
||||
let mut grabber = self.grabber.borrow_mut();
|
||||
if grabber.is_some() {
|
||||
return None;
|
||||
}
|
||||
*grabber = Some(PointerGrabber {
|
||||
node,
|
||||
});
|
||||
Some(PointerGrab {
|
||||
seat: self.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_known_cursor(&self, cursor: KnownCursor) {
|
||||
let cursors = match self.state.cursors.get() {
|
||||
Some(c) => c,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::ifs::xdg_positioner::{XdgPositioned, XdgPositioner, CA};
|
|||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::rect::Rect;
|
||||
use crate::render::Renderer;
|
||||
use crate::tree::{AbsoluteNode, FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode};
|
||||
use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::linkedlist::LinkedNode;
|
||||
|
|
@ -37,8 +37,8 @@ pub struct XdgPopup {
|
|||
pub xdg: Rc<XdgSurface>,
|
||||
pub(super) parent: CloneCell<Option<Rc<XdgSurface>>>,
|
||||
relative_position: Cell<Rect>,
|
||||
display_link: RefCell<Option<LinkedNode<Rc<dyn AbsoluteNode>>>>,
|
||||
workspace_link: RefCell<Option<LinkedNode<Rc<dyn AbsoluteNode>>>>,
|
||||
display_link: RefCell<Option<LinkedNode<Rc<dyn Node>>>>,
|
||||
workspace_link: RefCell<Option<LinkedNode<Rc<dyn Node>>>>,
|
||||
pos: RefCell<XdgPositioned>,
|
||||
}
|
||||
|
||||
|
|
@ -268,16 +268,6 @@ impl Object for XdgPopup {
|
|||
}
|
||||
}
|
||||
|
||||
impl AbsoluteNode for XdgPopup {
|
||||
fn into_node(self: Rc<Self>) -> Rc<dyn Node> {
|
||||
self
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> (Rect, bool) {
|
||||
(self.xdg.absolute_desired_extents.get(), false)
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for XdgPopup {
|
||||
fn id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
|
|
@ -294,6 +284,14 @@ impl Node for XdgPopup {
|
|||
self.xdg.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
self.xdg.absolute_desired_extents.get()
|
||||
}
|
||||
|
||||
fn absolute_position_constrains_input(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
self.xdg.find_tree_at(x, y, tree)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
mod types;
|
||||
|
||||
use crate::backend::SeatId;
|
||||
use crate::backend::{SeatId};
|
||||
use crate::client::{ClientId, DynEventFormatter};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
|
|
@ -388,6 +388,10 @@ impl Node for XdgToplevel {
|
|||
self.xdg.seat_state.destroy_node(self)
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
self.xdg.absolute_desired_extents.get()
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
self.xdg.find_tree_at(x, y, tree)
|
||||
}
|
||||
|
|
@ -405,12 +409,14 @@ impl Node for XdgToplevel {
|
|||
}
|
||||
|
||||
fn change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
let nw = rect.width();
|
||||
let nh = rect.height();
|
||||
let de = self.xdg.absolute_desired_extents.replace(*rect);
|
||||
if de.width() != rect.width() || de.height() != rect.height() {
|
||||
if de.width() != nw || de.height() != nh {
|
||||
self.xdg
|
||||
.surface
|
||||
.client
|
||||
.event(self.configure(rect.width(), rect.height()));
|
||||
.event(self.configure(nw.max(1), nh.max(1)));
|
||||
self.xdg.send_configure();
|
||||
self.xdg.surface.client.flush();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue