Skip to content

Commit

Permalink
Enable necessary protocols for supporting IMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Nov 7, 2023
1 parent 18067de commit 304f406
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion src/wayland/handlers/seat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl SeatHandler for State {
.and_then(|s| dh.get_client(s.id()).ok())
{
set_data_device_focus(dh, seat, Some(client.clone()));
set_primary_focus(dh, seat, Some(client))
set_primary_focus(dh, seat, Some(client));
}
}
}
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);

0 comments on commit 304f406

Please sign in to comment.