add sxmo target
The SXMO (sway) environment expects that the on-screen keyboard does not handle visibility by itself. Add a new target that ignores the program's own show/hide requests and shows the keyboard on startup.
This commit is contained in:
parent
cefc4ddc79
commit
32f3fee405
2 changed files with 78 additions and 0 deletions
|
|
@ -29,6 +29,10 @@ bindgen = "0.69.4"
|
|||
name = "ufkbd-gnome"
|
||||
path = "src/ufkbd_gnome.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "ufkbd-sxmo"
|
||||
path = "src/ufkbd_sxmo.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "ufkbd-wl"
|
||||
path = "src/ufkbd_wl.rs"
|
||||
|
|
|
|||
74
src/ufkbd_sxmo.rs
Normal file
74
src/ufkbd_sxmo.rs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Copyright (c) 2024, Richard Acayan. All rights reserved.
|
||||
*/
|
||||
|
||||
mod core;
|
||||
mod wayland;
|
||||
|
||||
use crate::core::Layout;
|
||||
use crate::wayland::Dispatcher;
|
||||
use polling::Event;
|
||||
use polling::Events;
|
||||
use polling::Poller;
|
||||
use std::mem;
|
||||
use std::path::Path;
|
||||
use std::time::Instant;
|
||||
use wayland_client::globals;
|
||||
|
||||
pub struct VisibilityManager();
|
||||
|
||||
impl VisibilityManager {
|
||||
pub fn set_visible(&self, _visible: bool)
|
||||
{
|
||||
// SXMO manages visibility
|
||||
}
|
||||
}
|
||||
|
||||
fn main()
|
||||
{
|
||||
let conn = wayland_client::Connection::connect_to_env().unwrap();
|
||||
|
||||
let (globals, mut queue) = globals::registry_queue_init::<Dispatcher>(&conn)
|
||||
.expect("Registry required");
|
||||
|
||||
let layouts = Path::new("/usr/share/unfettered-keyboard/layouts");
|
||||
let layout = Layout::load(layouts, "latn_qwerty_us.xml")
|
||||
.expect("Layout should be loadable");
|
||||
let mut dispatcher = Dispatcher::new(layout, queue.handle(), &globals).unwrap();
|
||||
dispatcher.set_osk(VisibilityManager());
|
||||
|
||||
let gfx = dispatcher.graphics();
|
||||
let mut gfx = gfx.lock().unwrap();
|
||||
gfx.display_mut().show();
|
||||
mem::drop(gfx);
|
||||
|
||||
let wl_evt = Event::readable(0);
|
||||
|
||||
let mut events = Events::new();
|
||||
let poller = Poller::new().unwrap();
|
||||
|
||||
loop {
|
||||
conn.flush().unwrap();
|
||||
|
||||
let guard = queue.prepare_read().unwrap();
|
||||
let fd = guard.connection_fd();
|
||||
let timer = dispatcher.button().next_time().map(|t| t - Instant::now());
|
||||
|
||||
unsafe {
|
||||
poller.add(&fd, wl_evt).unwrap();
|
||||
}
|
||||
|
||||
events.clear();
|
||||
poller.wait(&mut events, timer).unwrap();
|
||||
poller.delete(fd).unwrap();
|
||||
|
||||
if !events.is_empty() {
|
||||
// This may still emit EWOULDBLOCK errors.
|
||||
let _ = guard.read();
|
||||
queue.dispatch_pending(&mut dispatcher).unwrap();
|
||||
}
|
||||
|
||||
dispatcher.dispatch_timers();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue