fixes and renaming

This commit is contained in:
rano-oss 2022-08-01 21:04:03 +08:00
parent 7a7899a5f9
commit 84f5fd406c
12 changed files with 48 additions and 50 deletions

View file

@ -73,7 +73,7 @@ pub fn draw_input_popup_surface(
SurfaceTree {
surface,
position: location.into(),
z_index: 99, /* Cursor should always be on-top */
z_index: 98, /* Input-popup should only be below cursor */
}
}

View file

@ -18,7 +18,7 @@ use smithay::{
utils::{Logical, Point},
wayland::{
compositor::with_states,
input_method_manager::InputMethodSeatTrait,
input_method::InputMethodSeat,
output::Scale,
seat::{keysyms as xkb, AxisFrame, ButtonEvent, FilterResult, Keysym, ModifiersState, MotionEvent},
shell::wlr_layer::{KeyboardInteractivity, Layer as WlrLayer, LayerSurfaceCachedState},

View file

@ -27,7 +27,7 @@ use smithay::{
set_data_device_focus, ClientDndGrabHandler, DataDeviceHandler, DataDeviceState,
ServerDndGrabHandler,
},
input_method_manager::{InputMethodManagerState, InputMethodSeatTrait},
input_method::{InputMethodManagerState, InputMethodSeat},
output::{Output, OutputManagerState},
primary_selection::{set_primary_focus, PrimarySelectionHandler, PrimarySelectionState},
seat::{CursorImageStatus, Seat, SeatHandler, SeatState, XkbConfig},
@ -41,7 +41,7 @@ use smithay::{
shm::{ShmHandler, ShmState},
socket::ListeningSocketSource,
tablet_manager::TabletSeatTrait,
text_input_manager::{TextInputManagerState, TextInputSeatTrait},
text_input::{TextInputManagerState, TextInputSeat},
viewporter::ViewporterState,
xdg_activation::{
XdgActivationHandler, XdgActivationState, XdgActivationToken, XdgActivationTokenData,

View file

@ -29,7 +29,7 @@ use smithay::{
},
utils::IsAlive,
wayland::{
input_method_manager::InputMethodSeatTrait,
input_method::InputMethodSeat,
output::{Mode, Output, PhysicalProperties},
seat::CursorImageStatus,
},
@ -223,9 +223,7 @@ pub fn run_winit(log: Logger) {
let input_method = state.seat.input_method();
let (x, y, _, height) = input_method.coordinates();
input_method.with_surface(|surface| {
if surface.alive() {
elements.push(draw_input_popup_surface(surface.clone(), (x, (y + height))).into());
}
});
// draw the cursor as relevant

View file

@ -16,10 +16,10 @@ use wayland_server::{
use xkbcommon::xkb;
use crate::{
utils::{Logical, Point},
utils::{IsAlive, Logical, Point},
wayland::{
seat::{keyboard::KeymapFile, KeyboardHandle, XkbConfig},
text_input_manager::TextInputHandle,
text_input::TextInputHandle,
SERIAL_COUNTER,
},
};
@ -104,10 +104,12 @@ impl InputMethodHandle {
let popup = inner.popup.inner.lock().unwrap();
if popup.surface_role.is_some() {
if let Some(surface) = &popup.surface {
if surface.alive() {
f(surface);
}
}
}
}
/// Used to access the relative location of an input popup surface
pub fn coordinates(&self) -> (i32, i32, i32, i32) {

View file

@ -10,7 +10,7 @@ use wayland_server::Dispatch;
use crate::wayland::seat::keyboard::KeymapFile;
use crate::wayland::seat::KeyboardGrabStartData;
use crate::wayland::seat::{KeyboardGrab, KeyboardHandle, KeyboardInnerHandle};
use crate::wayland::text_input_manager::TextInputHandle;
use crate::wayland::text_input::TextInputHandle;
use super::InputMethodManagerState;

View file

@ -10,13 +10,13 @@
//! delegate_text_input_manager,
//! };
//! use smithay::wayland::seat::{Seat, SeatState, SeatHandler, XkbConfig};
//! use smithay::wayland::input_method_manager::{
//! use smithay::wayland::input_method::{
//! InputMethodManagerState,
//! InputMethodSeatTrait
//! InputMethodSeat
//! };
//! use smithay::wayland::text_input_manager::{
//! use smithay::wayland::text_input::{
//! TextInputManagerState,
//! TextInputSeatTrait
//! TextInputSeat
//! };
//!
//! # struct State { seat_state: SeatState<Self> };
@ -74,20 +74,20 @@ use wayland_protocols_misc::zwp_input_method_v2::server::{
use crate::wayland::seat::Seat;
pub use input_method::{InputMethodHandle, InputMethodUserData};
pub use input_method_handle::{InputMethodHandle, InputMethodUserData};
pub use input_method_keyboard_grab::InputMethodKeyboardUserData;
pub use input_method_popup_surface::InputMethodPopupSurfaceUserData;
use super::{seat::XkbConfig, text_input_manager::TextInputHandle};
use super::{seat::XkbConfig, text_input::TextInputHandle};
const MANAGER_VERSION: u32 = 1;
mod input_method;
mod input_method_handle;
mod input_method_keyboard_grab;
mod input_method_popup_surface;
/// Extends [Seat] with input method functionality
pub trait InputMethodSeatTrait {
pub trait InputMethodSeat {
/// Add an input method to this seat, and configures the associated keyboard.
/// Input methods need different keyboard languages for different input methods.
/// E.g a pinyin user will want to use their native keyboard layout, but a
@ -98,7 +98,7 @@ pub trait InputMethodSeatTrait {
fn input_method(&self) -> InputMethodHandle;
}
impl<D: 'static> InputMethodSeatTrait for Seat<D> {
impl<D: 'static> InputMethodSeat for Seat<D> {
fn add_input_method(&self, xkb_config: XkbConfig<'_>, repeat_delay: i32, repeat_rate: i32) {
let user_data = self.user_data();
user_data.insert_if_missing(InputMethodHandle::default);
@ -205,19 +205,19 @@ macro_rules! delegate_input_method_manager {
($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => {
$crate::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
$crate::reexports::wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_method_manager_v2::ZwpInputMethodManagerV2: ()
] => $crate::wayland::input_method_manager::InputMethodManagerState);
] => $crate::wayland::input_method::InputMethodManagerState);
$crate::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
$crate::reexports::wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_method_manager_v2::ZwpInputMethodManagerV2: ()
] => $crate::wayland::input_method_manager::InputMethodManagerState);
] => $crate::wayland::input_method::InputMethodManagerState);
$crate::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
$crate::reexports::wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_method_v2::ZwpInputMethodV2: $crate::wayland::input_method_manager::InputMethodUserData
] => $crate::wayland::input_method_manager::InputMethodManagerState);
$crate::reexports::wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_method_v2::ZwpInputMethodV2: $crate::wayland::input_method::InputMethodUserData
] => $crate::wayland::input_method::InputMethodManagerState);
$crate::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
$crate::reexports::wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_method_keyboard_grab_v2::ZwpInputMethodKeyboardGrabV2: $crate::wayland::input_method_manager::InputMethodKeyboardUserData
] => $crate::wayland::input_method_manager::InputMethodManagerState);
$crate::reexports::wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_method_keyboard_grab_v2::ZwpInputMethodKeyboardGrabV2: $crate::wayland::input_method::InputMethodKeyboardUserData
] => $crate::wayland::input_method::InputMethodManagerState);
$crate::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
$crate::reexports::wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_popup_surface_v2::ZwpInputPopupSurfaceV2: $crate::wayland::input_method_manager::InputMethodPopupSurfaceUserData
] => $crate::wayland::input_method_manager::InputMethodManagerState);
$crate::reexports::wayland_protocols_misc::zwp_input_method_v2::server::zwp_input_popup_surface_v2::ZwpInputPopupSurfaceV2: $crate::wayland::input_method::InputMethodPopupSurfaceUserData
] => $crate::wayland::input_method::InputMethodManagerState);
};
}

