Skip to content

Commit

Permalink
WIP: Enable necessary protocols for supporting IMEs
Browse files Browse the repository at this point in the history
I'm not entirely sure how text input focus should be managed:
Smithay/smithay#1038.

This "works" but is missing a bit of code to actually render the IME
surface, and the code in anvil calling `set_point` (I'm not sure exactly
what that is for or where/how it should be set here).
  • Loading branch information
ids1024 committed May 25, 2023
1 parent bd7a4ca commit 463a3a8
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ use smithay::{
compositor::{CompositorClientState, CompositorState},
data_device::DataDeviceState,
dmabuf::{DmabufFeedback, DmabufState},
input_method::InputMethodManagerState,
keyboard_shortcuts_inhibit::KeyboardShortcutsInhibitState,
output::OutputManagerState,
presentation::PresentationState,
primary_selection::PrimarySelectionState,
seat::WaylandFocus,
shell::{kde::decoration::KdeDecorationState, xdg::decoration::XdgDecorationState},
shm::ShmState,
text_input::TextInputManagerState,
viewporter::ViewporterState,
virtual_keyboard::VirtualKeyboardManagerState,
},
};
use tracing::error;
Expand Down Expand Up @@ -261,6 +264,9 @@ impl State {
let wl_drm_state = WlDrmState;
let kde_decoration_state = KdeDecorationState::new::<Self>(&dh, Mode::Client);
let xdg_decoration_state = XdgDecorationState::new::<Self>(&dh);
InputMethodManagerState::new::<Self>(&dh);
TextInputManagerState::new::<Self>(&dh);
VirtualKeyboardManagerState::new::<State, _>(&dh, |_client| true);

let shell = Shell::new(&config, dh);

Expand Down
9 changes: 9 additions & 0 deletions src/wayland/handlers/input_method.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only

// TODO: Restrict what applications can use protocol? At least don't allow in
// sandboxed app.

use crate::state::State;
use smithay::delegate_input_method_manager;

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 @@ -5,6 +5,7 @@ pub mod compositor;
pub mod data_device;
pub mod decoration;
pub mod dmabuf;
pub mod input_method;
pub mod keyboard_shortcuts_inhibit;
pub mod layer_shell;
pub mod output;
Expand All @@ -15,9 +16,11 @@ pub mod relative_pointer;
pub mod screencopy;
pub mod seat;
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;
9 changes: 7 additions & 2 deletions src/wayland/handlers/seat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use smithay::{
reexports::wayland_server::Resource,
wayland::{
data_device::set_data_device_focus, primary_selection::set_primary_focus,
seat::WaylandFocus,
seat::WaylandFocus, text_input::TextInputHandle,
},
};
use std::cell::RefCell;
Expand Down Expand Up @@ -46,7 +46,12 @@ 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));

if let Some(text_input) = seat.user_data().get::<TextInputHandle>() {
let surface = focused.and_then(WaylandFocus::wl_surface);
text_input.set_focus(surface.as_ref(), || {});
}
}
}
}
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 463a3a8

Please sign in to comment.