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

@ -354,6 +354,17 @@ impl ConfigProxyHandler {
if x < 0 || y < 0 || x > MAX_EXTENTS || y > MAX_EXTENTS {
return Err(CphError::InvalidConnectorPosition(x, y));
}
let old_pos = connector.node.global.pos.get();
let seats = self.state.globals.seats.lock();
for seat in seats.values() {
if seat.get_output().id == connector.node.id {
let seat_pos = seat.position();
seat.set_position(
seat_pos.0.round_down() + x - old_pos.x1(),
seat_pos.1.round_down() + y - old_pos.y1(),
);
}
}
connector.node.set_position(x, y);
Ok(())
}

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)
}

View file

@ -130,6 +130,11 @@ impl State {
}
}
self.root.clone().visit(&mut Walker);
let seats = self.globals.seats.lock();
for seat in seats.values() {
seat.render_ctx_changed();
}
}
pub fn add_global<T: WaylandGlobal>(&self, global: &Rc<T>) {

View file

@ -101,12 +101,19 @@ impl ConnectorHandler {
state: self.state.clone(),
is_dummy: false,
});
let mode = info.initial_mode;
let output_data = Rc::new(OutputData {
connector: self.data.clone(),
monitor_info: info,
node: on.clone(),
});
self.state.outputs.set(self.id, output_data);
if self.state.outputs.len() == 1 {
let seats = self.state.globals.seats.lock();
for seat in seats.values() {
seat.set_position(x1 + mode.width / 2, mode.height / 2);
}
}
global.node.set(Some(on.clone()));
if let Some(config) = self.state.config.get() {
config.connector_connected(self.id);

View file

@ -79,18 +79,8 @@ impl Node for DisplayNode {
x,
y,
});
let len = tree.len();
for layer in [OVERLAY, TOP] {
for surface in output.layers[layer as usize].rev_iter() {
let pos = surface.absolute_position();
if pos.contains(x, y) {
let (x, y) = pos.translate(x, y);
if surface.find_tree_at(x, y, tree) == FindTreeResult::AcceptsInput {
return FindTreeResult::AcceptsInput;
}
tree.truncate(len);
}
}
if output.find_layer_surface_at(x, y, &[OVERLAY, TOP], tree) == FindTreeResult::AcceptsInput {
return FindTreeResult::AcceptsInput;
}
tree.pop();
break;

View file

@ -23,6 +23,7 @@ use {
rc::Rc,
},
};
use crate::ifs::zwlr_layer_shell_v1::{BACKGROUND, BOTTOM};
tree_id!(OutputNodeId);
pub struct OutputNode {
@ -163,6 +164,23 @@ impl OutputNode {
}
self.global.send_mode();
}
pub fn find_layer_surface_at(&self, x: i32, y: i32, layers: &[u32], tree: &mut Vec<FoundNode>) -> FindTreeResult {
let len = tree.len();
for layer in layers.iter().copied() {
for surface in self.layers[layer as usize].rev_iter() {
let pos = surface.absolute_position();
if pos.contains(x, y) {
let (x, y) = pos.translate(x, y);
if surface.find_tree_at(x, y, tree) == FindTreeResult::AcceptsInput {
return FindTreeResult::AcceptsInput;
}
tree.truncate(len);
}
}
}
FindTreeResult::Other
}
}
pub struct OutputTitle {
@ -228,6 +246,7 @@ impl Node for OutputNode {
let th = self.state.theme.title_height.get();
if y > th {
y -= th;
let len = tree.len();
if let Some(ws) = self.workspace.get() {
tree.push(FoundNode {
node: ws.clone(),
@ -236,6 +255,9 @@ impl Node for OutputNode {
});
ws.find_tree_at(x, y, tree);
}
if tree.len() == len {
self.find_layer_surface_at(x, y, &[BOTTOM, BACKGROUND], tree);
}
}
FindTreeResult::AcceptsInput
}

View file

@ -78,6 +78,10 @@ impl<K: Eq + Hash, V> CopyHashMap<K, V> {
pub fn is_empty(&self) -> bool {
unsafe { self.map.get().deref().is_empty() }
}
pub fn len(&self) -> usize {
unsafe { self.map.get().deref().len() }
}
}
pub struct Locked<'a, K, V> {

View file

@ -460,7 +460,6 @@ impl Wm {
return;
}
let accepts_input = window.info.icccm_hints.input.get();
log::info!("{:?} ai {}", window.info.title, accepts_input);
let mask = if accepts_input {
EVENT_MASK_SUBSTRUCTURE_REDIRECT
} else {