Add feature flags for x11 and wayland

Winit has features for these, so it makes sense to offer the same.
This commit is contained in:
Ian Douglas Scott 2022-12-21 16:20:15 -08:00
parent 80b45a9a68
commit c73bd4b836
2 changed files with 13 additions and 8 deletions

View file

@ -9,9 +9,9 @@ extern crate core;
mod win32;
#[cfg(target_os = "macos")]
mod cg;
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "freebsd")))]
mod x11;
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(all(feature = "wayland", any(target_os = "linux", target_os = "freebsd")))]
mod wayland;
#[cfg(target_arch = "wasm32")]
mod web;
@ -49,9 +49,9 @@ impl GraphicsContext {
/// lifetime of the GraphicsContext
pub unsafe fn from_raw(raw_window_handle: RawWindowHandle, raw_display_handle: RawDisplayHandle) -> Result<Self, SwBufError> {
let imple: Box<dyn GraphicsContextImpl> = match (raw_window_handle, raw_display_handle) {
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "freebsd")))]
(RawWindowHandle::Xlib(xlib_window_handle), RawDisplayHandle::Xlib(xlib_display_handle)) => Box::new(x11::X11Impl::new(xlib_window_handle, xlib_display_handle)?),
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(all(feature = "wayland", any(target_os = "linux", target_os = "freebsd")))]
(RawWindowHandle::Wayland(wayland_window_handle), RawDisplayHandle::Wayland(wayland_display_handle)) => Box::new(wayland::WaylandImpl::new(wayland_window_handle, wayland_display_handle)?),
#[cfg(target_os = "windows")]
(RawWindowHandle::Win32(win32_handle), _) => Box::new(win32::Win32Impl::new(&win32_handle)?),