fix(wm): dynamically reserve monitor ring space

This commit makes a small change to dynamically keep reserving space in
the VecDeque that backs Ring<Monitor> until an index preference can be
contained within the current length.

This commit also fixes some clippy lints and adds some allow
annotations.
This commit is contained in:
LGUG2Z
2024-05-23 16:58:52 -07:00
parent e46a0757e3
commit 340c137342
6 changed files with 14 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
#![allow(clippy::missing_errors_doc, clippy::use_self)]
#![allow(clippy::missing_errors_doc, clippy::use_self, clippy::doc_markdown)]
use std::path::Path;
use std::path::PathBuf;

View File

@@ -1,3 +1,5 @@
#![allow(clippy::assigning_clones)]
use eframe::egui;
use eframe::egui::color_picker::Alpha;
use eframe::egui::Color32;

View File

@@ -3,7 +3,8 @@
clippy::missing_errors_doc,
clippy::redundant_pub_crate,
clippy::significant_drop_tightening,
clippy::significant_drop_in_scrutinee
clippy::significant_drop_in_scrutinee,
clippy::doc_markdown
)]
use std::path::PathBuf;

View File

@@ -333,7 +333,7 @@ impl StaticConfig {
let mut display = false;
for (_, aliases) in &map {
for aliases in map.values() {
for a in aliases {
if raw.contains(a) {
display = true;
@@ -493,7 +493,11 @@ impl From<&WindowManager> for StaticConfig {
}
impl StaticConfig {
#[allow(clippy::cognitive_complexity, clippy::too_many_lines)]
#[allow(
clippy::cognitive_complexity,
clippy::too_many_lines,
clippy::assigning_clones
)]
fn apply_globals(&mut self) -> Result<()> {
if let Some(monitor_index_preferences) = &self.monitor_index_preferences {
let mut preferences = MONITOR_INDEX_PREFERENCES.lock();

View File

@@ -276,8 +276,7 @@ impl WindowsApi {
if monitors.elements().is_empty() {
monitors.elements_mut().push_back(m);
} else if let Some(preference) = index_preference {
let current_len = monitors.elements().len();
if *preference > current_len {
while *preference > monitors.elements().len() {
monitors.elements_mut().reserve(1);
}

View File

@@ -1,5 +1,5 @@
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::missing_errors_doc, clippy::doc_markdown)]
use chrono::Local;
use std::fs::File;
@@ -102,6 +102,7 @@ lazy_static! {
};
}
#[allow(dead_code)]
trait AhkLibrary {
fn generate_ahk_library() -> String;
}