1
0
Fork 0
forked from wry/wry

autocommit 2022-02-01 23:33:59 CET

This commit is contained in:
Julian Orth 2022-02-01 23:33:59 +01:00
parent 41c5f8cf89
commit 2dbe3ba732
21 changed files with 814 additions and 86 deletions

View file

@ -350,6 +350,9 @@ impl WlSeatGlobal {
.enter(self, x.apply_fract(new.x), y.apply_fract(new.y));
stack.push(new.node);
}
if let Some(node) = stack.last() {
node.pointer_target(self);
}
}
found_tree.clear();
}
@ -397,7 +400,7 @@ impl WlSeatGlobal {
self.focus_toplevel(n);
}
pub fn enter_popup(self: &Rc<Self>, n: &Rc<XdgPopup>) {
pub fn enter_popup(self: &Rc<Self>, _n: &Rc<XdgPopup>) {
// self.focus_xdg_surface(&n.xdg);
}

View file

@ -12,7 +12,6 @@ use crate::ifs::wl_data_device::{WlDataDevice, WlDataDeviceId};
use crate::ifs::wl_seat::wl_keyboard::{WlKeyboard, WlKeyboardId, REPEAT_INFO_SINCE};
use crate::ifs::wl_seat::wl_pointer::{WlPointer, WlPointerId};
use crate::ifs::wl_seat::wl_touch::WlTouch;
use crate::ifs::wl_surface::cursor::CursorSurface;
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
use crate::object::{Interface, Object, ObjectId};
use crate::tree::{FloatNode, FoundNode, Node};
@ -31,6 +30,7 @@ use std::io::Write;
use std::rc::Rc;
pub use types::*;
use uapi::{c, OwnedFd};
use crate::cursor::{Cursor, KnownCursor};
id!(WlSeatId);
@ -74,7 +74,7 @@ pub struct WlSeatGlobal {
kb_state: RefCell<XkbState>,
layout: Rc<OwnedFd>,
layout_size: u32,
cursor: CloneCell<Option<Rc<CursorSurface>>>,
cursor: CloneCell<Option<Rc<dyn Cursor>>>,
serial: NumCell<u32>,
}
@ -121,7 +121,21 @@ impl WlSeatGlobal {
}
}
pub fn set_cursor(&self, cursor: Option<Rc<CursorSurface>>) {
pub fn set_known_cursor(&self, cursor: KnownCursor) {
let cursors = match self.state.cursors.get() {
Some(c) => c,
None => {
self.set_cursor(None);
return;
}
};
let tpl = match cursor {
KnownCursor::Default => &cursors.default,
};
self.set_cursor(Some(tpl.instantiate()));
}
pub fn set_cursor(&self, cursor: Option<Rc<dyn Cursor>>) {
if let Some(old) = self.cursor.get() {
if let Some(new) = cursor.as_ref() {
if Rc::ptr_eq(&old, new) {
@ -130,10 +144,15 @@ impl WlSeatGlobal {
}
old.handle_unset();
}
if let Some(cursor) = cursor.as_ref() {
log::info!("setting new cursor");
let (x, y) = self.pos.get();
cursor.set_position(x.round_down(), y.round_down());
}
self.cursor.set(cursor);
}
pub fn get_cursor(&self) -> Option<Rc<CursorSurface>> {
pub fn get_cursor(&self) -> Option<Rc<dyn Cursor>> {
self.cursor.get()
}

View file

@ -8,6 +8,7 @@ use crate::object::{Interface, Object, ObjectId};
use crate::utils::buffd::MsgParser;
use std::rc::Rc;
pub use types::*;
use crate::cursor::Cursor;
const SET_CURSOR: u32 = 0;
const RELEASE: u32 = 1;
@ -153,7 +154,7 @@ impl WlPointer {
let surface = self.seat.client.get_surface(req.surface)?;
let cursor = surface.get_cursor(&self.seat.global)?;
cursor.set_hotspot(req.hotspot_x, req.hotspot_y);
cursor_opt = Some(cursor);
cursor_opt = Some(cursor as Rc<dyn Cursor>);
}
let pointer_node = match self.seat.global.pointer_stack.borrow().last().cloned() {
Some(n) => n,