Selaa lähdekoodia

app: on linux allow specifying x11 or wayland backend explicitly using CLI args

darkfi 11 kuukautta sitten
vanhempi
sitoutus
a36dfb84e6
4 muutettua tiedostoa jossa 116 lisäystä ja 4 poistoa
  1. 84 0
      bin/app/Cargo.lock
  2. 1 0
      bin/app/Cargo.toml
  3. 2 3
      bin/app/src/gfx/mod.rs
  4. 29 1
      bin/app/src/main.rs

+ 84 - 0
bin/app/Cargo.lock

@@ -148,12 +148,56 @@ dependencies = [
  "winapi",
 ]
 
+[[package]]
+name = "anstream"
+version = "0.6.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192"
+dependencies = [
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "is_terminal_polyfill",
+ "utf8parse",
+]
+
 [[package]]
 name = "anstyle"
 version = "1.0.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
 
+[[package]]
+name = "anstyle-parse"
+version = "0.2.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2"
+dependencies = [
+ "windows-sys 0.60.2",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a"
+dependencies = [
+ "anstyle",
+ "once_cell_polyfill",
+ "windows-sys 0.60.2",
+]
+
 [[package]]
 name = "anyhow"
 version = "1.0.99"
@@ -1012,6 +1056,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "1fc0e74a703892159f5ae7d3aac52c8e6c392f5ae5f359c70b5881d60aaac318"
 dependencies = [
  "clap_builder",
+ "clap_derive",
 ]
 
 [[package]]
@@ -1020,8 +1065,22 @@ version = "4.5.44"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "b3e7f4214277f3c7aa526a59dd3fbe306a370daee1f8b7b8c987069cd8e888a8"
 dependencies = [
+ "anstream",
  "anstyle",
  "clap_lex",
+ "strsim 0.11.1",
+]
+
+[[package]]
+name = "clap_derive"
+version = "4.5.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "14cb31bb0a7d536caef2639baa7fad459e15c3144efefa6dbd1c84562c4739f6"
+dependencies = [
+ "heck 0.5.0",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.106",
 ]
 
 [[package]]
@@ -1053,6 +1112,12 @@ version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
 
+[[package]]
+name = "colorchoice"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
+
 [[package]]
 name = "colored"
 version = "3.0.0"
@@ -1379,6 +1444,7 @@ dependencies = [
  "atomic_float",
  "blake3",
  "chrono",
+ "clap 4.5.45",
  "colored",
  "darkfi",
  "darkfi-serial",
@@ -3069,6 +3135,12 @@ dependencies = [
  "windows-sys 0.59.0",
 ]
 
+[[package]]
+name = "is_terminal_polyfill"
+version = "1.70.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
+
 [[package]]
 name = "itertools"
 version = "0.10.5"
@@ -3696,6 +3768,12 @@ version = "1.21.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
 
+[[package]]
+name = "once_cell_polyfill"
+version = "1.70.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
+
 [[package]]
 name = "oneshot-fused-workaround"
 version = "0.2.3"
@@ -6867,6 +6945,12 @@ version = "1.0.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
 
+[[package]]
+name = "utf8parse"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
+
 [[package]]
 name = "uuid"
 version = "1.18.0"

+ 1 - 0
bin/app/Cargo.toml

@@ -45,6 +45,7 @@ async-gen = "0.2.3"
 async-trait = "0.1.88"
 blake3 = "1.8.2"
 simplelog = "0.12.2"
+clap = { version = "4.5", features = ["derive"] }
 # For log files
 file-rotate = "0.7.6"
 parking_lot = { version = "0.12.4", features = ["nightly"] }

+ 2 - 3
bin/app/src/gfx/mod.rs

@@ -1482,7 +1482,7 @@ impl EventHandler for Stage {
     }
 }
 
-pub fn run_gui() {
+pub fn run_gui(linux_backend: miniquad::conf::LinuxBackend) {
     let mut window_width = 1024;
     let mut window_height = 768;
     if let Ok(mut file) = File::open(get_window_size_filename()) {
@@ -1498,8 +1498,7 @@ pub fn run_gui() {
         high_dpi: true,
         window_resizable: true,
         platform: miniquad::conf::Platform {
-            linux_x11_gl: miniquad::conf::LinuxX11Gl::EGLWithGLXFallback,
-            linux_backend: miniquad::conf::LinuxBackend::WaylandWithX11Fallback,
+            linux_backend,
             #[cfg(target_os = "android")]
             blocking_event_loop: true,
             android_panic_hook: false,

+ 29 - 1
bin/app/src/main.rs

@@ -16,6 +16,7 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
+use clap::Parser;
 use darkfi::system::CondVar;
 use std::sync::{Arc, OnceLock};
 
@@ -442,14 +443,41 @@ pub fn create_darkirc(name: &str) -> SceneNode {
     node
 }
 
+/// Simple program to greet a person
+#[derive(Parser, Debug)]
+#[command(version, about, long_about = None)]
+struct Args {
+    /// On Linux use the X11 backend
+    #[arg(long)]
+    linux_x11_backend: bool,
+
+    /// On Linux use the wayland backend
+    #[arg(long)]
+    linux_wayland_backend: bool,
+}
+
 fn main() {
+    let args = Args::parse();
+
     GOD.get_or_init(God::new);
 
     // Reuse render_api, event_pub and text_shaper
     // No need for setup(), just wait for gfx start then call .start()
     // ZMQ, darkirc stay running
 
-    gfx::run_gui();
+    let linux_backend = if args.linux_wayland_backend {
+        if args.linux_x11_backend {
+            miniquad::conf::LinuxBackend::WaylandWithX11Fallback
+        } else {
+            miniquad::conf::LinuxBackend::WaylandOnly
+        }
+    } else if args.linux_x11_backend {
+        miniquad::conf::LinuxBackend::X11Only
+    } else {
+        miniquad::conf::LinuxBackend::WaylandWithX11Fallback
+    };
+
+    gfx::run_gui(linux_backend);
     debug!(target: "main", "Started GFX backend");
 }