Merge pull request #122 from pop-os/ime

Enable necessary protocols for supporting IMEs
This commit is contained in:
Victoria Brekenfeld 2023-11-08 13:02:53 +01:00 committed by GitHub
commit bdaec558e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 0 deletions

View file

@ -63,6 +63,7 @@ use smithay::{
compositor::{CompositorClientState, CompositorState},
dmabuf::{DmabufFeedback, DmabufState},
fractional_scale::{with_fractional_scale, FractionalScaleManagerState},
input_method::InputMethodManagerState,
keyboard_shortcuts_inhibit::KeyboardShortcutsInhibitState,
output::OutputManagerState,
pointer_constraints::PointerConstraintsState,
@ -74,7 +75,9 @@ use smithay::{
session_lock::{LockSurface, SessionLockManagerState},
shell::{kde::decoration::KdeDecorationState, xdg::decoration::XdgDecorationState},
shm::ShmState,
text_input::TextInputManagerState,
viewporter::ViewporterState,
virtual_keyboard::VirtualKeyboardManagerState,
xwayland_keyboard_grab::XWaylandKeyboardGrabState,
},
};
@ -351,6 +354,9 @@ impl State {
PointerConstraintsState::new::<Self>(&dh);
PointerGesturesState::new::<Self>(&dh);
SecurityContextState::new::<Self, _>(&dh, client_has_no_security_context);
InputMethodManagerState::new::<Self, _>(&dh, client_should_see_privileged_protocols);
TextInputManagerState::new::<Self>(&dh);
VirtualKeyboardManagerState::new::<State, _>(&dh, client_should_see_privileged_protocols);
let shell = Shell::new(&config, dh);

View file

@ -0,0 +1,40 @@
// SPDX-License-Identifier: GPL-3.0-only
use crate::state::State;
use smithay::{
delegate_input_method_manager,
desktop::{space::SpaceElement, PopupKind, PopupManager},
reexports::wayland_server::protocol::wl_surface::WlSurface,
utils::Rectangle,
wayland::input_method::{InputMethodHandler, PopupSurface},
};
use tracing::warn;
impl InputMethodHandler for State {
fn new_popup(&mut self, surface: PopupSurface) {
if let Err(err) = self
.common
.shell
.popups
.track_popup(PopupKind::from(surface))
{
warn!("Failed to track popup: {}", err);
}
}
fn dismiss_popup(&mut self, surface: PopupSurface) {
if let Some(parent) = surface.get_parent().map(|parent| parent.surface.clone()) {
let _ = PopupManager::dismiss_popup(&parent, &PopupKind::from(surface));
}
}
fn parent_geometry(&self, parent: &WlSurface) -> Rectangle<i32, smithay::utils::Logical> {
self.common
.shell
.element_for_wl_surface(parent)
.map(|e| e.geometry())
.unwrap_or_default()
}
}
delegate_input_method_manager!(State);

View file

@ -7,6 +7,7 @@ pub mod decoration;
pub mod dmabuf;
pub mod drm_lease;
pub mod fractional_scale;
pub mod input_method;
pub mod keyboard_shortcuts_inhibit;
pub mod layer_shell;
pub mod output;
@ -22,9 +23,11 @@ pub mod security_context;
pub mod selection;
pub mod session_lock;
pub mod shm;
pub mod text_input;
pub mod toplevel_info;
pub mod toplevel_management;
pub mod viewporter;
pub mod virtual_keyboard;
pub mod wl_drm;
pub mod workspace;
pub mod xdg_shell;

View file

@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
use crate::state::State;
use smithay::delegate_text_input_manager;
delegate_text_input_manager!(State);

View file

@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
use crate::state::State;
use smithay::delegate_virtual_keyboard_manager;
delegate_virtual_keyboard_manager!(State);