mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2024-12-25 09:59:21 +01:00
Add xkbconfig to API
This commit is contained in:
parent
e19601e771
commit
2a13e736e4
4 changed files with 65 additions and 1 deletions
|
@ -26,6 +26,13 @@ local buttons = {
|
|||
back = 0x116,
|
||||
}
|
||||
|
||||
---@class XkbConfig
|
||||
---@field rules string?
|
||||
---@field model string?
|
||||
---@field layout string?
|
||||
---@field variant string?
|
||||
---@field options string?
|
||||
|
||||
---Input management.
|
||||
---
|
||||
---This module provides utilities to set keybinds.
|
||||
|
@ -114,4 +121,23 @@ function input_module.mousebind(modifiers, button, edge, action)
|
|||
})
|
||||
end
|
||||
|
||||
---Set the xkbconfig for your input device.
|
||||
---
|
||||
---Fields not present will be set to their default values.
|
||||
---
|
||||
---### Example
|
||||
---```lua
|
||||
---input.set_xkb_config({
|
||||
--- layout = "us,fr,ge",
|
||||
--- options = "ctrl:swapcaps,caps:shift"
|
||||
---})
|
||||
---```
|
||||
---
|
||||
---@param xkb_config XkbConfig
|
||||
function input_module.set_xkb_config(xkb_config)
|
||||
SendMsg({
|
||||
SetXkbConfig = xkb_config,
|
||||
})
|
||||
end
|
||||
|
||||
return input_module
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
--
|
||||
---@field Spawn { command: string[], callback_id: integer? }?
|
||||
---@field SetEnv { key: string, value: string }?
|
||||
---@field Request Request?
|
||||
--Tags
|
||||
---@field ToggleTag { tag_id: TagId }?
|
||||
---@field SwitchToTag { tag_id: TagId }?
|
||||
|
@ -29,6 +28,9 @@
|
|||
--Outputs
|
||||
---@field ConnectForAllOutputs { callback_id: integer }?
|
||||
---@field SetOutputLocation { output_name: OutputName, x: integer?, y: integer? }?
|
||||
--Input
|
||||
---@field SetXkbConfig XkbConfig?
|
||||
---@field Request Request?
|
||||
|
||||
---@alias Msg _Msg | "Quit"
|
||||
|
||||
|
|
|
@ -134,6 +134,20 @@ pub enum Msg {
|
|||
/// Quit the compositor.
|
||||
Quit,
|
||||
|
||||
// Input management
|
||||
SetXkbConfig {
|
||||
#[serde(default)]
|
||||
rules: Option<String>,
|
||||
#[serde(default)]
|
||||
variant: Option<String>,
|
||||
#[serde(default)]
|
||||
layout: Option<String>,
|
||||
#[serde(default)]
|
||||
model: Option<String>,
|
||||
#[serde(default)]
|
||||
options: Option<String>,
|
||||
},
|
||||
|
||||
Request {
|
||||
request_id: RequestId,
|
||||
request: Request,
|
||||
|
|
|
@ -4,6 +4,7 @@ use async_process::Stdio;
|
|||
use futures_lite::AsyncBufReadExt;
|
||||
use smithay::{
|
||||
desktop::space::SpaceElement,
|
||||
input::keyboard::XkbConfig,
|
||||
reexports::wayland_protocols::xdg::shell::server::xdg_toplevel::ResizeEdge,
|
||||
utils::{Point, Rectangle, SERIAL_COUNTER},
|
||||
wayland::{compositor, shell::xdg::XdgToplevelSurfaceData},
|
||||
|
@ -349,6 +350,27 @@ impl State {
|
|||
self.loop_signal.stop();
|
||||
}
|
||||
|
||||
Msg::SetXkbConfig {
|
||||
rules,
|
||||
variant,
|
||||
layout,
|
||||
model,
|
||||
options,
|
||||
} => {
|
||||
let new_config = XkbConfig {
|
||||
rules: &rules.unwrap_or_default(),
|
||||
model: &model.unwrap_or_default(),
|
||||
layout: &layout.unwrap_or_default(),
|
||||
variant: &variant.unwrap_or_default(),
|
||||
options,
|
||||
};
|
||||
if let Some(kb) = self.seat.get_keyboard() {
|
||||
if let Err(err) = kb.set_xkb_config(self, new_config) {
|
||||
tracing::error!("Failed to set xkbconfig: {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Msg::Request {
|
||||
request_id,
|
||||
request,
|
||||
|
|
Loading…
Reference in a new issue