Skip to content

Commit 7bdf167

Browse files
Desktop: Have CEF use Wayland if available (#2945)
tell cef to use wayland if available Co-authored-by: Keavon Chambers <[email protected]>
1 parent 516e612 commit 7bdf167

File tree

1 file changed

+16
-0
lines changed
  • desktop/src/cef/internal

1 file changed

+16
-0
lines changed

desktop/src/cef/internal/app.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::env;
2+
13
use cef::rc::{Rc, RcImpl};
24
use cef::sys::{_cef_app_t, cef_base_ref_counted_t};
35
use cef::{BrowserProcessHandler, CefString, ImplApp, ImplCommandLine, SchemeRegistrar, WrapApp};
@@ -34,6 +36,20 @@ impl<H: CefEventHandler + Clone> ImplApp for AppImpl<H> {
3436
// Disable GPU acceleration, because it is not supported for Offscreen Rendering and can cause crashes.
3537
cmd.append_switch(Some(&CefString::from("disable-gpu")));
3638
cmd.append_switch(Some(&CefString::from("disable-gpu-compositing")));
39+
40+
// Tell CEF to use Wayland if available
41+
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
42+
{
43+
let use_wayland = env::var("WAYLAND_DISPLAY")
44+
.ok()
45+
.filter(|var| !var.is_empty())
46+
.or_else(|| env::var("WAYLAND_SOCKET").ok())
47+
.filter(|var| !var.is_empty())
48+
.is_some();
49+
if use_wayland {
50+
cmd.append_switch_with_value(Some(&CefString::from("ozone-platform")), Some(&CefString::from("wayland")));
51+
}
52+
}
3753
}
3854
}
3955

0 commit comments

Comments
 (0)