Crates.io | yaxi |
lib.rs | yaxi |
version | 0.1.47 |
source | src |
created_at | 2024-10-02 14:21:47.117572 |
updated_at | 2024-11-10 18:21:36.831007 |
description | A rust implementation of the x11 protocol |
homepage | |
repository | https://github.com/proxin187/yaxi |
max_upload_size | |
id | 1394117 |
size | 424,399 |
This example opens a window and waits for a keyboard press before it quits:
use yaxi::window::{WindowArguments, ValuesBuilder, WindowKind};
use yaxi::proto::{Event, WindowClass, EventMask};
use yaxi::display;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut display = display::open(None)?;
let mut root = display.default_root_window()?;
let mut window = root.create_window(WindowArguments {
depth: root.depth(),
x: 5,
y: 5,
width: 80,
height: 50,
border_width: 15,
class: WindowClass::InputOutput,
visual: root.visual(),
values: ValuesBuilder::new(vec![]),
})?;
window.select_input(&[EventMask::KeyPress, EventMask::KeyRelease])?;
window.map(WindowKind::Window)?;
let event = display.next_event()?;
match event {
Event::KeyEvent { kind, coordinates, window, root, subwindow, state, keycode, send_event } => {
let window_copy = display.window_from_id(window)?;
println!("window from id: {}, keycode: {}", window_copy.id(), keycode);
},
_ => {},
}
window.destroy(WindowKind::Window)?;
Ok(())
}
Yaxi is licensed under the MIT License.