Skip to content

Commit

Permalink
chore(deps): bump windows-rs from 0.33 to 0.34
Browse files Browse the repository at this point in the history
  • Loading branch information
LGUG2Z committed Mar 18, 2022
1 parent e46f1f4 commit 3eade94
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 78 deletions.
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion komorebi-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ strum = { version = "0.24", features = ["derive"] }
schemars = "0.8"

[dependencies.windows]
version = "0.33"
version = "0.34"
features = [
"Win32_Foundation",
]
13 changes: 7 additions & 6 deletions komorebi-core/src/arrangement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ impl Arrangement for DefaultLayout {
) -> Vec<Rect> {
let len = usize::from(len);
let mut dimensions = match self {
DefaultLayout::BSP => recursive_fibonacci(
Self::BSP => recursive_fibonacci(
0,
len,
area,
layout_flip,
calculate_resize_adjustments(resize_dimensions),
),
DefaultLayout::Columns => columns(area, len),
DefaultLayout::Rows => rows(area, len),
DefaultLayout::VerticalStack => {
Self::Columns => columns(area, len),
Self::Rows => rows(area, len),
Self::VerticalStack => {
let mut layouts: Vec<Rect> = vec![];

let primary_right = match len {
Expand Down Expand Up @@ -88,7 +88,7 @@ impl Arrangement for DefaultLayout {

layouts
}
DefaultLayout::HorizontalStack => {
Self::HorizontalStack => {
let mut layouts: Vec<Rect> = vec![];

let bottom = match len {
Expand Down Expand Up @@ -130,7 +130,7 @@ impl Arrangement for DefaultLayout {

layouts
}
DefaultLayout::UltrawideVerticalStack => {
Self::UltrawideVerticalStack => {
let mut layouts: Vec<Rect> = vec![];

let primary_right = match len {
Expand Down Expand Up @@ -475,6 +475,7 @@ fn calculate_resize_adjustments(resize_dimensions: &[Option<Rect>]) -> Vec<Optio
cleaned_resize_adjustments
}

#[allow(clippy::only_used_in_recursion)]
fn recursive_fibonacci(
idx: usize,
count: usize,
Expand Down
2 changes: 1 addition & 1 deletion komorebi-core/src/default_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub enum DefaultLayout {

impl DefaultLayout {
#[must_use]
#[allow(clippy::cast_precision_loss)]
#[allow(clippy::cast_precision_loss, clippy::only_used_in_recursion)]
pub fn resize(
&self,
unaltered: &Rect,
Expand Down
81 changes: 38 additions & 43 deletions komorebi-core/src/direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,34 @@ impl Direction for DefaultLayout {
) -> bool {
match op_direction {
OperationDirection::Up => match self {
DefaultLayout::BSP => count > 2 && idx != 0 && idx != 1,
DefaultLayout::Columns => false,
DefaultLayout::Rows | DefaultLayout::HorizontalStack => idx != 0,
DefaultLayout::VerticalStack => idx != 0 && idx != 1,
DefaultLayout::UltrawideVerticalStack => idx > 2,
Self::BSP => count > 2 && idx != 0 && idx != 1,
Self::Columns => false,
Self::Rows | Self::HorizontalStack => idx != 0,
Self::VerticalStack => idx != 0 && idx != 1,
Self::UltrawideVerticalStack => idx > 2,
},
OperationDirection::Down => match self {
DefaultLayout::BSP => count > 2 && idx != count - 1 && idx % 2 != 0,
DefaultLayout::Columns => false,
DefaultLayout::Rows => idx != count - 1,
DefaultLayout::VerticalStack => idx != 0 && idx != count - 1,
DefaultLayout::HorizontalStack => idx == 0,
DefaultLayout::UltrawideVerticalStack => idx > 1 && idx != count - 1,
Self::BSP => count > 2 && idx != count - 1 && idx % 2 != 0,
Self::Columns => false,
Self::Rows => idx != count - 1,
Self::VerticalStack => idx != 0 && idx != count - 1,
Self::HorizontalStack => idx == 0,
Self::UltrawideVerticalStack => idx > 1 && idx != count - 1,
},
OperationDirection::Left => match self {
DefaultLayout::BSP => count > 1 && idx != 0,
DefaultLayout::Columns | DefaultLayout::VerticalStack => idx != 0,
DefaultLayout::Rows => false,
DefaultLayout::HorizontalStack => idx != 0 && idx != 1,
DefaultLayout::UltrawideVerticalStack => count > 1 && idx != 1,
Self::BSP => count > 1 && idx != 0,
Self::Columns | Self::VerticalStack => idx != 0,
Self::Rows => false,
Self::HorizontalStack => idx != 0 && idx != 1,
Self::UltrawideVerticalStack => count > 1 && idx != 1,
},
OperationDirection::Right => match self {
DefaultLayout::BSP => count > 1 && idx % 2 == 0 && idx != count - 1,
DefaultLayout::Columns => idx != count - 1,
DefaultLayout::Rows => false,
DefaultLayout::VerticalStack => idx == 0,
DefaultLayout::HorizontalStack => idx != 0 && idx != count - 1,
DefaultLayout::UltrawideVerticalStack => match count {
Self::BSP => count > 1 && idx % 2 == 0 && idx != count - 1,
Self::Columns => idx != count - 1,
Self::Rows => false,
Self::VerticalStack => idx == 0,
Self::HorizontalStack => idx != 0 && idx != count - 1,
Self::UltrawideVerticalStack => match count {
0 | 1 => false,
2 => idx != 0,
_ => idx < 2,
Expand All @@ -110,45 +110,40 @@ impl Direction for DefaultLayout {

fn up_index(&self, idx: usize) -> usize {
match self {
DefaultLayout::BSP => {
Self::BSP => {
if idx % 2 == 0 {
idx - 1
} else {
idx - 2
}
}
DefaultLayout::Columns => unreachable!(),
DefaultLayout::Rows
| DefaultLayout::VerticalStack
| DefaultLayout::UltrawideVerticalStack => idx - 1,
DefaultLayout::HorizontalStack => 0,
Self::Columns => unreachable!(),
Self::Rows | Self::VerticalStack | Self::UltrawideVerticalStack => idx - 1,
Self::HorizontalStack => 0,
}
}

fn down_index(&self, idx: usize) -> usize {
match self {
DefaultLayout::BSP
| DefaultLayout::Rows
| DefaultLayout::VerticalStack
| DefaultLayout::UltrawideVerticalStack => idx + 1,
DefaultLayout::Columns => unreachable!(),
DefaultLayout::HorizontalStack => 1,
Self::BSP | Self::Rows | Self::VerticalStack | Self::UltrawideVerticalStack => idx + 1,
Self::Columns => unreachable!(),
Self::HorizontalStack => 1,
}
}

fn left_index(&self, idx: usize) -> usize {
match self {
DefaultLayout::BSP => {
Self::BSP => {
if idx % 2 == 0 {
idx - 2
} else {
idx - 1
}
}
DefaultLayout::Columns | DefaultLayout::HorizontalStack => idx - 1,
DefaultLayout::Rows => unreachable!(),
DefaultLayout::VerticalStack => 0,
DefaultLayout::UltrawideVerticalStack => match idx {
Self::Columns | Self::HorizontalStack => idx - 1,
Self::Rows => unreachable!(),
Self::VerticalStack => 0,
Self::UltrawideVerticalStack => match idx {
0 => 1,
1 => unreachable!(),
_ => 0,
Expand All @@ -158,10 +153,10 @@ impl Direction for DefaultLayout {

fn right_index(&self, idx: usize) -> usize {
match self {
DefaultLayout::BSP | DefaultLayout::Columns | DefaultLayout::HorizontalStack => idx + 1,
DefaultLayout::Rows => unreachable!(),
DefaultLayout::VerticalStack => 1,
DefaultLayout::UltrawideVerticalStack => match idx {
Self::BSP | Self::Columns | Self::HorizontalStack => idx + 1,
Self::Rows => unreachable!(),
Self::VerticalStack => 1,
Self::UltrawideVerticalStack => match idx {
1 => 0,
0 => 2,
_ => unreachable!(),
Expand Down
6 changes: 3 additions & 3 deletions 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)]
#![allow(clippy::missing_errors_doc, clippy::use_self)]

use std::path::PathBuf;
use std::str::FromStr;
Expand Down Expand Up @@ -171,8 +171,8 @@ impl Sizing {
#[must_use]
pub const fn adjust_by(&self, value: i32, adjustment: i32) -> i32 {
match self {
Sizing::Increase => value + adjustment,
Sizing::Decrease => {
Self::Increase => value + adjustment,
Self::Decrease => {
if value > 0 && value - adjustment >= 0 {
value - adjustment
} else {
Expand Down
2 changes: 1 addition & 1 deletion komorebi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ winreg = "0.10"
schemars = "0.8"

[dependencies.windows]
version = "0.33"
version = "0.34"
features = [
"Win32_Foundation",
"Win32_Graphics_Dwm",
Expand Down
7 changes: 2 additions & 5 deletions komorebi/src/windows_api.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::VecDeque;
use std::convert::TryFrom;
use std::convert::TryInto;
use std::ffi::c_void;

use color_eyre::eyre::anyhow;
Expand Down Expand Up @@ -438,9 +437,7 @@ impl WindowsApi {

pub fn window_text_w(hwnd: HWND) -> Result<String> {
let mut text: [u16; 512] = [0; 512];
match WindowsResult::from(unsafe {
GetWindowTextW(hwnd, PWSTR(text.as_mut_ptr()), text.len().try_into()?)
}) {
match WindowsResult::from(unsafe { GetWindowTextW(hwnd, &mut text) }) {
WindowsResult::Ok(len) => {
let length = usize::try_from(len)?;
Ok(String::from_utf16(&text[..length])?)
Expand Down Expand Up @@ -495,7 +492,7 @@ impl WindowsApi {
let mut class: [u16; BUF_SIZE] = [0; BUF_SIZE];

let len = Result::from(WindowsResult::from(unsafe {
RealGetWindowClassW(hwnd, PWSTR(class.as_mut_ptr()), u32::try_from(BUF_SIZE)?)
RealGetWindowClassW(hwnd, &mut class)
}))?;

Ok(String::from_utf16(&class[0..len as usize])?)
Expand Down
2 changes: 2 additions & 0 deletions komorebi/src/winevent.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::use_self)]

use schemars::JsonSchema;
use serde::Serialize;
use strum::Display;
Expand Down
2 changes: 1 addition & 1 deletion komorebic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ serde_json = "1"
uds_windows = "1"

[dependencies.windows]
version = "0.33"
version = "0.34"
features = [
"Win32_Foundation",
"Win32_UI_WindowsAndMessaging"
Expand Down

0 comments on commit 3eade94

Please sign in to comment.