Skip to content

Commit

Permalink
fix: revert changes and fixed imports
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaCoduriV committed Jul 29, 2024
1 parent ec7a335 commit 63caa2a
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub fn handle_window_location_changed(
move_container_within_tree(
window.into(),
updated_workspace.clone().into(),
Some(updated_workspace.child_count()),
updated_workspace.child_count(),
state,
)?;
}
Expand Down
14 changes: 7 additions & 7 deletions packages/wm/src/common/events/handle_window_moved_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ fn move_window_to_target(
attach_container(&Container::NonTilingWindow(moved_window.clone()), target_window_parent, None)?;

let target_index = match new_window_position {
DropPosition::Start => Some(target_window_index),
DropPosition::End => Some(target_window_index + 1),
DropPosition::Start => target_window_index,
DropPosition::End => target_window_index + 1,
};

update_window_state(
Expand Down Expand Up @@ -205,23 +205,23 @@ fn create_split_container(
target_window: TilingWindow,
dropped_position: DropPosition,
parent: &Container,
split_container_index: Option<usize>,
split_container_index: usize,
) -> anyhow::Result<()> {
let target_index_inside_split_container = match dropped_position {
DropPosition::Start => Some(0),
DropPosition::End => Some(1),
DropPosition::Start => 0,
DropPosition::End => 1,
};

let split_container = Container::Split(SplitContainer::new(
tiling_direction,
config.value.gaps.inner_gap.clone(),
));
attach_container(&split_container, &parent, split_container_index)?;
attach_container(&split_container, &parent, Some(split_container_index))?;

move_container_within_tree(
Container::TilingWindow(target_window),
split_container.clone(),
None,
0,
state,
)?;
move_container_within_tree(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
use std::collections::VecDeque;

use anyhow::Context;
use tracing::{debug, info};
use windows::Win32::{Foundation, UI::WindowsAndMessaging::GetCursorPos};
use tracing::info;

use crate::{
common::{
commands::platform_sync,
events::handle_window_moved_end::window_moved_end,
platform::{MouseMoveEvent, NativeWindow, Platform},
LengthValue, Point, Rect,
platform::NativeWindow, LengthValue,
},
containers::{
commands::{
attach_container, detach_container, move_container_within_tree,
},
traits::{CommonGetters, PositionGetters},
Container, WindowContainer,
WindowContainer,
},
user_config::UserConfig,
windows::{
commands::resize_window, traits::WindowGetters, NonTilingWindow,
TilingWindow,
commands::resize_window, traits::WindowGetters, TilingWindow,
},
wm_event::WmEvent,
wm_state::WmState,
};

Expand All @@ -37,7 +27,7 @@ pub fn handle_window_moved_or_resized_end(
config: &UserConfig,
) -> anyhow::Result<()> {
let found_window = state.window_from_native(&native_window);
if let Some(window) = found_window{
if let Some(window) = found_window {
// TODO: Log window details.

let parent = window.parent().context("No parent.")?;
Expand All @@ -64,13 +54,11 @@ pub fn handle_window_moved_or_resized_end(
if has_window_moved {
window_moved_end(window, state, config)?;
}
} else if let WindowContainer::TilingWindow(window) = window
{
} else if let WindowContainer::TilingWindow(window) = window {
window_resized_end(window, state, width_delta, height_delta)?;
}
}


Ok(())
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
use std::collections::VecDeque;

use anyhow::Context;
use tracing::{debug, info};
use windows::Win32::{Foundation, UI::WindowsAndMessaging::GetCursorPos};
use tracing::info;

use crate::{
common::{
commands::platform_sync,
events::{
handle_window_moved_start::window_moved_start,
},
platform::{MouseMoveEvent, NativeWindow, Platform},
LengthValue, Point, Rect,
events::handle_window_moved_start::window_moved_start,
platform::NativeWindow,
},
containers::{
commands::{
attach_container, detach_container, move_container_within_tree,
},
traits::{CommonGetters, PositionGetters},
Container, WindowContainer,
WindowContainer,
},
user_config::UserConfig,
windows::{
commands::resize_window, traits::WindowGetters, NonTilingWindow,
TilingWindow,
},
wm_event::WmEvent,
windows::traits::WindowGetters,
wm_state::WmState,
};

Expand Down Expand Up @@ -65,22 +51,15 @@ pub fn handle_window_moved_or_resized_start(

return match has_window_moved {
true => window_moved_start(window, state, config),
false => {
window_resized_start(window, state, width_delta, height_delta)
}
false => window_resized_start(),
};
}

Ok(())
}

/// Handles window resize events
fn window_resized_start(
window: TilingWindow,
state: &mut WmState,
width_delta: i32,
height_delta: i32,
) -> anyhow::Result<()> {
fn window_resized_start() -> anyhow::Result<()> {
info!("Tiling window resize start");
Ok(())
}
25 changes: 3 additions & 22 deletions packages/wm/src/common/events/handle_window_moved_start.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
use std::{collections::VecDeque, io::Split};

use anyhow::Context;
use tracing::{debug, info};
use windows::Win32::{Foundation, UI::WindowsAndMessaging::GetCursorPos};
use tracing::info;

use crate::{
common::{
commands::platform_sync,
platform::{MouseMoveEvent, NativeWindow, Platform},
LengthValue, Point, Rect, TilingDirection,
},
containers::{
commands::{
attach_container, detach_container, move_container_within_tree,
},
traits::{CommonGetters, PositionGetters, TilingDirectionGetters},
Container, SplitContainer, WindowContainer,
},
containers::traits::CommonGetters,
user_config::{FloatingStateConfig, UserConfig},
windows::{
commands::{resize_window, update_window_state},
traits::WindowGetters,
NonTilingWindow, TilingWindow, WindowState,
},
wm_event::WmEvent,
windows::{commands::update_window_state, TilingWindow, WindowState},
wm_state::WmState,
};

Expand Down
1 change: 0 additions & 1 deletion packages/wm/src/common/platform/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::{
};

use anyhow::{bail, Context};
use tracing::{field::debug, info};
use windows::{
core::{w, PCWSTR},
Win32::{
Expand Down
12 changes: 2 additions & 10 deletions packages/wm/src/containers/commands/move_container_within_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{
pub fn move_container_within_tree(
container_to_move: Container,
target_parent: Container,
target_index: Option<usize>,
target_index: usize,
state: &WmState,
) -> anyhow::Result<()> {
// Create iterator of parent, grandparent, and great-grandparent.
Expand All @@ -43,7 +43,6 @@ pub fn move_container_within_tree(
// If the container is already a child of the target parent, then shift
// it to the target index.
if container_to_move.parent().context("No parent.")? == target_parent {
if let Some(target_index) = target_index {
target_parent
.borrow_children_mut()
.shift_to_index(target_index, container_to_move.clone());
Expand All @@ -53,20 +52,13 @@ pub fn move_container_within_tree(
focused_container: container_to_move.to_dto()?,
});
}
}

return Ok(());
}

// Handle case where target parent is the LCA. For example, when swapping
// sibling containers or moving a container to a direct ancestor.
if target_parent == lowest_common_ancestor {
let target_index = if let Some(index) = target_index{
index
}else {
return Ok(());
};

return move_to_lowest_common_ancestor(
container_to_move,
lowest_common_ancestor,
Expand Down Expand Up @@ -110,7 +102,7 @@ pub fn move_container_within_tree(
attach_container(
&container_to_move.clone(),
&target_parent.clone(),
target_index,
Some(target_index),
)?;

// Set `container_to_move` as focused descendant within target subtree if
Expand Down
2 changes: 1 addition & 1 deletion packages/wm/src/monitors/commands/remove_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn remove_monitor(
move_container_within_tree(
workspace.clone().into(),
target_monitor.clone().into(),
Some(target_monitor.child_count()),
target_monitor.child_count(),
state,
)?;

Expand Down
10 changes: 5 additions & 5 deletions packages/wm/src/windows/commands/move_window_in_direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fn move_to_sibling_container(
move_container_within_tree(
window_to_move.clone().into(),
parent,
Some(sibling_window.index()),
sibling_window.index(),
state,
)?;

Expand Down Expand Up @@ -190,7 +190,7 @@ fn move_to_sibling_container(
move_container_within_tree(
window_to_move.into(),
target_parent.clone().into(),
Some(target_index),
target_index,
state,
)?;

Expand Down Expand Up @@ -247,7 +247,7 @@ fn move_to_workspace_in_direction(
move_container_within_tree(
window_to_move.clone().into(),
workspace.clone().into(),
Some(target_index),
target_index,
state,
)?;

Expand Down Expand Up @@ -321,7 +321,7 @@ fn invert_workspace_tiling_direction(
move_container_within_tree(
window_to_move.clone().into(),
workspace.clone().into(),
Some(target_index),
target_index,
state,
)?;

Expand Down Expand Up @@ -369,7 +369,7 @@ fn insert_into_ancestor(
move_container_within_tree(
window_to_move.clone().into(),
target_ancestor.clone().into(),
Some(target_index),
target_index,
state,
)?;

Expand Down
4 changes: 2 additions & 2 deletions packages/wm/src/windows/commands/move_window_to_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub fn move_window_to_workspace(
move_container_within_tree(
window.clone().into(),
insertion_sibling.clone().parent().context("No parent.")?,
Some(insertion_sibling.index() + 1),
insertion_sibling.index() + 1,
state,
)?;
}
Expand All @@ -102,7 +102,7 @@ pub fn move_window_to_workspace(
move_container_within_tree(
window.clone().into(),
target_workspace.clone().into(),
Some(target_workspace.child_count()),
target_workspace.child_count(),
state,
)?;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/wm/src/windows/commands/update_window_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn set_tiling(
move_container_within_tree(
tiling_window.clone().into(),
target_parent.clone(),
Some(target_index),
target_index,
state,
)?;

Expand Down Expand Up @@ -137,7 +137,7 @@ fn set_non_tiling(
move_container_within_tree(
window.clone().into(),
workspace.clone().into(),
Some(workspace.child_count()),
workspace.child_count(),
state,
)?;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn move_workspace_in_direction(
move_container_within_tree(
workspace.clone().into(),
target_monitor.clone().into(),
Some(target_monitor.child_count()),
target_monitor.child_count(),
state,
)?;

Expand Down

0 comments on commit 63caa2a

Please sign in to comment.