mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-20 15:41:38 +01:00
refactor(windows): window_manager.rs reads frames through backend().frame()
Every WindowsApi::window_rect(hwnd) in window_manager.rs becomes backend().frame(WindowId::from_hwnd(hwnd)). WindowsBackend::frame is Window::window_rect, i.e. the same DWM call with the Win32 error kept; the callers' ?, ok(), unwrap_or_default() and is_ok_and() behave as before (only the error text can differ: a window that died meanwhile reports WindowGone). BEHAVIOUR: none intended; e2e gate needed: commands, layouts, workspaces, stacking. Verified: Windows clippy -D warnings via tools/fast-check PASS; e2e not run.
This commit is contained in:
1 parent
63904b736d
commit
a43d39635b
1 file changed
+29
-12
@@ -1219,7 +1219,7 @@ impl WindowManager {
|
||||
|
||||
for window in workspace.floating_windows().iter() {
|
||||
if window.hwnd == focused_hwnd {
|
||||
let mut rect = WindowsApi::window_rect(window.hwnd)?;
|
||||
let mut rect = backend().frame(WindowId::from_hwnd(window.hwnd))?;
|
||||
match (direction, sizing) {
|
||||
(OperationDirection::Left, Sizing::Increase) => {
|
||||
if rect.left - delta < focused_monitor_work_area.left {
|
||||
@@ -1897,7 +1897,7 @@ impl WindowManager {
|
||||
|
||||
if len > 1 {
|
||||
let focused_hwnd = WindowsApi::foreground_window()?;
|
||||
let focused_rect = WindowsApi::window_rect(focused_hwnd)?;
|
||||
let focused_rect = backend().frame(WindowId::from_hwnd(focused_hwnd))?;
|
||||
match direction {
|
||||
OperationDirection::Left => {
|
||||
let mut windows_in_direction = focused_workspace
|
||||
@@ -1905,8 +1905,12 @@ impl WindowManager {
|
||||
.iter()
|
||||
.enumerate()
|
||||
.flat_map(|(idx, w)| {
|
||||
(w.hwnd != focused_hwnd)
|
||||
.then_some(WindowsApi::window_rect(w.hwnd).ok().map(|r| (idx, r)))
|
||||
(w.hwnd != focused_hwnd).then_some(
|
||||
backend()
|
||||
.frame(WindowId::from_hwnd(w.hwnd))
|
||||
.ok()
|
||||
.map(|r| (idx, r)),
|
||||
)
|
||||
})
|
||||
.flatten()
|
||||
.flat_map(|(idx, r)| {
|
||||
@@ -1928,8 +1932,12 @@ impl WindowManager {
|
||||
.iter()
|
||||
.enumerate()
|
||||
.flat_map(|(idx, w)| {
|
||||
(w.hwnd != focused_hwnd)
|
||||
.then_some(WindowsApi::window_rect(w.hwnd).ok().map(|r| (idx, r)))
|
||||
(w.hwnd != focused_hwnd).then_some(
|
||||
backend()
|
||||
.frame(WindowId::from_hwnd(w.hwnd))
|
||||
.ok()
|
||||
.map(|r| (idx, r)),
|
||||
)
|
||||
})
|
||||
.flatten()
|
||||
.flat_map(|(idx, r)| {
|
||||
@@ -1951,8 +1959,12 @@ impl WindowManager {
|
||||
.iter()
|
||||
.enumerate()
|
||||
.flat_map(|(idx, w)| {
|
||||
(w.hwnd != focused_hwnd)
|
||||
.then_some(WindowsApi::window_rect(w.hwnd).ok().map(|r| (idx, r)))
|
||||
(w.hwnd != focused_hwnd).then_some(
|
||||
backend()
|
||||
.frame(WindowId::from_hwnd(w.hwnd))
|
||||
.ok()
|
||||
.map(|r| (idx, r)),
|
||||
)
|
||||
})
|
||||
.flatten()
|
||||
.flat_map(|(idx, r)| {
|
||||
@@ -1974,8 +1986,12 @@ impl WindowManager {
|
||||
.iter()
|
||||
.enumerate()
|
||||
.flat_map(|(idx, w)| {
|
||||
(w.hwnd != focused_hwnd)
|
||||
.then_some(WindowsApi::window_rect(w.hwnd).ok().map(|r| (idx, r)))
|
||||
(w.hwnd != focused_hwnd).then_some(
|
||||
backend()
|
||||
.frame(WindowId::from_hwnd(w.hwnd))
|
||||
.ok()
|
||||
.map(|r| (idx, r)),
|
||||
)
|
||||
})
|
||||
.flatten()
|
||||
.flat_map(|(idx, r)| {
|
||||
@@ -2367,7 +2383,7 @@ impl WindowManager {
|
||||
let focused_hwnd = WindowsApi::foreground_window()?;
|
||||
for window in focused_workspace.floating_windows().iter() {
|
||||
if window.hwnd == focused_hwnd {
|
||||
let mut rect = WindowsApi::window_rect(window.hwnd)?;
|
||||
let mut rect = backend().frame(WindowId::from_hwnd(window.hwnd))?;
|
||||
match direction {
|
||||
OperationDirection::Left => {
|
||||
if rect.left - delta < focused_monitor_work_area.left {
|
||||
@@ -4066,7 +4082,8 @@ fn workspace_transition_plan(
|
||||
.into_iter()
|
||||
.filter(|window| !window.is_miminized())
|
||||
.filter_map(|window| {
|
||||
WindowsApi::window_rect(window.hwnd)
|
||||
backend()
|
||||
.frame(WindowId::from_hwnd(window.hwnd))
|
||||
.ok()
|
||||
.map(|rect| (window.hwnd, rect))
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user