mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-14 04:43:42 +01:00
refactor(mac): name the Window frame query window_rect, as the Backend and the Windows Window do
Renames Window::frame (added two revisions back) to Window::window_rect and its 28 callers: Backend::window_rect is the shared name, and the Windows Window got the same one (wip-u-kfw mkwoqsvs). Same body; nothing changes at runtime. Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified: cannot run or unit-test on Linux.
This commit is contained in:
1 parent
d30a3eb686
commit
931b17d748
7 files changed
+30
-30
No files matched your search
@@ -1,6 +1,6 @@
|
||||
//! `MacosBackend`: the shared [`komorebi_backend::Backend`] over the existing [`MacosApi`] and
|
||||
//! [`Window`] methods (set_rect, focus, raise, hide, restore, minimize, unminimize, close, alive,
|
||||
//! frame and minimized): it holds no Accessibility call of its own.
|
||||
//! window_rect and minimized): it holds no Accessibility call of its own.
|
||||
//!
|
||||
//! **Nothing uses it yet.** The daemon still holds `Window` values (element, application and
|
||||
//! observer) and calls them directly; this adapter exists so that the trait is known to be
|
||||
@@ -131,7 +131,7 @@ impl MacosBackend {
|
||||
id: WindowId::from_u32(window.id),
|
||||
pid: window.application.process_id,
|
||||
// the Accessibility position and size, in points; a failure leaves the default
|
||||
rect: window.frame()
|
||||
rect: window.window_rect()
|
||||
.map(Rect::from)
|
||||
.unwrap_or_default(),
|
||||
minimized: window.minimized(),
|
||||
|
||||
@@ -637,7 +637,7 @@ impl WindowManager {
|
||||
// Sort by window area
|
||||
window_idx_pairs.sort_by_key(|(_, w)| {
|
||||
let rect =
|
||||
Rect::from(w.frame().unwrap_or_default());
|
||||
Rect::from(w.window_rect().unwrap_or_default());
|
||||
rect.right * rect.bottom
|
||||
});
|
||||
window_idx_pairs.reverse();
|
||||
@@ -707,7 +707,7 @@ impl WindowManager {
|
||||
// Sort by window area
|
||||
window_idx_pairs.sort_by_key(|w| {
|
||||
let rect = Rect::from(
|
||||
w.frame().unwrap_or_default(),
|
||||
w.window_rect().unwrap_or_default(),
|
||||
);
|
||||
rect.right * rect.bottom
|
||||
});
|
||||
|
||||
@@ -260,7 +260,7 @@ impl WindowManager {
|
||||
&& window.application.process_id == process_id
|
||||
{
|
||||
let tab_rect = MacosApi::window_rect(&element)?;
|
||||
let main_rect = match window.frame() {
|
||||
let main_rect = match window.window_rect() {
|
||||
Ok(rect) => rect,
|
||||
Err(AccessibilityError::Api(
|
||||
AccessibilityApiError::InvalidUIElement,
|
||||
@@ -328,7 +328,7 @@ impl WindowManager {
|
||||
&& window.application.process_id == process_id
|
||||
{
|
||||
let tab_rect = MacosApi::window_rect(&element)?;
|
||||
let main_rect = match window.frame() {
|
||||
let main_rect = match window.window_rect() {
|
||||
Ok(rect) => rect,
|
||||
Err(AccessibilityError::Api(
|
||||
AccessibilityApiError::InvalidUIElement,
|
||||
@@ -553,7 +553,7 @@ impl WindowManager {
|
||||
if window.application.name().unwrap_or_default() == application_name
|
||||
{
|
||||
let tab_rect = MacosApi::window_rect(element)?;
|
||||
let main_rect = window.frame()?;
|
||||
let main_rect = window.window_rect()?;
|
||||
// BOTH conditions must be true:
|
||||
// 1. Geometry matches (original check - preserves existing behavior)
|
||||
// 2. Window IDs match (new check - prevents false positives)
|
||||
@@ -897,7 +897,7 @@ impl WindowManager {
|
||||
{
|
||||
// TODO: not sure about this clone
|
||||
let window = window.clone();
|
||||
let new_position = Rect::from(window.frame()?);
|
||||
let new_position = Rect::from(window.window_rect()?);
|
||||
let old_position = *workspace
|
||||
.latest_layout
|
||||
.get(focused_container_idx)
|
||||
@@ -1102,7 +1102,7 @@ impl WindowManager {
|
||||
&& let Some(window) =
|
||||
container.windows().iter().find(|w| w.id == window_id)
|
||||
{
|
||||
let started_from = Rect::from(window.frame()?);
|
||||
let started_from = Rect::from(window.window_rect()?);
|
||||
|
||||
let pending_resize_op = Arc::make_mut(&mut self.pending_resize_op);
|
||||
*pending_resize_op = Option::from((window_id, Some(started_from)));
|
||||
@@ -1162,7 +1162,7 @@ impl WindowManager {
|
||||
&& let Some(window) =
|
||||
container.windows().iter().find(|w| w.id == window_id)
|
||||
{
|
||||
let ended_at = Rect::from(window.frame()?);
|
||||
let ended_at = Rect::from(window.window_rect()?);
|
||||
|
||||
tracing::info!("resizing with mouse");
|
||||
redraw |= self.resize_by_drag(window_id, started_from, ended_at)?;
|
||||
|
||||
@@ -184,7 +184,7 @@ impl WindowManager {
|
||||
}
|
||||
|
||||
let _ = window.set_messaging_timeout(LOOK_TIMEOUT);
|
||||
let rect = window.frame().map(Rect::from);
|
||||
let rect = window.window_rect().map(Rect::from);
|
||||
let _ = window.set_messaging_timeout(0.0);
|
||||
|
||||
if let Ok(rect) = rect
|
||||
|
||||
@@ -520,7 +520,7 @@ impl Serialize for Window {
|
||||
state.serialize_field("id", &self.id)?;
|
||||
state.serialize_field(
|
||||
"rect",
|
||||
&Rect::from(self.frame().unwrap_or_default()),
|
||||
&Rect::from(self.window_rect().unwrap_or_default()),
|
||||
)?;
|
||||
state.serialize_field("details", &WindowDetails::from(self))?;
|
||||
state.end()
|
||||
@@ -570,7 +570,7 @@ impl Window {
|
||||
}
|
||||
|
||||
/// The frame query (`Backend::window_rect`): the Accessibility position and size, in points.
|
||||
pub fn frame(&self) -> Result<CGRect, AccessibilityError> {
|
||||
pub fn window_rect(&self) -> Result<CGRect, AccessibilityError> {
|
||||
MacosApi::window_rect(&self.element)
|
||||
}
|
||||
|
||||
@@ -633,7 +633,7 @@ impl Window {
|
||||
// it happened to be when it was hidden
|
||||
let rect = match animator::take_over(self.id) {
|
||||
Some(target) => CGRect::from(target),
|
||||
None => self.frame()?,
|
||||
None => self.window_rect()?,
|
||||
};
|
||||
|
||||
let mut window_restore_positions = WINDOW_RESTORE_POSITIONS.lock();
|
||||
@@ -717,7 +717,7 @@ impl Window {
|
||||
|
||||
let rect = match animator::target(self.id) {
|
||||
Some(target) => CGRect::from(target),
|
||||
None => self.frame()?,
|
||||
None => self.window_rect()?,
|
||||
};
|
||||
|
||||
let Some(screen) = screen.or_else(|| CoreGraphicsApi::display_bounds_for_window_rect(rect))
|
||||
@@ -978,7 +978,7 @@ impl Window {
|
||||
// the window manager is waiting for this, and so is every window after this one
|
||||
let _ = self.set_messaging_timeout(ARRIVAL_TIMEOUT);
|
||||
|
||||
match self.frame() {
|
||||
match self.window_rect() {
|
||||
Ok(actual) => arrival::report(self.id, *target, Rect::from(actual)),
|
||||
Err(error) => {
|
||||
tracing::debug!(
|
||||
@@ -1007,7 +1007,7 @@ impl Window {
|
||||
return;
|
||||
}
|
||||
|
||||
let Ok(current) = self.frame() else {
|
||||
let Ok(current) = self.window_rect() else {
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -1099,7 +1099,7 @@ impl Window {
|
||||
motion,
|
||||
after: None,
|
||||
},
|
||||
|| self.frame().map(Rect::from),
|
||||
|| self.window_rect().map(Rect::from),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1214,7 +1214,7 @@ impl Window {
|
||||
let target_width = (target_height * aspect_ratio_width) / aspect_ratio_height;
|
||||
(target_width, target_height)
|
||||
} else {
|
||||
let current_rect = Rect::from(self.frame()?);
|
||||
let current_rect = Rect::from(self.window_rect()?);
|
||||
(current_rect.right, current_rect.bottom)
|
||||
};
|
||||
|
||||
@@ -1234,7 +1234,7 @@ impl Window {
|
||||
current_area: &Rect,
|
||||
target_area: &Rect,
|
||||
) -> Result<(), AccessibilityError> {
|
||||
let current_rect = Rect::from(self.frame()?);
|
||||
let current_rect = Rect::from(self.window_rect()?);
|
||||
let x_diff = target_area.left - current_area.left;
|
||||
let y_diff = target_area.top - current_area.top;
|
||||
let x_ratio = f32::abs((target_area.right as f32) / (current_area.right as f32));
|
||||
|
||||
@@ -279,7 +279,7 @@ impl WindowManager {
|
||||
.enumerate()
|
||||
.flat_map(|(idx, w)| {
|
||||
(w.id != focused_window_id).then_some(
|
||||
w.frame()
|
||||
w.window_rect()
|
||||
.ok()
|
||||
.map(|r| (idx, Rect::from(r))),
|
||||
)
|
||||
@@ -305,7 +305,7 @@ impl WindowManager {
|
||||
.enumerate()
|
||||
.flat_map(|(idx, w)| {
|
||||
(w.id != focused_window_id).then_some(
|
||||
w.frame()
|
||||
w.window_rect()
|
||||
.ok()
|
||||
.map(|r| (idx, Rect::from(r))),
|
||||
)
|
||||
@@ -331,7 +331,7 @@ impl WindowManager {
|
||||
.enumerate()
|
||||
.flat_map(|(idx, w)| {
|
||||
(w.id != focused_window_id).then_some(
|
||||
w.frame()
|
||||
w.window_rect()
|
||||
.ok()
|
||||
.map(|r| (idx, Rect::from(r))),
|
||||
)
|
||||
@@ -357,7 +357,7 @@ impl WindowManager {
|
||||
.enumerate()
|
||||
.flat_map(|(idx, w)| {
|
||||
(w.id != focused_window_id).then_some(
|
||||
w.frame()
|
||||
w.window_rect()
|
||||
.ok()
|
||||
.map(|r| (idx, Rect::from(r))),
|
||||
)
|
||||
@@ -747,7 +747,7 @@ impl WindowManager {
|
||||
MacosApi::foreground_window_id().ok_or_eyre("no foreground window")?;
|
||||
for window in focused_workspace.floating_windows().iter() {
|
||||
if window.id == focused_window_id {
|
||||
let mut rect = Rect::from(window.frame()?);
|
||||
let mut rect = Rect::from(window.window_rect()?);
|
||||
match direction {
|
||||
OperationDirection::Left => {
|
||||
if rect.left - delta < focused_monitor_work_area.left {
|
||||
@@ -1475,7 +1475,7 @@ impl WindowManager {
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter_map(|window| {
|
||||
window.frame()
|
||||
window.window_rect()
|
||||
.ok()
|
||||
.map(|rect| (window.id, Rect::from(rect)))
|
||||
})
|
||||
@@ -1696,7 +1696,7 @@ impl WindowManager {
|
||||
|
||||
for window in workspace.floating_windows().iter() {
|
||||
if window.id == focused_window_id {
|
||||
let mut rect = Rect::from(window.frame()?);
|
||||
let mut rect = Rect::from(window.window_rect()?);
|
||||
match (direction, sizing) {
|
||||
(OperationDirection::Left, Sizing::Increase) => {
|
||||
if rect.left - delta < focused_monitor_work_area.left {
|
||||
|
||||
@@ -553,7 +553,7 @@ impl Workspace {
|
||||
&& focused_window.application.process_id == process_id
|
||||
{
|
||||
if !valid_window_ids.contains(&focused_window.id) {
|
||||
if let Ok(rect) = focused_window.frame() {
|
||||
if let Ok(rect) = focused_window.window_rect() {
|
||||
tracing::debug!(
|
||||
"reaping window {} ({}): rect = {:?}",
|
||||
focused_window.id,
|
||||
@@ -578,7 +578,7 @@ impl Workspace {
|
||||
if focused_window.application.process_id == process_id
|
||||
&& !valid_window_ids.contains(&focused_window.id)
|
||||
{
|
||||
if let Ok(rect) = focused_window.frame() {
|
||||
if let Ok(rect) = focused_window.window_rect() {
|
||||
tracing::debug!(
|
||||
"reaping monocle window {} ({}): rect = {:?}",
|
||||
focused_window.id,
|
||||
@@ -599,7 +599,7 @@ impl Workspace {
|
||||
for window in self.floating_windows() {
|
||||
if window.application.process_id == process_id {
|
||||
if !valid_window_ids.contains(&window.id) {
|
||||
if let Ok(rect) = window.frame() {
|
||||
if let Ok(rect) = window.window_rect() {
|
||||
tracing::debug!(
|
||||
"reaping floating window {} ({}): rect = {:?}",
|
||||
window.id,
|
||||
|
||||
Reference in new issue
Block a user