mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-09-20 19:31:05 +03:00
disable example without wlroots
This commit is contained in:
@@ -6,6 +6,10 @@ edition = "2021"
|
|||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
repository = "https://github.com/feschber/lan-mouse"
|
repository = "https://github.com/feschber/lan-mouse"
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "keymap_fd_churn"
|
||||||
|
required-features = ["wlroots"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = "0.1.80"
|
async-trait = "0.1.80"
|
||||||
futures = "0.3.28"
|
futures = "0.3.28"
|
||||||
|
|||||||
@@ -24,22 +24,28 @@
|
|||||||
//! Motion events are sent with dx and dy of zero so the example never moves the real
|
//! Motion events are sent with dx and dy of zero so the example never moves the real
|
||||||
//! cursor.
|
//! cursor.
|
||||||
|
|
||||||
|
#[cfg(wlroots)]
|
||||||
use input_emulation::{Backend, EmulationHandle, InputEmulation};
|
use input_emulation::{Backend, EmulationHandle, InputEmulation};
|
||||||
|
#[cfg(wlroots)]
|
||||||
use input_event::{Event, PointerEvent};
|
use input_event::{Event, PointerEvent};
|
||||||
|
|
||||||
/// number of simulated peer reconnects
|
/// number of simulated peer reconnects
|
||||||
|
#[cfg(wlroots)]
|
||||||
const ITERATIONS: u64 = 2000;
|
const ITERATIONS: u64 = 2000;
|
||||||
|
|
||||||
/// how often to sample the descriptor count
|
/// how often to sample the descriptor count
|
||||||
|
#[cfg(wlroots)]
|
||||||
const SAMPLE_EVERY: u64 = 100;
|
const SAMPLE_EVERY: u64 = 100;
|
||||||
|
|
||||||
/// counts open descriptors of this process.
|
/// counts open descriptors of this process.
|
||||||
/// returns None rather than 0 when the count itself fails for lack of a descriptor,
|
/// returns None rather than 0 when the count itself fails for lack of a descriptor,
|
||||||
/// so an exhausted process is never reported as using none.
|
/// so an exhausted process is never reported as using none.
|
||||||
|
#[cfg(wlroots)]
|
||||||
fn open_fds() -> Option<usize> {
|
fn open_fds() -> Option<usize> {
|
||||||
std::fs::read_dir("/proc/self/fd").ok().map(|d| d.count())
|
std::fs::read_dir("/proc/self/fd").ok().map(|d| d.count())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(wlroots)]
|
||||||
fn fds_display(fds: Option<usize>) -> String {
|
fn fds_display(fds: Option<usize>) -> String {
|
||||||
match fds {
|
match fds {
|
||||||
Some(n) => n.to_string(),
|
Some(n) => n.to_string(),
|
||||||
@@ -47,6 +53,7 @@ fn fds_display(fds: Option<usize>) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(wlroots)]
|
||||||
fn main() {
|
fn main() {
|
||||||
let runtime = tokio::runtime::Builder::new_current_thread()
|
let runtime = tokio::runtime::Builder::new_current_thread()
|
||||||
.enable_all()
|
.enable_all()
|
||||||
@@ -130,3 +137,10 @@ fn main() {
|
|||||||
emulation.terminate().await;
|
emulation.terminate().await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(wlroots))]
|
||||||
|
fn main() {
|
||||||
|
eprintln!("this example requires the wlroots backend, which is only built on");
|
||||||
|
eprintln!("unix targets other than macos with the `wlroots` feature enabled");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user