autocommit 2022-02-14 21:13:42 CET
This commit is contained in:
parent
9b8e1ac29f
commit
da6b29f138
44 changed files with 5903 additions and 364 deletions
|
|
@ -4,7 +4,6 @@ pub mod wl_keyboard;
|
|||
pub mod wl_pointer;
|
||||
pub mod wl_touch;
|
||||
|
||||
use crate::backend::{Seat, SeatId};
|
||||
use crate::client::{Client, ClientError, ClientId};
|
||||
use crate::cursor::{Cursor, KnownCursor};
|
||||
use crate::fixed::Fixed;
|
||||
|
|
@ -29,24 +28,25 @@ use crate::utils::buffd::MsgParser;
|
|||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::copyhashmap::CopyHashMap;
|
||||
use crate::utils::linkedlist::LinkedList;
|
||||
use crate::utils::linkedlist::{LinkedList, LinkedNode};
|
||||
use crate::wire::wl_seat::*;
|
||||
use crate::wire::{
|
||||
WlDataDeviceId, WlKeyboardId, WlPointerId, WlSeatId, ZwpPrimarySelectionDeviceV1Id,
|
||||
};
|
||||
use crate::xkbcommon::{XkbContext, XkbState};
|
||||
use crate::{NumCell, State};
|
||||
use crate::xkbcommon::{XkbKeymap, XkbState};
|
||||
use crate::{ErrorFmt, NumCell, State};
|
||||
use ahash::{AHashMap, AHashSet};
|
||||
use bstr::ByteSlice;
|
||||
pub use event_handling::NodeSeatState;
|
||||
use i4config::keyboard::mods::Modifiers;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::io::Write;
|
||||
use std::mem;
|
||||
use std::ops::DerefMut;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::{c, OwnedFd};
|
||||
use uapi::{c, Errno, OwnedFd};
|
||||
use i4config::Direction;
|
||||
use crate::async_engine::SpawnedFuture;
|
||||
|
||||
const POINTER: u32 = 1;
|
||||
const KEYBOARD: u32 = 2;
|
||||
|
|
@ -79,11 +79,13 @@ impl Drop for DroppedDnd {
|
|||
}
|
||||
}
|
||||
|
||||
linear_ids!(SeatIds, SeatId);
|
||||
|
||||
pub struct WlSeatGlobal {
|
||||
id: SeatId,
|
||||
name: GlobalName,
|
||||
state: Rc<State>,
|
||||
seat: Rc<dyn Seat>,
|
||||
seat_name: Rc<String>,
|
||||
seat_name: String,
|
||||
move_: Cell<bool>,
|
||||
move_start_pos: Cell<(Fixed, Fixed)>,
|
||||
extents_start_pos: Cell<(i32, i32)>,
|
||||
|
|
@ -101,9 +103,9 @@ pub struct WlSeatGlobal {
|
|||
AHashMap<ZwpPrimarySelectionDeviceV1Id, Rc<ZwpPrimarySelectionDeviceV1>>,
|
||||
>,
|
||||
>,
|
||||
repeat_rate: Cell<(i32, i32)>,
|
||||
kb_map: CloneCell<Rc<XkbKeymap>>,
|
||||
kb_state: RefCell<XkbState>,
|
||||
layout: Rc<OwnedFd>,
|
||||
layout_size: u32,
|
||||
cursor: CloneCell<Option<Rc<dyn Cursor>>>,
|
||||
serial: NumCell<u32>,
|
||||
tree_changed: Rc<AsyncEvent>,
|
||||
|
|
@ -111,37 +113,22 @@ pub struct WlSeatGlobal {
|
|||
primary_selection: CloneCell<Option<Rc<ZwpPrimarySelectionSourceV1>>>,
|
||||
pointer_owner: PointerOwnerHolder,
|
||||
dropped_dnd: RefCell<Option<DroppedDnd>>,
|
||||
shortcuts: CopyHashMap<(u32, u32), Modifiers>,
|
||||
queue_link: Cell<Option<LinkedNode<Rc<Self>>>>,
|
||||
tree_changed_handler: Cell<Option<SpawnedFuture<()>>>,
|
||||
}
|
||||
|
||||
impl WlSeatGlobal {
|
||||
pub fn new(
|
||||
name: GlobalName,
|
||||
seat_name: &str,
|
||||
state: &Rc<State>,
|
||||
seat: &Rc<dyn Seat>,
|
||||
tree_changed: &Rc<AsyncEvent>,
|
||||
) -> Self {
|
||||
let (kb_state, layout, layout_size) = {
|
||||
let ctx = XkbContext::new().unwrap();
|
||||
let keymap = ctx.default_keymap().unwrap();
|
||||
let state = keymap.state().unwrap();
|
||||
let string = keymap.as_str().unwrap();
|
||||
let mut memfd =
|
||||
uapi::memfd_create("keymap", c::MFD_CLOEXEC | c::MFD_ALLOW_SEALING).unwrap();
|
||||
memfd.write_all(string.as_bytes()).unwrap();
|
||||
memfd.write_all(&[0]).unwrap();
|
||||
uapi::lseek(memfd.raw(), 0, c::SEEK_SET).unwrap();
|
||||
uapi::fcntl_add_seals(
|
||||
memfd.raw(),
|
||||
c::F_SEAL_SEAL | c::F_SEAL_GROW | c::F_SEAL_SHRINK | c::F_SEAL_WRITE,
|
||||
)
|
||||
.unwrap();
|
||||
(state, Rc::new(memfd), (string.len() + 1) as _)
|
||||
};
|
||||
Self {
|
||||
) -> Rc<Self> {
|
||||
let slf = Rc::new(Self {
|
||||
id: state.seat_ids.next(),
|
||||
name,
|
||||
state: state.clone(),
|
||||
seat: seat.clone(),
|
||||
seat_name: Rc::new(format!("seat-{}", seat.id())),
|
||||
seat_name: seat_name.to_string(),
|
||||
move_: Cell::new(false),
|
||||
move_start_pos: Cell::new((Fixed(0), Fixed(0))),
|
||||
extents_start_pos: Cell::new((0, 0)),
|
||||
|
|
@ -154,19 +141,79 @@ impl WlSeatGlobal {
|
|||
bindings: Default::default(),
|
||||
data_devices: RefCell::new(Default::default()),
|
||||
primary_selection_devices: RefCell::new(Default::default()),
|
||||
kb_state: RefCell::new(kb_state),
|
||||
layout,
|
||||
layout_size,
|
||||
repeat_rate: Cell::new((25, 250)),
|
||||
kb_map: CloneCell::new(state.default_keymap.clone()),
|
||||
kb_state: RefCell::new(state.default_keymap.state().unwrap()),
|
||||
cursor: Default::default(),
|
||||
serial: Default::default(),
|
||||
tree_changed: tree_changed.clone(),
|
||||
tree_changed: Default::default(),
|
||||
selection: Default::default(),
|
||||
primary_selection: Default::default(),
|
||||
pointer_owner: Default::default(),
|
||||
dropped_dnd: RefCell::new(None),
|
||||
shortcuts: Default::default(),
|
||||
queue_link: Cell::new(None),
|
||||
tree_changed_handler: Cell::new(None),
|
||||
});
|
||||
let seat = slf.clone();
|
||||
state.eng.spawn(async move {
|
||||
loop {
|
||||
seat.tree_changed.triggered().await;
|
||||
seat.state.tree_changed_sent.set(false);
|
||||
seat.tree_changed();
|
||||
}
|
||||
});
|
||||
slf
|
||||
}
|
||||
|
||||
pub fn mark_last_active(self: &Rc<Self>) {
|
||||
self.queue_link.set(Some(self.state.seat_queue.add_last(self.clone())));
|
||||
}
|
||||
|
||||
pub fn set_keymap(&self, keymap: &Rc<XkbKeymap>) {
|
||||
self.kb_map.set(keymap.clone());
|
||||
let bindings = self.bindings.borrow_mut();
|
||||
for (id, client) in bindings.iter() {
|
||||
for seat in client.values() {
|
||||
let kbs = seat.keyboards.lock();
|
||||
for kb in kbs.values() {
|
||||
let fd = match seat.keymap_fd(&keymap) {
|
||||
Ok(fd) => fd,
|
||||
Err(e) => {
|
||||
log::error!("Could not creat a file descriptor to transfer the keymap to client {}: {}", id, ErrorFmt(e));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
kb.send_keymap(wl_keyboard::XKB_V1, fd, keymap.map_len as _);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_rate(&self) -> (i32, i32) {
|
||||
self.repeat_rate.get()
|
||||
}
|
||||
|
||||
pub fn set_rate(&self, rate: i32, delay: i32) {
|
||||
self.repeat_rate.set((rate, delay));
|
||||
let bindings = self.bindings.borrow_mut();
|
||||
for client in bindings.values() {
|
||||
for seat in client.values() {
|
||||
if seat.version >= REPEAT_INFO_SINCE {
|
||||
let kbs = seat.keyboards.lock();
|
||||
for kb in kbs.values() {
|
||||
kb.send_repeat_info(rate, delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn move_focus(self: &Rc<Self>, direction: Direction) {
|
||||
let kb_node = self.keyboard_node.get();
|
||||
kb_node.move_focus(self, direction);
|
||||
}
|
||||
|
||||
fn set_selection_<T: ipc::Vtable>(
|
||||
self: &Rc<Self>,
|
||||
field: &CloneCell<Option<Rc<T::Source>>>,
|
||||
|
|
@ -275,7 +322,7 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
pub fn id(&self) -> SeatId {
|
||||
self.seat.id()
|
||||
self.id
|
||||
}
|
||||
|
||||
fn bind_(
|
||||
|
|
@ -321,6 +368,8 @@ impl Global for WlSeatGlobal {
|
|||
|
||||
fn break_loops(&self) {
|
||||
self.bindings.borrow_mut().clear();
|
||||
self.queue_link.take();
|
||||
self.tree_changed_handler.take();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -336,6 +385,8 @@ pub struct WlSeat {
|
|||
tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
const READ_ONLY_KEYMAP_SINCE: u32 = 7;
|
||||
|
||||
impl WlSeat {
|
||||
fn send_capabilities(self: &Rc<Self>) {
|
||||
self.client.event(Capabilities {
|
||||
|
|
@ -404,13 +455,41 @@ impl WlSeat {
|
|||
track!(self.client, p);
|
||||
self.client.add_client_obj(&p)?;
|
||||
self.keyboards.set(req.id, p.clone());
|
||||
p.send_keymap(wl_keyboard::XKB_V1, p.keymap_fd()?, self.global.layout_size);
|
||||
let keymap = self.global.kb_map.get();
|
||||
p.send_keymap(wl_keyboard::XKB_V1, self.keymap_fd(&keymap)?, keymap.map_len as _);
|
||||
if self.version >= REPEAT_INFO_SINCE {
|
||||
p.send_repeat_info(25, 250);
|
||||
let (rate, delay) = self.global.repeat_rate.get();
|
||||
p.send_repeat_info(rate, delay);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn keymap_fd(&self, keymap: &XkbKeymap) -> Result<Rc<OwnedFd>, WlKeyboardError> {
|
||||
if self.version >= READ_ONLY_KEYMAP_SINCE {
|
||||
return Ok(keymap.map.clone());
|
||||
}
|
||||
let fd = match uapi::memfd_create("shared-keymap", c::MFD_CLOEXEC) {
|
||||
Ok(fd) => fd,
|
||||
Err(e) => return Err(WlKeyboardError::KeymapMemfd(e.into())),
|
||||
};
|
||||
let target = keymap.map_len as c::off_t;
|
||||
let mut pos = 0;
|
||||
while pos < target {
|
||||
let rem = target - pos;
|
||||
let res = uapi::sendfile(
|
||||
fd.raw(),
|
||||
keymap.map.raw(),
|
||||
Some(&mut pos),
|
||||
rem as usize,
|
||||
);
|
||||
match res {
|
||||
Ok(_) | Err(Errno(c::EINTR)) => {}
|
||||
Err(e) => return Err(WlKeyboardError::KeymapCopy(e.into())),
|
||||
}
|
||||
}
|
||||
Ok(Rc::new(fd))
|
||||
}
|
||||
|
||||
fn get_touch(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), GetTouchError> {
|
||||
let req: GetTouch = self.client.parse(&**self, parser)?;
|
||||
let p = Rc::new(WlTouch::new(req.id, self));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::backend::{KeyState, OutputId, ScrollAxis, SeatEvent, SeatId};
|
||||
use crate::backend::{KeyboardEvent, KeyState, MouseEvent, OutputId, ScrollAxis};
|
||||
use crate::client::{Client, ClientId};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::ipc;
|
||||
|
|
@ -6,7 +6,7 @@ use crate::ifs::ipc::wl_data_device::WlDataDevice;
|
|||
use crate::ifs::ipc::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1;
|
||||
use crate::ifs::wl_seat::wl_keyboard::WlKeyboard;
|
||||
use crate::ifs::wl_seat::wl_pointer::{WlPointer, POINTER_FRAME_SINCE_VERSION};
|
||||
use crate::ifs::wl_seat::{wl_keyboard, wl_pointer, Dnd, WlSeat, WlSeatGlobal};
|
||||
use crate::ifs::wl_seat::{wl_keyboard, wl_pointer, Dnd, WlSeat, WlSeatGlobal, SeatId};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_popup::XdgPopup;
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
|
||||
use crate::ifs::wl_surface::xdg_surface::XdgSurface;
|
||||
|
|
@ -17,6 +17,10 @@ use crate::utils::clonecell::CloneCell;
|
|||
use crate::utils::smallmap::SmallMap;
|
||||
use crate::wire::WlDataOfferId;
|
||||
use crate::xkbcommon::{ModifierState, XKB_KEY_DOWN, XKB_KEY_UP};
|
||||
use i4config::keyboard::mods::Modifiers;
|
||||
use i4config::keyboard::syms::KeySym;
|
||||
use i4config::keyboard::ModifiedKeySym;
|
||||
use smallvec::SmallVec;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
|
@ -30,37 +34,37 @@ pub struct NodeSeatState {
|
|||
|
||||
impl NodeSeatState {
|
||||
pub(super) fn enter(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
self.pointer_foci.insert(seat.seat.id(), seat.clone());
|
||||
self.pointer_foci.insert(seat.id, seat.clone());
|
||||
}
|
||||
|
||||
pub(super) fn leave(&self, seat: &WlSeatGlobal) {
|
||||
self.pointer_foci.remove(&seat.seat.id());
|
||||
self.pointer_foci.remove(&seat.id);
|
||||
}
|
||||
|
||||
pub(super) fn focus(&self, seat: &Rc<WlSeatGlobal>) -> bool {
|
||||
self.kb_foci.insert(seat.seat.id(), seat.clone());
|
||||
self.kb_foci.insert(seat.id, seat.clone());
|
||||
self.kb_foci.len() == 1
|
||||
}
|
||||
|
||||
pub(super) fn unfocus(&self, seat: &WlSeatGlobal) -> bool {
|
||||
self.kb_foci.remove(&seat.seat.id());
|
||||
self.kb_foci.remove(&seat.id);
|
||||
self.kb_foci.len() == 0
|
||||
}
|
||||
|
||||
pub(super) fn add_pointer_grab(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
self.grabs.insert(seat.id(), seat.clone());
|
||||
self.grabs.insert(seat.id, seat.clone());
|
||||
}
|
||||
|
||||
pub(super) fn remove_pointer_grab(&self, seat: &WlSeatGlobal) {
|
||||
self.grabs.remove(&seat.id());
|
||||
self.grabs.remove(&seat.id);
|
||||
}
|
||||
|
||||
pub(super) fn add_dnd_target(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
self.dnd_targets.insert(seat.id(), seat.clone());
|
||||
self.dnd_targets.insert(seat.id, seat.clone());
|
||||
}
|
||||
|
||||
pub(super) fn remove_dnd_target(&self, seat: &WlSeatGlobal) {
|
||||
self.dnd_targets.remove(&seat.id());
|
||||
self.dnd_targets.remove(&seat.id);
|
||||
}
|
||||
|
||||
// pub fn remove_pointer_grabs(&self) {
|
||||
|
|
@ -100,13 +104,18 @@ impl NodeSeatState {
|
|||
}
|
||||
|
||||
impl WlSeatGlobal {
|
||||
pub fn event(self: &Rc<Self>, event: SeatEvent) {
|
||||
pub fn kb_event(self: &Rc<Self>, event: KeyboardEvent) {
|
||||
match event {
|
||||
SeatEvent::OutputPosition(o, x, y) => self.output_position_event(o, x, y),
|
||||
SeatEvent::Motion(dx, dy) => self.motion_event(dx, dy),
|
||||
SeatEvent::Button(b, s) => self.pointer_owner.button(self, b, s),
|
||||
SeatEvent::Scroll(d, a) => self.pointer_owner.scroll(self, d, a),
|
||||
SeatEvent::Key(k, s) => self.key_event(k, s),
|
||||
KeyboardEvent::Key(k, s) => self.key_event(k, s),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mouse_event(self: &Rc<Self>, event: MouseEvent) {
|
||||
match event {
|
||||
MouseEvent::OutputPosition(o, x, y) => self.output_position_event(o, x, y),
|
||||
MouseEvent::Motion(dx, dy) => self.motion_event(dx, dy),
|
||||
MouseEvent::Button(b, s) => self.pointer_owner.button(self, b, s),
|
||||
MouseEvent::Scroll(d, a) => self.pointer_owner.scroll(self, d, a),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -143,9 +152,35 @@ impl WlSeatGlobal {
|
|||
}
|
||||
}
|
||||
};
|
||||
let mods = self.kb_state.borrow_mut().update(key, xkb_dir);
|
||||
let mut shortcuts = SmallVec::<[_; 1]>::new();
|
||||
let new_mods;
|
||||
{
|
||||
let mut kb_state = self.kb_state.borrow_mut();
|
||||
if state == wl_keyboard::PRESSED {
|
||||
let old_mods = kb_state.mods();
|
||||
let keysyms = kb_state.unmodified_keysyms(key);
|
||||
for &sym in keysyms {
|
||||
if let Some(mods) = self.shortcuts.get(&(old_mods.mods_effective, sym)) {
|
||||
shortcuts.push(ModifiedKeySym {
|
||||
mods,
|
||||
sym: KeySym(sym),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
new_mods = kb_state.update(key, xkb_dir);
|
||||
}
|
||||
let node = self.keyboard_node.get();
|
||||
node.key(self, key, state, mods);
|
||||
if shortcuts.is_empty() {
|
||||
node.key(self, key, state);
|
||||
} else if let Some(config) = self.state.config.get() {
|
||||
for shortcut in shortcuts {
|
||||
config.invoke_shortcut(self.id(), &shortcut);
|
||||
}
|
||||
}
|
||||
if let Some(mods) = new_mods {
|
||||
node.mods(self, mods);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -206,6 +241,7 @@ impl WlSeatGlobal {
|
|||
mods_latched,
|
||||
mods_locked,
|
||||
group,
|
||||
..
|
||||
} = self.kb_state.borrow().mods();
|
||||
let serial = self.serial.fetch_add(1);
|
||||
self.surface_kb_event(0, &surface, |k| {
|
||||
|
|
@ -331,7 +367,15 @@ impl WlSeatGlobal {
|
|||
self.handle_new_position(true);
|
||||
}
|
||||
|
||||
pub fn tree_changed(self: &Rc<Self>) {
|
||||
pub fn add_shortcut(&self, mods: Modifiers, keysym: KeySym) {
|
||||
self.shortcuts.set((mods.0, keysym.0), mods);
|
||||
}
|
||||
|
||||
pub fn trigger_tree_changed(&self) {
|
||||
self.tree_changed.trigger();
|
||||
}
|
||||
|
||||
pub(super) fn tree_changed(self: &Rc<Self>) {
|
||||
self.handle_new_position(false);
|
||||
}
|
||||
|
||||
|
|
@ -417,27 +461,25 @@ impl WlSeatGlobal {
|
|||
|
||||
// Key callbacks
|
||||
impl WlSeatGlobal {
|
||||
pub fn key_surface(
|
||||
&self,
|
||||
surface: &WlSurface,
|
||||
key: u32,
|
||||
state: u32,
|
||||
mods: Option<ModifierState>,
|
||||
) {
|
||||
pub fn key_surface(&self, surface: &WlSurface, key: u32, state: u32) {
|
||||
let serial = self.serial.fetch_add(1);
|
||||
self.surface_kb_event(0, surface, |k| k.send_key(serial, 0, key, state));
|
||||
}
|
||||
}
|
||||
|
||||
// Modifiers callbacks
|
||||
impl WlSeatGlobal {
|
||||
pub fn mods_surface(&self, surface: &WlSurface, mods: ModifierState) {
|
||||
let serial = self.serial.fetch_add(1);
|
||||
if let Some(mods) = mods {
|
||||
self.surface_kb_event(0, surface, |k| {
|
||||
k.send_modifiers(
|
||||
serial,
|
||||
mods.mods_depressed,
|
||||
mods.mods_latched,
|
||||
mods.mods_locked,
|
||||
mods.group,
|
||||
)
|
||||
});
|
||||
}
|
||||
self.surface_kb_event(0, surface, |k| {
|
||||
k.send_modifiers(
|
||||
serial,
|
||||
mods.mods_depressed,
|
||||
mods.mods_latched,
|
||||
mods.mods_locked,
|
||||
mods.group,
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::wire::wl_keyboard::*;
|
|||
use crate::wire::{WlKeyboardId, WlSurfaceId};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::{c, Errno, OwnedFd};
|
||||
use uapi::{OwnedFd};
|
||||
|
||||
pub const REPEAT_INFO_SINCE: u32 = 4;
|
||||
|
||||
|
|
@ -34,36 +34,6 @@ impl WlKeyboard {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn needs_dedicated_keymap_fd(&self) -> bool {
|
||||
self.seat.version < 7
|
||||
}
|
||||
|
||||
pub fn keymap_fd(&self) -> Result<Rc<OwnedFd>, WlKeyboardError> {
|
||||
if !self.needs_dedicated_keymap_fd() {
|
||||
return Ok(self.seat.global.layout.clone());
|
||||
}
|
||||
let fd = match uapi::memfd_create("shared-keymap", c::MFD_CLOEXEC) {
|
||||
Ok(fd) => fd,
|
||||
Err(e) => return Err(WlKeyboardError::KeymapMemfd(e.into())),
|
||||
};
|
||||
let target = self.seat.global.layout_size as c::off_t;
|
||||
let mut pos = 0;
|
||||
while pos < target {
|
||||
let rem = target - pos;
|
||||
let res = uapi::sendfile(
|
||||
fd.raw(),
|
||||
self.seat.global.layout.raw(),
|
||||
Some(&mut pos),
|
||||
rem as usize,
|
||||
);
|
||||
match res {
|
||||
Ok(_) | Err(Errno(c::EINTR)) => {}
|
||||
Err(e) => return Err(WlKeyboardError::KeymapCopy(e.into())),
|
||||
}
|
||||
}
|
||||
Ok(Rc::new(fd))
|
||||
}
|
||||
|
||||
pub fn send_keymap(self: &Rc<Self>, format: u32, fd: Rc<OwnedFd>, size: u32) {
|
||||
self.seat.client.event(Keymap {
|
||||
self_id: self.id,
|
||||
|
|
|
|||
|
|
@ -2,12 +2,11 @@ pub mod cursor;
|
|||
pub mod wl_subsurface;
|
||||
pub mod xdg_surface;
|
||||
|
||||
use crate::backend::{KeyState, ScrollAxis, SeatId};
|
||||
use crate::client::{Client, ClientError, RequestParser};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_buffer::WlBuffer;
|
||||
use crate::ifs::wl_callback::WlCallback;
|
||||
use crate::ifs::wl_seat::{Dnd, NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_seat::{Dnd, NodeSeatState, SeatId, WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::cursor::CursorSurface;
|
||||
use crate::ifs::wl_surface::wl_subsurface::WlSubsurface;
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceRole};
|
||||
|
|
@ -32,6 +31,8 @@ use std::mem;
|
|||
use std::ops::{Deref, DerefMut};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use i4config::Direction;
|
||||
use crate::backend::{KeyState, ScrollAxis};
|
||||
|
||||
#[allow(dead_code)]
|
||||
const INVALID_SCALE: u32 = 0;
|
||||
|
|
@ -609,6 +610,14 @@ impl Node for WlSurface {
|
|||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn move_focus(&self, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
let xdg = match self.xdg.get() {
|
||||
Some(x) => x,
|
||||
_ => return,
|
||||
};
|
||||
xdg.move_focus(seat, direction);
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
self.buffer_abs_pos.get()
|
||||
}
|
||||
|
|
@ -619,8 +628,12 @@ impl Node for WlSurface {
|
|||
}
|
||||
}
|
||||
|
||||
fn key(&self, seat: &WlSeatGlobal, key: u32, state: u32, mods: Option<ModifierState>) {
|
||||
seat.key_surface(self, key, state, mods);
|
||||
fn key(&self, seat: &WlSeatGlobal, key: u32, state: u32) {
|
||||
seat.key_surface(self, key, state);
|
||||
}
|
||||
|
||||
fn mods(&self, seat: &WlSeatGlobal, mods: ModifierState) {
|
||||
seat.mods_surface(self, mods);
|
||||
}
|
||||
|
||||
fn button(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, button: u32, state: KeyState) {
|
||||
|
|
@ -665,10 +678,6 @@ impl Node for WlSurface {
|
|||
Some(self)
|
||||
}
|
||||
|
||||
fn dnd_enter(&self, dnd: &Dnd, x: Fixed, y: Fixed) {
|
||||
dnd.seat.dnd_surface_enter(self, dnd, x, y);
|
||||
}
|
||||
|
||||
fn dnd_drop(&self, dnd: &Dnd) {
|
||||
dnd.seat.dnd_surface_drop(self, dnd);
|
||||
}
|
||||
|
|
@ -677,6 +686,10 @@ impl Node for WlSurface {
|
|||
dnd.seat.dnd_surface_leave(self, dnd);
|
||||
}
|
||||
|
||||
fn dnd_enter(&self, dnd: &Dnd, x: Fixed, y: Fixed) {
|
||||
dnd.seat.dnd_surface_enter(self, dnd, x, y);
|
||||
}
|
||||
|
||||
fn dnd_motion(&self, dnd: &Dnd, x: Fixed, y: Fixed) {
|
||||
dnd.seat.dnd_surface_motion(self, dnd, x, y);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
pub mod xdg_popup;
|
||||
pub mod xdg_toplevel;
|
||||
|
||||
use crate::backend::SeatId;
|
||||
use crate::client::ClientError;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_popup::{XdgPopup, XdgPopupError};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
|
||||
use crate::ifs::wl_surface::{
|
||||
|
|
@ -26,6 +25,7 @@ use std::cell::Cell;
|
|||
use std::fmt::Debug;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use i4config::Direction;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const NOT_CONSTRUCTED: u32 = 1;
|
||||
|
|
@ -75,6 +75,11 @@ struct PendingXdgSurfaceData {
|
|||
}
|
||||
|
||||
pub trait XdgSurfaceExt: Debug {
|
||||
fn move_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
let _ = seat;
|
||||
let _ = direction;
|
||||
}
|
||||
|
||||
fn initial_configure(self: Rc<Self>) -> Result<(), XdgSurfaceError> {
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -137,6 +142,14 @@ impl XdgSurface {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn move_focus(&self, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
let ext = match self.ext.get() {
|
||||
None => return,
|
||||
Some(e) => e,
|
||||
};
|
||||
ext.move_focus(seat, direction);
|
||||
}
|
||||
|
||||
pub fn role(&self) -> XdgSurfaceRole {
|
||||
self.role.get()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
use crate::backend::SeatId;
|
||||
use crate::bugs::Bugs;
|
||||
use crate::client::{Client, ClientError};
|
||||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt};
|
||||
use crate::leaks::Tracker;
|
||||
use crate::object::Object;
|
||||
|
|
@ -27,6 +26,7 @@ use std::mem;
|
|||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use i4config::Direction;
|
||||
|
||||
#[derive(Copy, Clone, Debug, FromPrimitive)]
|
||||
pub enum ResizeEdge {
|
||||
|
|
@ -438,6 +438,10 @@ impl Node for XdgToplevel {
|
|||
self.xdg.seat_state.destroy_node(self)
|
||||
}
|
||||
|
||||
fn do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(&self);
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
self.xdg.absolute_desired_extents.get()
|
||||
}
|
||||
|
|
@ -480,6 +484,14 @@ impl Node for XdgToplevel {
|
|||
}
|
||||
|
||||
impl XdgSurfaceExt for XdgToplevel {
|
||||
fn move_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
let pn = match self.parent_node.get() {
|
||||
Some(pn) => pn,
|
||||
_ => return,
|
||||
};
|
||||
pn.move_focus_from_child(seat, &*self, direction);
|
||||
}
|
||||
|
||||
fn initial_configure(self: Rc<Self>) -> Result<(), XdgSurfaceError> {
|
||||
self.send_configure(0, 0);
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue