mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-03-11 17:15:49 +00:00
disable gpu option
This commit is contained in:
parent
83ace5827f
commit
8c6c0bfd06
3 changed files with 13 additions and 1 deletions
|
|
@ -25,6 +25,8 @@ struct Opt {
|
||||||
start_hidden: bool,
|
start_hidden: bool,
|
||||||
#[clap(long, help = "Enable dev tools when pressing F12")]
|
#[clap(long, help = "Enable dev tools when pressing F12")]
|
||||||
dev_tools: bool,
|
dev_tools: bool,
|
||||||
|
#[clap(long, help = "Use software rendering for the webview")]
|
||||||
|
disable_gpu: bool,
|
||||||
#[clap(long, help = "Disable the server and load the WebUI from localhost")]
|
#[clap(long, help = "Disable the server and load the WebUI from localhost")]
|
||||||
development: bool,
|
development: bool,
|
||||||
#[clap(long, help = "Shortcut for --webui-url=https://staging.strem.io/")]
|
#[clap(long, help = "Shortcut for --webui-url=https://staging.strem.io/")]
|
||||||
|
|
@ -93,6 +95,7 @@ fn main() {
|
||||||
commands_path: Some(commands_path),
|
commands_path: Some(commands_path),
|
||||||
webui_url,
|
webui_url,
|
||||||
dev_tools: opt.development || opt.dev_tools,
|
dev_tools: opt.development || opt.dev_tools,
|
||||||
|
disable_gpu: opt.disable_gpu,
|
||||||
start_hidden: opt.start_hidden,
|
start_hidden: opt.start_hidden,
|
||||||
autoupdater_endpoint: opt.autoupdater_endpoint,
|
autoupdater_endpoint: opt.autoupdater_endpoint,
|
||||||
force_update: opt.force_update,
|
force_update: opt.force_update,
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ pub struct MainWindow {
|
||||||
pub commands_path: Option<String>,
|
pub commands_path: Option<String>,
|
||||||
pub webui_url: String,
|
pub webui_url: String,
|
||||||
pub dev_tools: bool,
|
pub dev_tools: bool,
|
||||||
|
pub disable_gpu: bool,
|
||||||
pub start_hidden: bool,
|
pub start_hidden: bool,
|
||||||
pub autoupdater_endpoint: Option<Url>,
|
pub autoupdater_endpoint: Option<Url>,
|
||||||
pub force_update: bool,
|
pub force_update: bool,
|
||||||
|
|
@ -111,6 +112,7 @@ impl MainWindow {
|
||||||
fn on_init(&self) {
|
fn on_init(&self) {
|
||||||
self.webview.endpoint.set(self.webui_url.clone()).ok();
|
self.webview.endpoint.set(self.webui_url.clone()).ok();
|
||||||
self.webview.dev_tools.set(self.dev_tools).ok();
|
self.webview.dev_tools.set(self.dev_tools).ok();
|
||||||
|
self.webview.disable_gpu.set(self.disable_gpu).ok();
|
||||||
if let Some(hwnd) = self.window.handle.hwnd() {
|
if let Some(hwnd) = self.window.handle.hwnd() {
|
||||||
if let Ok(mut saved_style) = self.saved_window_style.try_borrow_mut() {
|
if let Ok(mut saved_style) = self.saved_window_style.try_borrow_mut() {
|
||||||
saved_style.center_window(hwnd, WINDOW_MIN_WIDTH, WINDOW_MIN_HEIGHT);
|
saved_style.center_window(hwnd, WINDOW_MIN_WIDTH, WINDOW_MIN_HEIGHT);
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ use winapi::um::winuser::{GetClientRect, WM_SETFOCUS};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct WebView {
|
pub struct WebView {
|
||||||
|
pub disable_gpu: Rc<OnceCell<bool>>,
|
||||||
pub endpoint: Rc<OnceCell<String>>,
|
pub endpoint: Rc<OnceCell<String>>,
|
||||||
pub dev_tools: Rc<OnceCell<bool>>,
|
pub dev_tools: Rc<OnceCell<bool>>,
|
||||||
pub controller: Rc<OnceCell<Controller>>,
|
pub controller: Rc<OnceCell<Controller>>,
|
||||||
|
|
@ -69,8 +70,14 @@ impl PartialUi for WebView {
|
||||||
let controller_clone = data.controller.clone();
|
let controller_clone = data.controller.clone();
|
||||||
let endpoint = data.endpoint.clone();
|
let endpoint = data.endpoint.clone();
|
||||||
let dev_tools = data.dev_tools.clone();
|
let dev_tools = data.dev_tools.clone();
|
||||||
|
let webview_flags = "--disable-web-security --autoplay-policy=no-user-gesture-required --disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection";
|
||||||
|
let webview_flags = if *data.disable_gpu.get().unwrap() {
|
||||||
|
format!("{} {}", webview_flags, "--disable-gpu")
|
||||||
|
} else {
|
||||||
|
webview_flags.to_string()
|
||||||
|
};
|
||||||
let result = webview2::EnvironmentBuilder::new()
|
let result = webview2::EnvironmentBuilder::new()
|
||||||
.with_additional_browser_arguments("--disable-web-security --autoplay-policy=no-user-gesture-required --disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection")
|
.with_additional_browser_arguments(&webview_flags)
|
||||||
.build(move |env| {
|
.build(move |env| {
|
||||||
env.expect("Cannot obtain webview environment")
|
env.expect("Cannot obtain webview environment")
|
||||||
.create_controller(hwnd, move |controller| {
|
.create_controller(hwnd, move |controller| {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue