Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable necessary protocols for supporting IMEs #122

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
};
Expand Down Expand Up @@ -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);

Expand Down
40 changes: 40 additions & 0 deletions src/wayland/handlers/input_method.rs
Original file line number Diff line number Diff line change
@@ -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);
3 changes: 3 additions & 0 deletions src/wayland/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/wayland/handlers/text_input.rs
Original file line number Diff line number Diff line change
@@ -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);
6 changes: 6 additions & 0 deletions src/wayland/handlers/virtual_keyboard.rs
Original file line number Diff line number Diff line change
@@ -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);