tony / oxwm

Switched from RandR to Xinerama for monitor detection to match dwm's Browse files
approach. Removed OXWM_MODKEY env var since --config flag handles
  different configs better. Moved test-config.ron into repo for version
  control. Fixed monitor-specific window operations to prevent actions
  from crossing monitor boundaries.
tonybtw committed 2025-10-21 parent 7604855 commit bc73085280a7397e2f3266ac85e8a938874443d9
Showing 7 changed files with 253 additions and 205 deletions. UnifiedSplit
+44 −108 Cargo.lock
@@ -13,9 +13,9 @@ dependencies = [
13 13
14 14 [[package]]
15 15 name = "anyhow"
16 -version = "1.0.99"
16 +version = "1.0.100"
17 17 source = "registry+https://github.com/rust-lang/crates.io-index"
18 -checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100"
18 +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
19 19
20 20 [[package]]
21 21 name = "autocfg"
@@ -31,11 +31,11 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
31 31
32 32 [[package]]
33 33 name = "bitflags"
34 -version = "2.9.4"
34 +version = "2.10.0"
35 35 source = "registry+https://github.com/rust-lang/crates.io-index"
36 -checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394"
36 +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
37 37 dependencies = [
38 - "serde",
38 + "serde_core",
39 39 ]
40 40
41 41 [[package]]
@@ -46,9 +46,9 @@ checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
46 46
47 47 [[package]]
48 48 name = "cc"
49 -version = "1.2.40"
49 +version = "1.2.41"
50 50 source = "registry+https://github.com/rust-lang/crates.io-index"
51 -checksum = "e1d05d92f4b1fd76aad469d46cdd858ca761576082cd37df81416691e50199fb"
51 +checksum = "ac9fe6cdbb24b6ade63616c0a0688e45bb56732262c158df3c0c4bea4ca47cb7"
52 52 dependencies = [
53 53 "find-msvc-tools",
54 54 "shlex",
@@ -56,9 +56,9 @@ dependencies = [
56 56
57 57 [[package]]
58 58 name = "cfg-if"
59 -version = "1.0.3"
59 +version = "1.0.4"
60 60 source = "registry+https://github.com/rust-lang/crates.io-index"
61 -checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
61 +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
62 62
63 63 [[package]]
64 64 name = "chrono"
@@ -107,23 +107,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
107 107 checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
108 108 dependencies = [
109 109 "libc",
110 - "windows-sys 0.61.0",
110 + "windows-sys 0.61.2",
111 111 ]
112 112
113 113 [[package]]
114 114 name = "find-msvc-tools"
115 -version = "0.1.3"
115 +version = "0.1.4"
116 116 source = "registry+https://github.com/rust-lang/crates.io-index"
117 -checksum = "0399f9d26e5191ce32c498bebd31e7a3ceabc2745f0ac54af3f335126c3f24b3"
117 +checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127"
118 118
119 119 [[package]]
120 120 name = "gethostname"
121 -version = "1.0.2"
121 +version = "1.1.0"
122 122 source = "registry+https://github.com/rust-lang/crates.io-index"
123 -checksum = "fc257fdb4038301ce4b9cd1b3b51704509692bb3ff716a410cbd07925d9dae55"
123 +checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8"
124 124 dependencies = [
125 125 "rustix",
126 - "windows-targets 0.52.6",
126 + "windows-link",
127 127 ]
128 128
129 129 [[package]]
@@ -173,9 +173,9 @@ dependencies = [
173 173
174 174 [[package]]
175 175 name = "libc"
176 -version = "0.2.175"
176 +version = "0.2.177"
177 177 source = "registry+https://github.com/rust-lang/crates.io-index"
178 -checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
178 +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
179 179
180 180 [[package]]
181 181 name = "libredox"
@@ -290,7 +290,7 @@ dependencies = [
290 290 "errno",
291 291 "libc",
292 292 "linux-raw-sys",
293 - "windows-sys 0.61.0",
293 + "windows-sys 0.61.2",
294 294 ]
295 295
296 296 [[package]]
@@ -337,9 +337,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
337 337
338 338 [[package]]
339 339 name = "syn"
340 -version = "2.0.106"
340 +version = "2.0.107"
341 341 source = "registry+https://github.com/rust-lang/crates.io-index"
342 -checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
342 +checksum = "2a26dbd934e5451d21ef060c018dae56fc073894c5a7896f882928a76e6d081b"
343 343 dependencies = [
344 344 "proc-macro2",
345 345 "quote",
@@ -368,9 +368,9 @@ dependencies = [
368 368
369 369 [[package]]
370 370 name = "unicode-ident"
371 -version = "1.0.19"
371 +version = "1.0.20"
372 372 source = "registry+https://github.com/rust-lang/crates.io-index"
373 -checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
373 +checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06"
374 374
375 375 [[package]]
376 376 name = "wasi"
@@ -439,9 +439,9 @@ dependencies = [
439 439
440 440 [[package]]
441 441 name = "windows-core"
442 -version = "0.62.1"
442 +version = "0.62.2"
443 443 source = "registry+https://github.com/rust-lang/crates.io-index"
444 -checksum = "6844ee5416b285084d3d3fffd743b925a6c9385455f64f6d4fa3031c4c2749a9"
444 +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
445 445 dependencies = [
446 446 "windows-implement",
447 447 "windows-interface",
@@ -452,9 +452,9 @@ dependencies = [
452 452
453 453 [[package]]
454 454 name = "windows-implement"
455 -version = "0.60.1"
455 +version = "0.60.2"
456 456 source = "registry+https://github.com/rust-lang/crates.io-index"
457 -checksum = "edb307e42a74fb6de9bf3a02d9712678b22399c87e6fa869d6dfcd8c1b7754e0"
457 +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
458 458 dependencies = [
459 459 "proc-macro2",
460 460 "quote",
@@ -463,9 +463,9 @@ dependencies = [
463 463
464 464 [[package]]
465 465 name = "windows-interface"
466 -version = "0.59.2"
466 +version = "0.59.3"
467 467 source = "registry+https://github.com/rust-lang/crates.io-index"
468 -checksum = "c0abd1ddbc6964ac14db11c7213d6532ef34bd9aa042c2e5935f59d7908b46a5"
468 +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
469 469 dependencies = [
470 470 "proc-macro2",
471 471 "quote",
@@ -474,24 +474,24 @@ dependencies = [
474 474
475 475 [[package]]
476 476 name = "windows-link"
477 -version = "0.2.0"
477 +version = "0.2.1"
478 478 source = "registry+https://github.com/rust-lang/crates.io-index"
479 -checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65"
479 +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
480 480
481 481 [[package]]
482 482 name = "windows-result"
483 -version = "0.4.0"
483 +version = "0.4.1"
484 484 source = "registry+https://github.com/rust-lang/crates.io-index"
485 -checksum = "7084dcc306f89883455a206237404d3eaf961e5bd7e0f312f7c91f57eb44167f"
485 +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
486 486 dependencies = [
487 487 "windows-link",
488 488 ]
489 489
490 490 [[package]]
491 491 name = "windows-strings"
492 -version = "0.5.0"
492 +version = "0.5.1"
493 493 source = "registry+https://github.com/rust-lang/crates.io-index"
494 -checksum = "7218c655a553b0bed4426cf54b20d7ba363ef543b52d515b3e48d7fd55318dda"
494 +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
495 495 dependencies = [
496 496 "windows-link",
497 497 ]
@@ -502,14 +502,14 @@ version = "0.48.0"
502 502 source = "registry+https://github.com/rust-lang/crates.io-index"
503 503 checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
504 504 dependencies = [
505 - "windows-targets 0.48.5",
505 + "windows-targets",
506 506 ]
507 507
508 508 [[package]]
509 509 name = "windows-sys"
510 -version = "0.61.0"
510 +version = "0.61.2"
511 511 source = "registry+https://github.com/rust-lang/crates.io-index"
512 -checksum = "e201184e40b2ede64bc2ea34968b28e33622acdbbf37104f0e4a33f7abe657aa"
512 +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
513 513 dependencies = [
514 514 "windows-link",
515 515 ]
@@ -520,29 +520,13 @@ version = "0.48.5"
520 520 source = "registry+https://github.com/rust-lang/crates.io-index"
521 521 checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
522 522 dependencies = [
523 - "windows_aarch64_gnullvm 0.48.5",
524 - "windows_aarch64_msvc 0.48.5",
525 - "windows_i686_gnu 0.48.5",
526 - "windows_i686_msvc 0.48.5",
527 - "windows_x86_64_gnu 0.48.5",
528 - "windows_x86_64_gnullvm 0.48.5",
529 - "windows_x86_64_msvc 0.48.5",
530 -]
531 -
532 -[[package]]
533 -name = "windows-targets"
534 -version = "0.52.6"
535 -source = "registry+https://github.com/rust-lang/crates.io-index"
536 -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
537 -dependencies = [
538 - "windows_aarch64_gnullvm 0.52.6",
539 - "windows_aarch64_msvc 0.52.6",
540 - "windows_i686_gnu 0.52.6",
541 - "windows_i686_gnullvm",
542 - "windows_i686_msvc 0.52.6",
543 - "windows_x86_64_gnu 0.52.6",
544 - "windows_x86_64_gnullvm 0.52.6",
545 - "windows_x86_64_msvc 0.52.6",
523 + "windows_aarch64_gnullvm",
524 + "windows_aarch64_msvc",
525 + "windows_i686_gnu",
526 + "windows_i686_msvc",
527 + "windows_x86_64_gnu",
528 + "windows_x86_64_gnullvm",
529 + "windows_x86_64_msvc",
546 530 ]
547 531
548 532 [[package]]
@@ -551,90 +535,42 @@ version = "0.48.5"
551 535 source = "registry+https://github.com/rust-lang/crates.io-index"
552 536 checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
553 537
554 -[[package]]
555 -name = "windows_aarch64_gnullvm"
556 -version = "0.52.6"
557 -source = "registry+https://github.com/rust-lang/crates.io-index"
558 -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
559 -
560 538 [[package]]
561 539 name = "windows_aarch64_msvc"
562 540 version = "0.48.5"
563 541 source = "registry+https://github.com/rust-lang/crates.io-index"
564 542 checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
565 543
566 -[[package]]
567 -name = "windows_aarch64_msvc"
568 -version = "0.52.6"
569 -source = "registry+https://github.com/rust-lang/crates.io-index"
570 -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
571 -
572 544 [[package]]
573 545 name = "windows_i686_gnu"
574 546 version = "0.48.5"
575 547 source = "registry+https://github.com/rust-lang/crates.io-index"
576 548 checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
577 549
578 -[[package]]
579 -name = "windows_i686_gnu"
580 -version = "0.52.6"
581 -source = "registry+https://github.com/rust-lang/crates.io-index"
582 -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
583 -
584 -[[package]]
585 -name = "windows_i686_gnullvm"
586 -version = "0.52.6"
587 -source = "registry+https://github.com/rust-lang/crates.io-index"
588 -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
589 -
590 550 [[package]]
591 551 name = "windows_i686_msvc"
592 552 version = "0.48.5"
593 553 source = "registry+https://github.com/rust-lang/crates.io-index"
594 554 checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
595 555
596 -[[package]]
597 -name = "windows_i686_msvc"
598 -version = "0.52.6"
599 -source = "registry+https://github.com/rust-lang/crates.io-index"
600 -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
601 -
602 556 [[package]]
603 557 name = "windows_x86_64_gnu"
604 558 version = "0.48.5"
605 559 source = "registry+https://github.com/rust-lang/crates.io-index"
606 560 checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
607 561
608 -[[package]]
609 -name = "windows_x86_64_gnu"
610 -version = "0.52.6"
611 -source = "registry+https://github.com/rust-lang/crates.io-index"
612 -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
613 -
614 562 [[package]]
615 563 name = "windows_x86_64_gnullvm"
616 564 version = "0.48.5"
617 565 source = "registry+https://github.com/rust-lang/crates.io-index"
618 566 checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
619 567
620 -[[package]]
621 -name = "windows_x86_64_gnullvm"
622 -version = "0.52.6"
623 -source = "registry+https://github.com/rust-lang/crates.io-index"
624 -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
625 -
626 568 [[package]]
627 569 name = "windows_x86_64_msvc"
628 570 version = "0.48.5"
629 571 source = "registry+https://github.com/rust-lang/crates.io-index"
630 572 checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
631 573
632 -[[package]]
633 -name = "windows_x86_64_msvc"
634 -version = "0.52.6"
635 -source = "registry+https://github.com/rust-lang/crates.io-index"
636 -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
637 -
638 574 [[package]]
639 575 name = "x11"
640 576 version = "2.21.0"
+1 −1 Cargo.toml
@@ -13,7 +13,7 @@ path = "src/bin/main.rs"
13 13
14 14 [dependencies]
15 15 x11 = { version = "2.21", features = ["xlib", "xft"] }
16 -x11rb = { version = "0.13", features = ["cursor", "randr"] }
16 +x11rb = { version = "0.13", features = ["cursor", "xinerama"] }
17 17 anyhow = "1"
18 18 chrono = "0.4"
19 19 dirs = "5.0"
+7 −2 justfile
@@ -19,12 +19,17 @@ test-clean:
19 19 pkill Xephyr || true
20 20 rm -rf ~/.config/oxwm
21 21 Xephyr -screen 1280x800 :1 & sleep 1
22 - DISPLAY=:1 cargo run --release
22 + DISPLAY=:1 cargo run --release -- --config test-config.ron
23 23
24 24 test:
25 25 pkill Xephyr || true
26 26 Xephyr -screen 1280x800 :1 & sleep 1
27 - DISPLAY=:1 cargo run --release
27 + DISPLAY=:1 cargo run --release -- --config test-config.ron
28 +
29 +test-multimon:
30 + pkill Xephyr || true
31 + Xephyr +xinerama -screen 640x480 -screen 640x480 :1 & sleep 1
32 + DISPLAY=:1 cargo run --release -- --config test-config.ron
28 33
29 34 init:
30 35 cargo run --release -- --init
+27 −12 src/bin/main.rs
@@ -4,6 +4,8 @@ use std::path::PathBuf;
4 4 fn main() -> Result<()> {
5 5 let args: Vec<String> = std::env::args().collect();
6 6
7 + let mut custom_config_path: Option<PathBuf> = None;
8 +
7 9 match args.get(1).map(|s| s.as_str()) {
8 10 Some("--version") => {
9 11 println!("oxwm {}", env!("CARGO_PKG_VERSION"));
@@ -17,10 +19,18 @@ fn main() -> Result<()> {
17 19 init_config()?;
18 20 return Ok(());
19 21 }
22 + Some("--config") => {
23 + if let Some(path) = args.get(2) {
24 + custom_config_path = Some(PathBuf::from(path));
25 + } else {
26 + eprintln!("Error: --config requires a path argument");
27 + std::process::exit(1);
28 + }
29 + }
20 30 _ => {}
21 31 }
22 32
23 - let config = load_config()?;
33 + let config = load_config(custom_config_path)?;
24 34
25 35 let mut wm = oxwm::window_manager::WindowManager::new(config)?;
26 36 let should_restart = wm.run()?;
@@ -36,14 +46,18 @@ fn main() -> Result<()> {
36 46 Ok(())
37 47 }
38 48
39 -fn load_config() -> Result<oxwm::Config> {
40 - let config_path = get_config_path().join("config.ron");
41 -
42 - if !config_path.exists() {
43 - println!("No config found at {:?}", config_path);
44 - println!("Creating default config...");
45 - init_config()?;
46 - }
49 +fn load_config(custom_path: Option<PathBuf>) -> Result<oxwm::Config> {
50 + let config_path = if let Some(path) = custom_path {
51 + path
52 + } else {
53 + let default_path = get_config_path().join("config.ron");
54 + if !default_path.exists() {
55 + println!("No config found at {:?}", default_path);
56 + println!("Creating default config...");
57 + init_config()?;
58 + }
59 + default_path
60 + };
47 61
48 62 let config_str = std::fs::read_to_string(&config_path)
49 63 .map_err(|e| anyhow::anyhow!("Failed to read config file: {}", e))?;
@@ -79,9 +93,10 @@ fn print_help() {
79 93 println!("USAGE:");
80 94 println!(" oxwm [OPTIONS]\n");
81 95 println!("OPTIONS:");
82 - println!(" --init Create default config in ~/.config/oxwm/config.ron");
83 - println!(" --version Print version information");
84 - println!(" --help Print this help message\n");
96 + println!(" --init Create default config in ~/.config/oxwm/config.ron");
97 + println!(" --config <PATH> Use custom config file");
98 + println!(" --version Print version information");
99 + println!(" --help Print this help message\n");
85 100 println!("CONFIG:");
86 101 println!(" Location: ~/.config/oxwm/config.ron");
87 102 println!(" Edit the config file and use Mod+Shift+R to reload");
+31 −79 src/monitor.rs
@@ -1,5 +1,5 @@
1 1 use crate::errors::WmError;
2 -use x11rb::protocol::randr::{self, ConnectionExt as _};
2 +use x11rb::protocol::xinerama::ConnectionExt as _;
3 3 use x11rb::protocol::xproto::{Screen, Window};
4 4 use x11rb::rust_connection::RustConnection;
5 5
@@ -38,91 +38,43 @@ impl Monitor {
38 38 pub fn detect_monitors(
39 39 connection: &RustConnection,
40 40 screen: &Screen,
41 - root: Window,
41 + _root: Window,
42 42 ) -> WmResult<Vec<Monitor>> {
43 - let randr_version = match connection.randr_query_version(1, 2) {
44 - Ok(cookie) => match cookie.reply() {
45 - Ok(reply) => reply.major_version >= 1 && reply.minor_version >= 2,
46 - Err(_) => false,
47 - },
48 - Err(_) => false,
49 - };
50 -
51 - if !randr_version {
52 - eprintln!("RandR 1.2+ not available, using single monitor");
53 - return Ok(vec![Monitor::new(
54 - 0,
55 - 0,
56 - screen.width_in_pixels as u32,
57 - screen.height_in_pixels as u32,
58 - )]);
59 - }
60 -
61 - let resources = match connection.randr_get_screen_resources(root) {
62 - Ok(cookie) => match cookie.reply() {
63 - Ok(res) => res,
64 - Err(_) => {
65 - eprintln!("Failed to get screen resources, using single monitor");
66 - return Ok(vec![Monitor::new(
67 - 0,
68 - 0,
69 - screen.width_in_pixels as u32,
70 - screen.height_in_pixels as u32,
71 - )]);
72 - }
73 - },
74 - Err(_) => {
75 - eprintln!("Failed to query screen resources, using single monitor");
76 - return Ok(vec![Monitor::new(
77 - 0,
78 - 0,
79 - screen.width_in_pixels as u32,
80 - screen.height_in_pixels as u32,
81 - )]);
82 - }
83 - };
84 -
85 43 let mut monitors = Vec::new();
86 44
87 - for &output in &resources.outputs {
88 - let output_info = match connection.randr_get_output_info(output, 0) {
89 - Ok(cookie) => match cookie.reply() {
90 - Ok(info) => info,
91 - Err(_) => continue,
92 - },
93 - Err(_) => continue,
94 - };
95 -
96 - if output_info.connection != randr::Connection::CONNECTED {
97 - continue;
98 - }
99 -
100 - if output_info.crtc == 0 {
101 - continue;
102 - }
103 -
104 - let crtc_info = match connection.randr_get_crtc_info(output_info.crtc, 0) {
105 - Ok(cookie) => match cookie.reply() {
106 - Ok(info) => info,
107 - Err(_) => continue,
108 - },
109 - Err(_) => continue,
110 - };
111 -
112 - if crtc_info.width == 0 || crtc_info.height == 0 {
113 - continue;
45 + if let Ok(cookie) = connection.xinerama_is_active() {
46 + if let Ok(reply) = cookie.reply() {
47 + if reply.state != 0 {
48 + if let Ok(screens_cookie) = connection.xinerama_query_screens() {
49 + if let Ok(screens_reply) = screens_cookie.reply() {
50 + for screen_info in &screens_reply.screen_info {
51 + if screen_info.width == 0 || screen_info.height == 0 {
52 + continue;
53 + }
54 +
55 + let is_unique = !monitors.iter().any(|m: &Monitor| {
56 + m.x == screen_info.x_org as i32
57 + && m.y == screen_info.y_org as i32
58 + && m.width == screen_info.width as u32
59 + && m.height == screen_info.height as u32
60 + });
61 +
62 + if is_unique {
63 + monitors.push(Monitor::new(
64 + screen_info.x_org as i32,
65 + screen_info.y_org as i32,
66 + screen_info.width as u32,
67 + screen_info.height as u32,
68 + ));
69 + }
70 + }
71 + }
72 + }
73 + }
114 74 }
115 -
116 - monitors.push(Monitor::new(
117 - crtc_info.x as i32,
118 - crtc_info.y as i32,
119 - crtc_info.width as u32,
120 - crtc_info.height as u32,
121 - ));
122 75 }
123 76
124 77 if monitors.is_empty() {
125 - eprintln!("No monitors detected via RandR, using full screen");
126 78 monitors.push(Monitor::new(
127 79 0,
128 80 0,
+7 −3 src/window_manager.rs
@@ -143,7 +143,7 @@ impl WindowManager {
143 143 let font = crate::bar::font::Font::new(display, screen_number as i32, &config.font)?;
144 144
145 145 let mut bars = Vec::new();
146 - for monitor in &monitors {
146 + for monitor in monitors.iter() {
147 147 let bar = Bar::new(
148 148 &connection,
149 149 &screen,
@@ -619,7 +619,7 @@ impl WindowManager {
619 619 self.apply_layout()?;
620 620 self.update_bar()?;
621 621
622 - let visible = self.visible_windows();
622 + let visible = self.visible_windows_on_monitor(self.selected_monitor);
623 623 if let Some(&win) = visible.first() {
624 624 self.set_focus(win)?;
625 625 }
@@ -910,6 +910,10 @@ impl WindowManager {
910 910 }
911 911 }
912 912 Event::MotionNotify(event) => {
913 + if event.event != self.root {
914 + return Ok(None);
915 + }
916 +
913 917 if let Some(monitor_index) = self.get_monitor_at_point(event.root_x as i32, event.root_y as i32) {
914 918 if monitor_index != self.selected_monitor {
915 919 self.selected_monitor = monitor_index;
@@ -1056,7 +1060,7 @@ impl WindowManager {
1056 1060 if self.windows.len() < initial_count {
1057 1061 let focused = self.monitors.get(self.selected_monitor).and_then(|m| m.focused_window);
1058 1062 if focused == Some(window) {
1059 - let visible = self.visible_windows();
1063 + let visible = self.visible_windows_on_monitor(self.selected_monitor);
1060 1064 if let Some(&new_win) = visible.last() {
1061 1065 self.set_focus(new_win)?;
1062 1066 } else if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) {
+136 −0 test-config.ron new file mode 100644
@@ -0,0 +1,136 @@
1 +#![enable(implicit_some)]
2 +// OXWM Configuration File
3 +// Edit this file and reload with Mod+Shift+R (no compilation needed!)
4 +
5 +(
6 + border_width: 2,
7 + border_focused: 0x6dade3,
8 + border_unfocused: 0xbbbbbb,
9 + font: "JetBrainsMono Nerd Font:style=Bold:size=12",
10 +
11 + gaps_enabled: true,
12 + gap_inner_horizontal: 5,
13 + gap_inner_vertical: 5,
14 + gap_outer_horizontal: 5,
15 + gap_outer_vertical: 5,
16 +
17 + terminal: "st",
18 + modkey: Mod1,
19 +
20 + tags: ["1", "2", "3", "4", "5", "6", "7", "8", "9"],
21 +
22 + // Alternative icon tags (uncomment to use):
23 + // tags: ["", "󰊯", "", "", "󰙯", "󱇤", "", "󱘶", "󰧮"],
24 +
25 + // Alternative text tags (uncomment to use):
26 + // tags: ["DEV", "WWW", "SYS", "DOC", "VBOX", "CHAT", "MUS", "VID", "MISC"],
27 +
28 + keybindings: [
29 + (modifiers: [Mod1], key: Return, action: Spawn, arg: "st"),
30 + (modifiers: [Mod1], key: D, action: Spawn, arg: ["sh", "-c", "dmenu_run -l 10"]),
31 + (modifiers: [Mod1], key: S, action: Spawn, arg: ["sh", "-c", "maim -s | xclip -selection clipboard -t image/png"]),
32 + (modifiers: [Mod1], key: Q, action: KillClient),
33 + (modifiers: [Mod1, Shift], key: F, action: ToggleFullScreen),
34 + (modifiers: [Mod1, Shift], key: Space, action: ToggleFloating),
35 + (modifiers: [Mod1], key: A, action: ToggleGaps),
36 + (modifiers: [Mod1, Shift], key: Q, action: Quit),
37 + (modifiers: [Mod1, Shift], key: R, action: Restart),
38 + (modifiers: [Mod1], key: J, action: FocusStack, arg: -1),
39 + (modifiers: [Mod1], key: K, action: FocusStack, arg: 1),
40 + (modifiers: [Mod1], key: Key1, action: ViewTag, arg: 0),
41 + (modifiers: [Mod1], key: Key2, action: ViewTag, arg: 1),
42 + (modifiers: [Mod1], key: Key3, action: ViewTag, arg: 2),
43 + (modifiers: [Mod1], key: Key4, action: ViewTag, arg: 3),
44 + (modifiers: [Mod1], key: Key5, action: ViewTag, arg: 4),
45 + (modifiers: [Mod1], key: Key6, action: ViewTag, arg: 5),
46 + (modifiers: [Mod1], key: Key7, action: ViewTag, arg: 6),
47 + (modifiers: [Mod1], key: Key8, action: ViewTag, arg: 7),
48 + (modifiers: [Mod1], key: Key9, action: ViewTag, arg: 8),
49 + (modifiers: [Mod1, Shift], key: Key1, action: MoveToTag, arg: 0),
50 + (modifiers: [Mod1, Shift], key: Key2, action: MoveToTag, arg: 1),
51 + (modifiers: [Mod1, Shift], key: Key3, action: MoveToTag, arg: 2),
52 + (modifiers: [Mod1, Shift], key: Key4, action: MoveToTag, arg: 3),
53 + (modifiers: [Mod1, Shift], key: Key5, action: MoveToTag, arg: 4),
54 + (modifiers: [Mod1, Shift], key: Key6, action: MoveToTag, arg: 5),
55 + (modifiers: [Mod1, Shift], key: Key7, action: MoveToTag, arg: 6),
56 + (modifiers: [Mod1, Shift], key: Key8, action: MoveToTag, arg: 7),
57 + (modifiers: [Mod1, Shift], key: Key9, action: MoveToTag, arg: 8),
58 + ],
59 +
60 + status_blocks: [
61 + // Battery block (shows charging/discharging status)
62 + (
63 + format: "",
64 + command: "Battery",
65 + battery_formats: (
66 + charging: "󰂄 Bat: {}%",
67 + discharging: "󰁹 Bat:{}%",
68 + full: "󰁹 Bat: {}%",
69 + ),
70 + interval_secs: 30,
71 + color: 0x9ece6a,
72 + underline: true,
73 + ),
74 +
75 + // Separator
76 + (
77 + format: " │ ",
78 + command: "Static",
79 + interval_secs: 18446744073709551615,
80 + color: 0xa9b1d6,
81 + underline: false,
82 + ),
83 +
84 + // RAM usage
85 + (
86 + format: "󰍛 {used}/{total} GB",
87 + command: "Ram",
88 + interval_secs: 5,
89 + color: 0x7aa2f7,
90 + underline: true,
91 + ),
92 +
93 + // Separator
94 + (
95 + format: " │ ",
96 + command: "Static",
97 + interval_secs: 18446744073709551615,
98 + color: 0xa9b1d6,
99 + underline: false,
100 + ),
101 +
102 + // Kernel version
103 + (
104 + format: " {}",
105 + command: "Shell",
106 + command_arg: "uname -r",
107 + interval_secs: 18446744073709551615,
108 + color: 0xf7768e,
109 + underline: true,
110 + ),
111 +
112 + // Separator
113 + (
114 + format: " │ ",
115 + command: "Static",
116 + interval_secs: 18446744073709551615,
117 + color: 0xa9b1d6,
118 + underline: false,
119 + ),
120 +
121 + // Date and time
122 + (
123 + format: "󰸘 {}",
124 + command: "DateTime",
125 + command_arg: "%a, %b %d - %-I:%M %P",
126 + interval_secs: 1,
127 + color: 0x0db9d7,
128 + underline: true,
129 + ),
130 + ],
131 +
132 + scheme_normal: (foreground: 0xbbbbbb, background: 0x1a1b26, underline: 0x444444),
133 + scheme_occupied: (foreground: 0x0db9d7, background: 0x1a1b26, underline: 0x0db9d7),
134 + scheme_selected: (foreground: 0x0db9d7, background: 0x1a1b26, underline: 0xad8ee6),
135 +)
136 +