From e204fb87defec1897b4dba10c3a3b3ad6ff78190 Mon Sep 17 00:00:00 2001 From: CheerfulPianissimo Date: Fri, 16 Aug 2024 23:04:11 +0530 Subject: [PATCH] [fix] remove hardcoded GPU path from libwayshot constructor --- libwayshot/examples/waymirror-egl/src/state.rs | 6 +++++- libwayshot/examples/waymirror.rs | 3 ++- libwayshot/src/lib.rs | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libwayshot/examples/waymirror-egl/src/state.rs b/libwayshot/examples/waymirror-egl/src/state.rs index 2f93c612..81dc501d 100644 --- a/libwayshot/examples/waymirror-egl/src/state.rs +++ b/libwayshot/examples/waymirror-egl/src/state.rs @@ -70,7 +70,11 @@ impl WaylandEGLState { xdg_surface: None, xdg_toplevel: None, wl_compositor: None, - wayshot: WayshotConnection::from_connection_with_dmabuf(server_connection).unwrap(), + wayshot: WayshotConnection::from_connection_with_dmabuf( + server_connection, + "/dev/dri/renderD128", + ) + .unwrap(), }) } diff --git a/libwayshot/examples/waymirror.rs b/libwayshot/examples/waymirror.rs index c89d7cb6..c350131a 100644 --- a/libwayshot/examples/waymirror.rs +++ b/libwayshot/examples/waymirror.rs @@ -18,7 +18,8 @@ fn main() { let display = conn.display(); display.get_registry(&qhandle, ()); - let wayshot = WayshotConnection::from_connection_with_dmabuf(conn).unwrap(); + let wayshot = + WayshotConnection::from_connection_with_dmabuf(conn, "/dev/dri/renderD128").unwrap(); let mut state = State { wayshot, diff --git a/libwayshot/src/lib.rs b/libwayshot/src/lib.rs index 4f6e9bcd..e76bf770 100644 --- a/libwayshot/src/lib.rs +++ b/libwayshot/src/lib.rs @@ -109,11 +109,11 @@ impl WayshotConnection { Ok(initial_state) } - pub fn from_connection_with_dmabuf(conn: Connection) -> Result { + pub fn from_connection_with_dmabuf(conn: Connection, device_path: &str) -> Result { let (globals, evq) = registry_queue_init::(&conn)?; let linux_dmabuf = globals.bind(&evq.handle(), 4..=ZwpLinuxDmabufV1::interface().version, ())?; - let gpu = dispatch::Card::open("/dev/dri/renderD128"); + let gpu = dispatch::Card::open(device_path); // init a GBM device let gbm = GBMDevice::new(gpu).unwrap(); let mut initial_state = Self {