fix(inject): fix wrong char type that prevented compilation on ARM. Fix #801

This commit is contained in:
Federico Terzi 2021-11-06 10:10:04 +01:00
parent ac208ecf02
commit 98ef10716c

View File

@ -1,7 +1,7 @@
// This code is a port of the libxkbcommon "interactive-evdev.c" example // This code is a port of the libxkbcommon "interactive-evdev.c" example
// https://github.com/xkbcommon/libxkbcommon/blob/master/tools/interactive-evdev.c // https://github.com/xkbcommon/libxkbcommon/blob/master/tools/interactive-evdev.c
use std::ffi::CStr; use std::{ffi::CStr, os::raw::c_char};
use scopeguard::ScopeGuard; use scopeguard::ScopeGuard;
@ -48,17 +48,17 @@ impl State {
} }
pub fn get_string(&self, code: u32) -> Option<String> { pub fn get_string(&self, code: u32) -> Option<String> {
let mut buffer: [u8; 16] = [0; 16]; let mut buffer: [c_char; 16] = [0; 16];
let len = unsafe { let len = unsafe {
xkb_state_key_get_utf8( xkb_state_key_get_utf8(
self.state, self.state,
code, code,
buffer.as_mut_ptr() as *mut i8, buffer.as_mut_ptr(),
std::mem::size_of_val(&buffer), std::mem::size_of_val(&buffer),
) )
}; };
if len > 0 { if len > 0 {
let content_raw = unsafe { CStr::from_ptr(buffer.as_ptr() as *mut i8) }; let content_raw = unsafe { CStr::from_ptr(buffer.as_ptr()) };
let string = content_raw.to_string_lossy().to_string(); let string = content_raw.to_string_lossy().to_string();
if string.is_empty() { if string.is_empty() {
None None