Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

// Automatically sets environment variables to work around issues with WebKitGTK on NVIDIA cards.
// When running in Wayland, it sets __NV_DISABLE_EXPLICIT_SYNC to 1
// When running in X11, it sets WEBKIT_DISABLE_COMPOSITING_MODE to 1
#[cfg(target_os = "linux")]
fn fix_nvidia() {
let variable = match std::env::var("GDK_BACKEND") {
Ok(val) => {
match val.as_str() {
"wayland" => "__NV_DISABLE_EXPLICIT_SYNC",
_ => "WEBKIT_DISABLE_COMPOSITING_MODE" // if GDK_BACKEND is not "wayland", assume X11 is in use
}
},
Err(_) => "WEBKIT_DISABLE_COMPOSITING_MODE" // if GDK_BACKEND is blank, assume X11 is in use
};

// SAFETY: There is no other thread where this is ran.
unsafe {
std::env::set_var(variable, "1");
}
}

fn main() {
#[cfg(target_os = "linux")]
fix_nvidia();

modfriend_lib::run()
}
Loading