keyboard: move KeyboardState to dedicated module
This commit is contained in:
parent
1a35ba3909
commit
e7d5a23af3
16 changed files with 60 additions and 43 deletions
|
|
@ -6,6 +6,7 @@ use {
|
|||
ei_ifs::ei_device::{EiDevice, EiDeviceInterface},
|
||||
ei_object::{EiObject, EiVersion},
|
||||
},
|
||||
keyboard::KeyboardState,
|
||||
leaks::Tracker,
|
||||
wire_ei::{
|
||||
ei_keyboard::{
|
||||
|
|
@ -13,7 +14,6 @@ use {
|
|||
},
|
||||
EiKeyboardId,
|
||||
},
|
||||
xkbcommon::KeyboardState,
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use {
|
|||
},
|
||||
fixed::Fixed,
|
||||
ifs::wl_seat::{wl_pointer::PendingScroll, WlSeatGlobal},
|
||||
keyboard::{DynKeyboardState, KeyboardState, KeyboardStateId},
|
||||
leaks::Tracker,
|
||||
tree::Node,
|
||||
utils::{array, bitflags::BitflagsExt, clonecell::CloneCell},
|
||||
|
|
@ -26,7 +27,6 @@ use {
|
|||
},
|
||||
EiSeatId,
|
||||
},
|
||||
xkbcommon::{DynKeyboardState, KeyboardState, KeyboardStateId},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
thiserror::Error,
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ use {
|
|||
wl_pointer::PendingScroll,
|
||||
SeatId,
|
||||
},
|
||||
keyboard::ModifierState,
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
wire::{jay_seat_events::*, JaySeatEventsId},
|
||||
xkbcommon::ModifierState,
|
||||
},
|
||||
std::{convert::Infallible, rc::Rc},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ use {
|
|||
},
|
||||
xdg_toplevel_drag_v1::XdgToplevelDragV1,
|
||||
},
|
||||
keyboard::{DynKeyboardState, KeyboardState},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
rect::Rect,
|
||||
|
|
@ -91,7 +92,7 @@ use {
|
|||
ZwpTextInputV3Id,
|
||||
},
|
||||
wire_ei::EiSeatId,
|
||||
xkbcommon::{DynKeyboardState, KeyboardState, KeymapId, XkbKeymap, XkbState},
|
||||
xkbcommon::{KeymapId, XkbKeymap, XkbState},
|
||||
},
|
||||
ahash::AHashMap,
|
||||
smallvec::SmallVec,
|
||||
|
|
|
|||
|
|
@ -33,13 +33,14 @@ use {
|
|||
},
|
||||
wl_surface::{xdg_surface::xdg_popup::XdgPopup, WlSurface},
|
||||
},
|
||||
keyboard::KeyboardState,
|
||||
object::Version,
|
||||
rect::Rect,
|
||||
state::DeviceHandlerData,
|
||||
tree::{Direction, Node, ToplevelNode},
|
||||
utils::{bitflags::BitflagsExt, hash_map_ext::HashMapExt, smallmap::SmallMap},
|
||||
wire::WlDataOfferId,
|
||||
xkbcommon::{KeyboardState, XkbState, XKB_KEY_DOWN, XKB_KEY_UP},
|
||||
xkbcommon::{XkbState, XKB_KEY_DOWN, XKB_KEY_UP},
|
||||
},
|
||||
isnt::std_1::primitive::{IsntSlice2Ext, IsntSliceExt},
|
||||
jay_config::{
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ use {
|
|||
crate::{
|
||||
client::{Client, ClientError},
|
||||
ifs::wl_seat::{text_input::zwp_input_method_v2::ZwpInputMethodV2, wl_keyboard},
|
||||
keyboard::{KeyboardState, KeyboardStateId},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::errorfmt::ErrorFmt,
|
||||
wire::{zwp_input_method_keyboard_grab_v2::*, ZwpInputMethodKeyboardGrabV2Id},
|
||||
xkbcommon::{KeyboardState, KeyboardStateId},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
thiserror::Error,
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ use {
|
|||
ZwpInputPopupSurfaceV2, ZwpInputPopupSurfaceV2Error,
|
||||
},
|
||||
},
|
||||
keyboard::KeyboardStateId,
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::{clonecell::CloneCell, numcell::NumCell, smallmap::SmallMap},
|
||||
wire::{zwp_input_method_v2::*, ZwpInputMethodV2Id, ZwpInputPopupSurfaceV2Id},
|
||||
xkbcommon::KeyboardStateId,
|
||||
},
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@ use {
|
|||
crate::{
|
||||
client::ClientError,
|
||||
ifs::wl_seat::WlSeat,
|
||||
keyboard::{KeyboardState, KeyboardStateId, ModifierState},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::errorfmt::ErrorFmt,
|
||||
wire::{wl_keyboard::*, WlKeyboardId, WlSurfaceId},
|
||||
xkbcommon::{KeyboardState, KeyboardStateId, ModifierState, XkbCommonError},
|
||||
xkbcommon::XkbCommonError,
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
thiserror::Error,
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ use {
|
|||
client::{Client, ClientCaps, ClientError, CAP_VIRTUAL_KEYBOARD_MANAGER},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::wl_seat::zwp_virtual_keyboard_v1::ZwpVirtualKeyboardV1,
|
||||
keyboard::KeyboardState,
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
wire::{zwp_virtual_keyboard_manager_v1::*, ZwpVirtualKeyboardManagerV1Id},
|
||||
xkbcommon::KeyboardState,
|
||||
},
|
||||
std::{cell::RefCell, rc::Rc},
|
||||
thiserror::Error,
|
||||
|
|
|
|||
|
|
@ -9,10 +9,11 @@ use {
|
|||
},
|
||||
wl_surface::WlSurface,
|
||||
},
|
||||
keyboard::KeyboardState,
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
wire::{zwp_virtual_keyboard_v1::*, ZwpVirtualKeyboardV1Id},
|
||||
xkbcommon::{KeyboardState, XkbCommonError},
|
||||
xkbcommon::XkbCommonError,
|
||||
},
|
||||
std::{cell::RefCell, rc::Rc},
|
||||
thiserror::Error,
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ use {
|
|||
zwp_linux_dmabuf_feedback_v1::ZwpLinuxDmabufFeedbackV1,
|
||||
},
|
||||
io_uring::IoUringError,
|
||||
keyboard::KeyboardState,
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
rect::{DamageQueue, Rect, Region},
|
||||
|
|
@ -88,7 +89,6 @@ use {
|
|||
wl_surface::*, WlOutputId, WlSurfaceId, ZwpIdleInhibitorV1Id,
|
||||
ZwpLinuxDmabufFeedbackV1Id,
|
||||
},
|
||||
xkbcommon::KeyboardState,
|
||||
xwayland::XWaylandEvent,
|
||||
},
|
||||
ahash::AHashMap,
|
||||
|
|
|
|||
37
src/keyboard.rs
Normal file
37
src/keyboard.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
use {
|
||||
crate::utils::vecset::VecSet,
|
||||
std::{
|
||||
cell::{Ref, RefCell},
|
||||
rc::Rc,
|
||||
},
|
||||
uapi::OwnedFd,
|
||||
};
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
pub struct ModifierState {
|
||||
pub mods_depressed: u32,
|
||||
pub mods_latched: u32,
|
||||
pub mods_locked: u32,
|
||||
pub mods_effective: u32,
|
||||
pub group: u32,
|
||||
}
|
||||
|
||||
linear_ids!(KeyboardStateIds, KeyboardStateId, u64);
|
||||
|
||||
pub struct KeyboardState {
|
||||
pub id: KeyboardStateId,
|
||||
pub map: Rc<OwnedFd>,
|
||||
pub map_len: usize,
|
||||
pub pressed_keys: VecSet<u32>,
|
||||
pub mods: ModifierState,
|
||||
}
|
||||
|
||||
pub trait DynKeyboardState {
|
||||
fn borrow(&self) -> Ref<'_, KeyboardState>;
|
||||
}
|
||||
|
||||
impl DynKeyboardState for RefCell<KeyboardState> {
|
||||
fn borrow(&self) -> Ref<'_, KeyboardState> {
|
||||
self.borrow()
|
||||
}
|
||||
}
|
||||
|
|
@ -74,6 +74,7 @@ mod ifs;
|
|||
mod io_uring;
|
||||
#[cfg(feature = "it")]
|
||||
mod it;
|
||||
mod keyboard;
|
||||
mod libinput;
|
||||
mod logger;
|
||||
mod logind;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ use {
|
|||
zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1Global,
|
||||
},
|
||||
io_uring::IoUring,
|
||||
keyboard::KeyboardStateIds,
|
||||
leaks::Tracker,
|
||||
logger::Logger,
|
||||
rect::{Rect, Region},
|
||||
|
|
@ -99,7 +100,7 @@ use {
|
|||
ExtForeignToplevelListV1Id, ExtIdleNotificationV1Id, JayRenderCtxId, JaySeatEventsId,
|
||||
JayWorkspaceWatcherId, ZwpLinuxDmabufFeedbackV1Id,
|
||||
},
|
||||
xkbcommon::{KeyboardStateIds, XkbContext, XkbKeymap, XkbState},
|
||||
xkbcommon::{XkbContext, XkbKeymap, XkbState},
|
||||
xwayland::{self, XWaylandEvent},
|
||||
},
|
||||
ahash::{AHashMap, AHashSet},
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ use {
|
|||
},
|
||||
wl_surface::{tray::TrayItemId, WlSurface},
|
||||
},
|
||||
keyboard::KeyboardState,
|
||||
rect::Rect,
|
||||
renderer::Renderer,
|
||||
utils::numcell::NumCell,
|
||||
xkbcommon::KeyboardState,
|
||||
},
|
||||
jay_config::Direction as JayDirection,
|
||||
std::{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,10 @@ include!(concat!(env!("OUT_DIR"), "/xkbcommon_tys.rs"));
|
|||
|
||||
pub use consts::*;
|
||||
use {
|
||||
crate::utils::{errorfmt::ErrorFmt, oserror::OsError, ptr_ext::PtrExt, vecset::VecSet},
|
||||
crate::{
|
||||
keyboard::{DynKeyboardState, KeyboardState, KeyboardStateId, ModifierState},
|
||||
utils::{errorfmt::ErrorFmt, oserror::OsError, ptr_ext::PtrExt},
|
||||
},
|
||||
bstr::{BStr, ByteSlice},
|
||||
isnt::std_1::primitive::IsntConstPtrExt,
|
||||
std::{
|
||||
|
|
@ -252,35 +255,6 @@ impl Drop for XkbKeymapStr {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
pub struct ModifierState {
|
||||
pub mods_depressed: u32,
|
||||
pub mods_latched: u32,
|
||||
pub mods_locked: u32,
|
||||
pub mods_effective: u32,
|
||||
pub group: u32,
|
||||
}
|
||||
|
||||
linear_ids!(KeyboardStateIds, KeyboardStateId, u64);
|
||||
|
||||
pub struct KeyboardState {
|
||||
pub id: KeyboardStateId,
|
||||
pub map: Rc<OwnedFd>,
|
||||
pub map_len: usize,
|
||||
pub pressed_keys: VecSet<u32>,
|
||||
pub mods: ModifierState,
|
||||
}
|
||||
|
||||
pub trait DynKeyboardState {
|
||||
fn borrow(&self) -> Ref<'_, KeyboardState>;
|
||||
}
|
||||
|
||||
impl DynKeyboardState for RefCell<KeyboardState> {
|
||||
fn borrow(&self) -> Ref<'_, KeyboardState> {
|
||||
self.borrow()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct XkbState {
|
||||
map: Rc<XkbKeymap>,
|
||||
state: *mut xkb_state,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue