Desktop: Have CEF use Wayland if available (#2945)
tell cef to use wayland if available Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
516e612b4a
commit
7bdf1670b5
|
|
@ -1,3 +1,5 @@
|
|||
use std::env;
|
||||
|
||||
use cef::rc::{Rc, RcImpl};
|
||||
use cef::sys::{_cef_app_t, cef_base_ref_counted_t};
|
||||
use cef::{BrowserProcessHandler, CefString, ImplApp, ImplCommandLine, SchemeRegistrar, WrapApp};
|
||||
|
|
@ -34,6 +36,20 @@ impl<H: CefEventHandler + Clone> ImplApp for AppImpl<H> {
|
|||
// Disable GPU acceleration, because it is not supported for Offscreen Rendering and can cause crashes.
|
||||
cmd.append_switch(Some(&CefString::from("disable-gpu")));
|
||||
cmd.append_switch(Some(&CefString::from("disable-gpu-compositing")));
|
||||
|
||||
// Tell CEF to use Wayland if available
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
{
|
||||
let use_wayland = env::var("WAYLAND_DISPLAY")
|
||||
.ok()
|
||||
.filter(|var| !var.is_empty())
|
||||
.or_else(|| env::var("WAYLAND_SOCKET").ok())
|
||||
.filter(|var| !var.is_empty())
|
||||
.is_some();
|
||||
if use_wayland {
|
||||
cmd.append_switch_with_value(Some(&CefString::from("ozone-platform")), Some(&CefString::from("wayland")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue