1
0
Fork 0
forked from wry/wry

autocommit 2022-04-07 23:21:31 CEST

This commit is contained in:
Julian Orth 2022-04-07 23:21:32 +02:00
parent be32036824
commit 26f8c1aeb6
14 changed files with 86 additions and 28 deletions

View file

@ -132,6 +132,7 @@ pub struct WlSeatGlobal {
queue_link: Cell<Option<LinkedNode<Rc<Self>>>>,
tree_changed_handler: Cell<Option<SpawnedFuture<()>>>,
output: CloneCell<Rc<OutputNode>>,
desired_known_cursor: Cell<Option<KnownCursor>>,
}
impl WlSeatGlobal {
@ -168,6 +169,7 @@ impl WlSeatGlobal {
queue_link: Cell::new(None),
tree_changed_handler: Cell::new(None),
output: CloneCell::new(state.dummy_output.get().unwrap()),
desired_known_cursor: Cell::new(None),
});
let seat = slf.clone();
let future = state.eng.spawn(async move {
@ -210,6 +212,21 @@ impl WlSeatGlobal {
}
}
pub fn set_position(&self, x: i32, y: i32) {
self.pos.set((Fixed::from_int(x), Fixed::from_int(y)));
self.trigger_tree_changed();
}
pub fn position(&self) -> (Fixed, Fixed) {
self.pos.get()
}
pub fn render_ctx_changed(&self) {
if let Some(cursor) = self.desired_known_cursor.get() {
self.set_known_cursor(cursor);
}
}
pub fn get_mono(&self) -> Option<bool> {
self.keyboard_node.get().get_parent_mono()
}
@ -326,10 +343,11 @@ impl WlSeatGlobal {
}
pub fn set_known_cursor(&self, cursor: KnownCursor) {
self.desired_known_cursor.set(Some(cursor));
let cursors = match self.state.cursors.get() {
Some(c) => c,
None => {
self.set_cursor(None);
self.set_cursor2(None);
return;
}
};
@ -342,10 +360,15 @@ impl WlSeatGlobal {
KnownCursor::ResizeBottomLeft => &cursors.resize_bottom_left,
KnownCursor::ResizeBottomRight => &cursors.resize_bottom_right,
};
self.set_cursor(Some(tpl.instantiate()));
self.set_cursor2(Some(tpl.instantiate()));
}
pub fn set_cursor(&self, cursor: Option<Rc<dyn Cursor>>) {
pub fn set_app_cursor(&self, cursor: Option<Rc<dyn Cursor>>) {
self.set_cursor2(cursor);
self.desired_known_cursor.set(None);
}
fn set_cursor2(&self, cursor: Option<Rc<dyn Cursor>>) {
if let Some(old) = self.cursor.get() {
if let Some(new) = cursor.as_ref() {
if rc_eq(&old, new) {

View file

@ -452,8 +452,9 @@ impl WlSeatGlobal {
impl WlSeatGlobal {
pub fn enter_toplevel(self: &Rc<Self>, n: Rc<dyn ToplevelNode>) {
if n.accepts_keyboard_focus() {
self.focus_toplevel(n);
log::info!("does not accept input focus");
}
self.focus_toplevel(n);
}
pub fn enter_popup(self: &Rc<Self>, _n: &Rc<XdgPopup>) {

View file

@ -144,7 +144,7 @@ impl WlPointer {
if pointer_node.client_id() != Some(self.seat.client.id) {
return Ok(());
}
self.seat.global.set_cursor(cursor_opt);
self.seat.global.set_app_cursor(cursor_opt);
Ok(())
}

View file

@ -253,7 +253,7 @@ impl WlSurface {
pub fn accepts_kb_focus(&self) -> bool {
match self.toplevel.get() {
Some(tl) => tl.accepts_keyboard_focus(),
Some(tl) => true,
_ => self.ext.get().accepts_kb_focus(),
}
}

View file

@ -46,7 +46,7 @@ impl CursorSurface {
}
pub fn handle_surface_destroy(&self) {
self.seat.set_cursor(None);
self.seat.set_app_cursor(None);
}
pub fn handle_buffer_change(&self) {

View file

@ -26,7 +26,7 @@ use {
jay_config::Direction,
std::{
cell::{Cell, RefCell},
ops::{Deref, Not},
ops::{Deref},
rc::Rc,
},
thiserror::Error,
@ -273,7 +273,7 @@ impl Xwindow {
pub fn map_status_changed(self: &Rc<Self>) {
match self.map_change() {
Change::None => {}
Change::None => return,
Change::Unmap => self.destroy_node(true),
Change::Map if self.data.info.override_redirect.get() => {
*self.display_link.borrow_mut() =
@ -304,6 +304,7 @@ impl Xwindow {
self.data.title_changed();
}
}
self.data.state.tree_changed();
}
}
@ -447,7 +448,7 @@ impl ToplevelNode for Xwindow {
}
fn accepts_keyboard_focus(&self) -> bool {
self.data.info.never_focus.get().not() && self.data.info.icccm_hints.input.get()
self.data.info.input_model.get() != XInputModel::None
}
fn default_surface(&self) -> Rc<WlSurface> {

View file

@ -375,11 +375,6 @@ impl Node for ZwlrLayerSurfaceV1 {
}
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
tree.push(FoundNode {
node: self.surface.clone(),
x,
y,
});
self.surface.find_tree_at_(x, y, tree)
}