Skip to content

Commit

Permalink
Intelligently enable Wayland in SDL
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlcctrlv committed Mar 13, 2023
1 parent e1cadb8 commit bd588ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
File renamed without changes.
7 changes: 7 additions & 0 deletions src/user_interface/sdl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ impl Interface {
filename: &str,
viewport: &mut Viewport,
) -> (Sdl, Window, RCHandle<GrDirectContext>, GLContext) {
const WL_ENV: &'static str = "WAYLAND_DISPLAY";
if let Some(_) = std::env::var_os(WL_ENV) {
let (k, v) = ("SDL_VIDEODRIVER", "wayland");
std::env::set_var(k, v);
log::info!("Setting {k} to {v} as we see in env {}={}. If this fails, set {k} to `x11`!", WL_ENV, std::env::var(WL_ENV).unwrap());
}

// SDL initialization
let sdl_context = sdl2::init().expect("Failed to initialize sdl2");
let video_subsystem = sdl_context
Expand Down

0 comments on commit bd588ab

Please sign in to comment.