diff --git a/wayvr/src/overlays/keyboard/builder.rs b/wayvr/src/overlays/keyboard/builder.rs index d924cd07..e95e8c80 100644 --- a/wayvr/src/overlays/keyboard/builder.rs +++ b/wayvr/src/overlays/keyboard/builder.rs @@ -507,7 +507,6 @@ pub(super) fn create_keyboard_panel( predictions_root, StyleSetRequest::Display(Display::Flex), )); - } } } diff --git a/wayvr/src/overlays/keyboard/layout.rs b/wayvr/src/overlays/keyboard/layout.rs index f65e3bd0..84c489a8 100644 --- a/wayvr/src/overlays/keyboard/layout.rs +++ b/wayvr/src/overlays/keyboard/layout.rs @@ -2,7 +2,6 @@ use std::{collections::HashMap, str::FromStr, sync::LazyLock}; use regex::Regex; use serde::{Deserialize, Serialize}; -use smithay::reexports::wayland_protocols::wp::pointer_gestures::zv1::server::zwp_pointer_gesture_swipe_v1::ZwpPointerGestureSwipeV1; use crate::{ config::{ConfigType, load_known_yaml}, subsystem::hid::{ diff --git a/wayvr/src/overlays/keyboard/mod.rs b/wayvr/src/overlays/keyboard/mod.rs index e98d4333..13c56cd3 100644 --- a/wayvr/src/overlays/keyboard/mod.rs +++ b/wayvr/src/overlays/keyboard/mod.rs @@ -29,11 +29,15 @@ use crate::{ use anyhow::Context; use glam::{Affine3A, Quat, Vec3, vec3, Vec2}; use regex::Regex; -use slotmap::{SlotMap, new_key_type}; +use slotmap::{SlotMap, new_key_type, Key}; use wgui::{ drawing, event::{InternalStateChangeEvent, MouseButtonEvent, MouseButtonIndex}, }; +use wgui::event::StyleSetRequest; +use wgui::layout::{Layout, LayoutTask}; +use wgui::parser::Fetchable; +use wgui::taffy::Display; use wlx_common::windowing::{OverlayWindowState, Positioning}; use wlx_common::{ config::AltModifier, @@ -124,7 +128,7 @@ pub fn create_keyboard(app: &mut AppState, wayland: bool) -> anyhow::Result { state.swipe_typing_manager = Some(engine); @@ -135,6 +139,18 @@ pub fn init_swipe_type_manager(state: &mut KeyboardState) { } }; } +pub(self) fn hide_swipe_type_manager(panel: &mut GuiPanel) { + let predictions_root = panel.parser_state + .get_widget_id("swipe_predictions_root") + .unwrap_or_default(); + + if !predictions_root.is_null() { + panel.layout.tasks.push(LayoutTask::SetWidgetStyle( + predictions_root, + StyleSetRequest::Display(Display::None), + )); + } +} fn alt_modifier_to_key(m: AltModifier) -> KeyModifier { match m { AltModifier::Shift => SHIFT, @@ -168,12 +184,18 @@ impl KeyboardBackend { ) -> anyhow::Result { let mut state = self.default_state.take(); - init_swipe_type_manager(&mut state); + if app.session.config.keyboard_swipe_to_type_enabled { + init_swipe_type_manager(&mut state); + } log::info!("swipe engine created"); - let panel = + let mut panel = create_keyboard_panel(app, keymap, state, &self.wlx_layout)?; + if !app.session.config.keyboard_swipe_to_type_enabled { + hide_swipe_type_manager(&mut panel); + } + let id = self.layout_panels.insert(panel); if let Some(layout_name) = keymap.and_then(|k| k.get_name()) { self.layout_ids.insert(layout_name.into(), id); @@ -198,17 +220,17 @@ impl KeyboardBackend { if self.active_layout.eq(new_key) { return Ok(false); } - self.internal_switch_keymap(*new_key, keymap); + self.internal_switch_keymap(*new_key, app); } else { let new_key = self.add_new_keymap(Some(keymap), app)?; - self.internal_switch_keymap(new_key, keymap); + self.internal_switch_keymap(new_key, app); } app.tasks .enqueue(TaskType::Overlay(OverlayTask::KeyboardChanged)); Ok(true) } - fn internal_switch_keymap(&mut self, new_key: KeyboardPanelKey, keymap: &XkbKeymap) { + fn internal_switch_keymap(&mut self, new_key: KeyboardPanelKey, app: &AppState) { let mut state_from = self .layout_panels .get_mut(self.active_layout) @@ -216,7 +238,9 @@ impl KeyboardBackend { .state .take(); - init_swipe_type_manager(&mut state_from); + if app.session.config.keyboard_swipe_to_type_enabled { + init_swipe_type_manager(&mut state_from); + } self.active_layout = new_key; @@ -224,6 +248,13 @@ impl KeyboardBackend { .get_mut(self.active_layout) .unwrap() .state = state_from; + + if !app.session.config.keyboard_swipe_to_type_enabled { + hide_swipe_type_manager(self.layout_panels + .get_mut(self.active_layout) + .unwrap() + ) + } } fn get_effective_keymap(&mut self) -> anyhow::Result { diff --git a/wlx-common/src/config.rs b/wlx-common/src/config.rs index c375b310..1878df81 100644 --- a/wlx-common/src/config.rs +++ b/wlx-common/src/config.rs @@ -328,6 +328,6 @@ pub struct GeneralConfig { #[serde(default = "def_one")] pub grid_opacity: f32, - #[serde(default = "def_true")] + #[serde(default = "def_false")] pub keyboard_swipe_to_type_enabled: bool, }