basic scaffolding
This commit is contained in:
parent
a12b10b4bc
commit
e4d51f09a1
3 changed files with 125 additions and 2 deletions
26
Cargo.lock
generated
26
Cargo.lock
generated
|
|
@ -23,6 +23,7 @@ name = "cursor-mover-app"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"wayland-client",
|
||||
"wayland-protocols-wlr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -154,6 +155,31 @@ dependencies = [
|
|||
"wayland-scanner",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wayland-protocols"
|
||||
version = "0.32.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baeda9ffbcfc8cd6ddaade385eaf2393bd2115a69523c735f12242353c3df4f3"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"wayland-backend",
|
||||
"wayland-client",
|
||||
"wayland-scanner",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wayland-protocols-wlr"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9597cdf02cf0c34cd5823786dce6b5ae8598f05c2daf5621b6e178d4f7345f3"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"wayland-backend",
|
||||
"wayland-client",
|
||||
"wayland-protocols",
|
||||
"wayland-scanner",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wayland-scanner"
|
||||
version = "0.31.8"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ readme = "README.md"
|
|||
|
||||
[dependencies]
|
||||
wayland-client = "0.31.12"
|
||||
wayland-protocols-wlr = { version = "0.3.10", features = ["client"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -1,3 +1,99 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use wayland_client::{Connection, Dispatch, Proxy, QueueHandle, protocol::wl_registry};
|
||||
use wayland_protocols_wlr::virtual_pointer::v1::client::{
|
||||
zwlr_virtual_pointer_manager_v1::ZwlrVirtualPointerManagerV1,
|
||||
zwlr_virtual_pointer_v1::ZwlrVirtualPointerV1,
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
struct AppData {
|
||||
virtual_pointer: Option<ZwlrVirtualPointerV1>,
|
||||
}
|
||||
|
||||
impl Dispatch<ZwlrVirtualPointerV1, ()> for AppData {
|
||||
fn event(
|
||||
state: &mut Self,
|
||||
proxy: &ZwlrVirtualPointerV1,
|
||||
event: <ZwlrVirtualPointerV1 as Proxy>::Event,
|
||||
data: &(),
|
||||
conn: &Connection,
|
||||
qhandle: &QueueHandle<Self>,
|
||||
) {
|
||||
println!("VPointerData");
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<ZwlrVirtualPointerManagerV1, ()> for AppData {
|
||||
fn event(
|
||||
state: &mut Self,
|
||||
proxy: &ZwlrVirtualPointerManagerV1,
|
||||
event: <ZwlrVirtualPointerManagerV1 as Proxy>::Event,
|
||||
data: &(),
|
||||
conn: &Connection,
|
||||
qhandle: &QueueHandle<Self>,
|
||||
) {
|
||||
println!("ZwlrEvent")
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<wl_registry::WlRegistry, ()> for AppData {
|
||||
fn event(
|
||||
app_data: &mut Self,
|
||||
registry: &wl_registry::WlRegistry,
|
||||
event: wl_registry::Event,
|
||||
_: &(),
|
||||
_: &Connection,
|
||||
queue_handle: &QueueHandle<AppData>,
|
||||
) {
|
||||
// When receiving events from the wl_registry, we are only interested in the
|
||||
// `global` event, which signals a new available global.
|
||||
// When receiving this event, we just print its characteristics in this example.
|
||||
if let wl_registry::Event::Global {
|
||||
name,
|
||||
interface,
|
||||
version,
|
||||
} = event
|
||||
{
|
||||
//println!("[{name}] {interface} (v{version})");
|
||||
|
||||
if interface.as_str() == "zwlr_virtual_pointer_manager_v1" {
|
||||
app_data.virtual_pointer.get_or_insert_with(|| {
|
||||
let manager = registry.bind::<ZwlrVirtualPointerManagerV1, _, _>(
|
||||
name,
|
||||
version,
|
||||
queue_handle,
|
||||
(),
|
||||
);
|
||||
|
||||
let pointer = manager.create_virtual_pointer(None, queue_handle, ());
|
||||
|
||||
println!("Virtual pointer manager created");
|
||||
pointer
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let connection = Connection::connect_to_env().unwrap();
|
||||
let display = connection.display();
|
||||
|
||||
let mut event_queue = connection.new_event_queue();
|
||||
let queue_handle = event_queue.handle();
|
||||
let _registry = display.get_registry(&queue_handle, ());
|
||||
println!("Advertized globals:");
|
||||
|
||||
let mut appdata = AppData::default();
|
||||
event_queue.roundtrip(&mut appdata).unwrap();
|
||||
|
||||
loop {
|
||||
let dispatched = event_queue.dispatch_pending(&mut appdata).unwrap();
|
||||
if dispatched == 0 {
|
||||
event_queue.flush().unwrap();
|
||||
}
|
||||
|
||||
if let Some(pointer) = &appdata.virtual_pointer {
|
||||
println!("Moving pointer?")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue