From 2c7397b27ccb2efd4589bb364e611a80635413c8 Mon Sep 17 00:00:00 2001 From: Fabian-Lars Date: Wed, 11 Sep 2024 15:42:30 +0200 Subject: [PATCH] fix(linux): Use c_ulong for ffi calls instead of u64 (#106) --- .changes/fix-linux-32bit.md | 5 +++++ src/platform_impl/x11/mod.rs | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changes/fix-linux-32bit.md diff --git a/.changes/fix-linux-32bit.md b/.changes/fix-linux-32bit.md new file mode 100644 index 0000000..a2a3d8b --- /dev/null +++ b/.changes/fix-linux-32bit.md @@ -0,0 +1,5 @@ +--- +global-hotkey: patch +--- + +Fixed an issue causing compilation to fail for 32-bit targets. diff --git a/src/platform_impl/x11/mod.rs b/src/platform_impl/x11/mod.rs index 33acc5a..3c4b449 100644 --- a/src/platform_impl/x11/mod.rs +++ b/src/platform_impl/x11/mod.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use std::{collections::BTreeMap, ptr}; +use std::{collections::BTreeMap, ffi::c_ulong, ptr}; use crossbeam_channel::{unbounded, Receiver, Sender}; use keyboard_types::{Code, Modifiers}; @@ -105,7 +105,7 @@ const IGNORED_MODS: [u32; 4] = [ fn register_hotkey( xlib: &Xlib, display: *mut _XDisplay, - root: u64, + root: c_ulong, hotkeys: &mut BTreeMap>, hotkey: HotKey, ) -> crate::Result<()> { @@ -159,7 +159,7 @@ fn register_hotkey( fn unregister_hotkey( xlib: &Xlib, display: *mut _XDisplay, - root: u64, + root: c_ulong, hotkeys: &mut BTreeMap>, hotkey: HotKey, ) -> crate::Result<()> { @@ -189,7 +189,7 @@ fn events_processor(thread_rx: Receiver) { if let Ok(xlib) = xlib::Xlib::open() { unsafe { let display = (xlib.XOpenDisplay)(ptr::null()); - let root = (xlib.XDefaultRootWindow)(display); + let root: c_ulong = (xlib.XDefaultRootWindow)(display); // Only trigger key release at end of repeated keys let mut supported_rtrn: i32 = 0;