View file

@ -51,7 +51,7 @@ pub mod buffer;
pub mod compositor;
pub mod data_device;
pub mod dmabuf;
pub mod input_method_manager;
pub mod input_method;
pub mod output;
pub mod primary_selection;
pub mod seat;
@ -59,7 +59,7 @@ pub mod shell;
pub mod shm;
pub mod socket;
pub mod tablet_manager;
pub mod text_input_manager;
pub mod text_input;
pub mod viewporter;
pub mod xdg_activation;

View file

@ -10,13 +10,13 @@
//! delegate_text_input_manager,
//! };
//! use smithay::wayland::seat::{Seat, SeatState, SeatHandler, XkbConfig};
//! use smithay::wayland::input_method_manager::{
//! use smithay::wayland::input_method::{
//! InputMethodManagerState,
//! InputMethodSeatTrait
//! InputMethodSeat
//! };
//! use smithay::wayland::text_input_manager::{
//! use smithay::wayland::text_input::{
//! TextInputManagerState,
//! TextInputSeatTrait
//! TextInputSeat
//! };
//!
//! # struct State { seat_state: SeatState<Self> };
@ -65,22 +65,22 @@ use wayland_server::{backend::GlobalId, Client, DataInit, Dispatch, DisplayHandl
use crate::wayland::seat::Seat;
pub use text_input::TextInputHandle;
pub use text_input::TextInputUserData;
pub use text_input_handle::TextInputHandle;
pub use text_input_handle::TextInputUserData;
use super::input_method_manager::InputMethodHandle;
use super::input_method::InputMethodHandle;
const MANAGER_VERSION: u32 = 1;
mod text_input;
mod text_input_handle;
/// Extends [Seat] with text input functionality
pub trait TextInputSeatTrait {
pub trait TextInputSeat {
/// Get text input associated with this seat
fn text_input(&self) -> TextInputHandle;
}
impl<D: 'static> TextInputSeatTrait for Seat<D> {
impl<D: 'static> TextInputSeat for Seat<D> {
fn text_input(&self) -> TextInputHandle {
let user_data = self.user_data();
user_data.insert_if_missing(TextInputHandle::default);
@ -181,14 +181,14 @@ macro_rules! delegate_text_input_manager {
($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => {
$crate::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
$crate::reexports::wayland_protocols::wp::text_input::zv3::server::zwp_text_input_manager_v3::ZwpTextInputManagerV3: ()
] => $crate::wayland::text_input_manager::TextInputManagerState);
] => $crate::wayland::text_input::TextInputManagerState);
$crate::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
$crate::reexports::wayland_protocols::wp::text_input::zv3::server::zwp_text_input_manager_v3::ZwpTextInputManagerV3: ()
] => $crate::wayland::text_input_manager::TextInputManagerState);
] => $crate::wayland::text_input::TextInputManagerState);
$crate::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
$crate::reexports::wayland_protocols::wp::text_input::zv3::server::zwp_text_input_v3::ZwpTextInputV3: $crate::wayland::text_input_manager::TextInputUserData
] => $crate::wayland::text_input_manager::TextInputManagerState);
$crate::reexports::wayland_protocols::wp::text_input::zv3::server::zwp_text_input_v3::ZwpTextInputV3: $crate::wayland::text_input::TextInputUserData
] => $crate::wayland::text_input::TextInputManagerState);
};
}

View file

@ -5,7 +5,7 @@ use wayland_server::backend::{ClientId, ObjectId};
use wayland_server::{protocol::wl_surface::WlSurface, Dispatch, Resource};
use crate::utils::IsAlive;
use crate::wayland::input_method_manager::InputMethodHandle;
use crate::wayland::input_method::InputMethodHandle;
use super::TextInputManagerState;

View file

@ -18,7 +18,7 @@ use smithay::{
},
utils::IsAlive,
wayland::{
input_method_manager::InputMethodSeatTrait,
input_method::InputMethodSeat,
output::{Mode, Output, PhysicalProperties},
seat::{ButtonEvent, CursorImageStatus, MotionEvent},
SERIAL_COUNTER as SCOUNTER,
@ -121,9 +121,7 @@ pub fn run(channel: Channel<WlcsEvent>) {
let input_method = state.seat.input_method();
let (x, y, _, height) = input_method.coordinates();
input_method.with_surface(|surface| {
if surface.alive() {
elements.push(draw_input_popup_surface(surface.clone(), (x, (y + height))).into());
}
});
// draw the cursor as relevant