-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix raw window handle pub #1359
Conversation
I don't understand how this is necessary? If you add raw-window-handle in your external project's Cargo.toml, it will use the same version if it's compatible, and you should be able to use the traits normally then, should you not? |
Hi @Cobrand [package]
name = "test_sdl2_raw"
version = "0.1.0"
edition = "2021"
[dependencies]
sdl2 = {version = "0.35.0", features = ["bundled", "raw-window-handle"]} And with this code: use sdl2::raw_window_handle::RawWindowHandle;
fn main() {
println!("Hello, world!");
} I have this result:
So I won't be able to use functions associated to this trait. (so no raw handles) |
[dependencies]
sdl2 = {version = "0.35.0", features = ["bundled", "raw-window-handle"]}
raw-window-handle = "0.5" then use raw_window_handle::RawWindowHandle; doesn't this work? You are rarely supposed to use raw-window-handle by yourself anyway, it almost always interops with something else (OpenGL, vulkan, DirectX, ...), which almost imports raw-window-handle, so I don't see why it would be our job to re-export this trait. |
Nop: it doesn't work and I don't really understand why. Cargo.toml: [package]
name = "test_sdl2_raw"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
sdl2 = {version = "0.35.0", features = ["bundled", "raw-window-handle"]}
raw-window-handle = "0.5" And the source: use raw_window_handle::RawWindowHandle;
use raw_window_handle::HasRawWindowHandle;
fn main() {
let sdl = sdl2::init().expect("xx");
let video_subsystem = sdl
.video().expect("xx");
let clipboard = video_subsystem.clipboard();
let gl_attr = video_subsystem.gl_attr();
let mut builder =
sdl2::video::WindowBuilder::new(&video_subsystem, "test", 800, 600);
let builder = builder.opengl().allow_highdpi();
let window = builder.build().expect("Cannot build window");
if let RawWindowHandle::Xlib(handle) = window.raw_window_handle() {
println!("Raw handle {:?}", handle);
}
} I have the following error:
What is interesting is that the compiler:
It make me thinks that it's a bit like the same error when you have a version of crate used in a sub module and you use the same crate but with a different version. The compiler doesn't mix those object. Have you got an example of a code which uses raw handles from a program outside of the crate sdl2 itself? |
You are using rust-sdl2 0.35.0, which uses a different version of raw-window-handle. Try updating to rust-sdl2 0.36, or downgrading raw-window-handle. |
Oh! |
If an end user wants to use raw handles, the trait must be defined as public to be included in external projects.