Skip to content

Commit

Permalink
fix(wm): dynamically reserve monitor ring space
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LGUG2Z committed May 24, 2024
1 parent e46a075 commit 340c137
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion komorebi-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 2 additions & 0 deletions komorebi-gui/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::assigning_clones)]

use eframe::egui;
use eframe::egui::color_picker::Alpha;
use eframe::egui::Color32;
Expand Down
3 changes: 2 additions & 1 deletion komorebi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions komorebi/src/static_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions komorebi/src/windows_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion komorebic/src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -102,6 +102,7 @@ lazy_static! {
};
}

#[allow(dead_code)]
trait AhkLibrary {
fn generate_ahk_library() -> String;
}
Expand Down

0 comments on commit 340c137

Please sign in to comment.