Fixed default gap implementation.
Browse files
+22 −0 src/main.zig
| @@ -427,6 +427,8 @@ fn setup_monitors(display: *Display) void { | ||
| 427 | 427 | mon.pertag.ltidxs[i][4] = mon.lt[4]; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | + init_monitor_gaps(mon); | |
| 431 | + | |
| 430 | 432 | if (prev_monitor) |prev| { |
| 431 | 433 | prev.next = mon; |
| 432 | 434 | } else { |
| @@ -466,6 +468,9 @@ fn setup_monitors(display: *Display) void { | ||
| 466 | 468 | mon.pertag.ltidxs[i][3] = mon.lt[3]; |
| 467 | 469 | mon.pertag.ltidxs[i][4] = mon.lt[4]; |
| 468 | 470 | } |
| 471 | + | |
| 472 | + init_monitor_gaps(mon); | |
| 473 | + | |
| 469 | 474 | monitor_mod.monitors = mon; |
| 470 | 475 | monitor_mod.selected_monitor = mon; |
| 471 | 476 | std.debug.print("monitor created: {d}x{d}\n", .{ mon.mon_w, mon.mon_h }); |
| @@ -482,6 +487,23 @@ fn apply_config_values() void { | ||
| 482 | 487 | tags = config.tags; |
| 483 | 488 | } |
| 484 | 489 | |
| 490 | +fn init_monitor_gaps(mon: *Monitor) void { | |
| 491 | + const any_gap_nonzero = config.gap_inner_h != 0 or config.gap_inner_v != 0 or | |
| 492 | + config.gap_outer_h != 0 or config.gap_outer_v != 0; | |
| 493 | + | |
| 494 | + if (config.gaps_enabled and any_gap_nonzero) { | |
| 495 | + mon.gap_inner_h = config.gap_inner_h; | |
| 496 | + mon.gap_inner_v = config.gap_inner_v; | |
| 497 | + mon.gap_outer_h = config.gap_outer_h; | |
| 498 | + mon.gap_outer_v = config.gap_outer_v; | |
| 499 | + } else { | |
| 500 | + mon.gap_inner_h = 0; | |
| 501 | + mon.gap_inner_v = 0; | |
| 502 | + mon.gap_outer_h = 0; | |
| 503 | + mon.gap_outer_v = 0; | |
| 504 | + } | |
| 505 | +} | |
| 506 | + | |
| 485 | 507 | fn make_keybind(mod: u32, key: u64, action: config_mod.Action) config_mod.Keybind { |
| 486 | 508 | var kb: config_mod.Keybind = .{ .action = action }; |
| 487 | 509 | kb.keys[0] = .{ .mod_mask = mod, .keysym = key }; |