Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't group floating windows unless one is fully contained in the other #2527

Merged
merged 1 commit into from
May 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/renderer/rendered_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use skia_safe::{
canvas::SaveLayerRec,
image_filters::blur,
utils::shadow_utils::{draw_shadow, ShadowFlags},
BlendMode, Canvas, ClipOp, Color, Paint, Path, PathOp, Point3, Rect,
BlendMode, Canvas, ClipOp, Color, Contains, Paint, Path, PathOp, Point3, Rect,
};

use crate::units::{to_skia_rect, GridScale, PixelRect};
Expand Down Expand Up @@ -156,8 +156,8 @@ fn get_window_group(windows: &mut Vec<LayerWindow>, index: usize) -> usize {
windows[index].group
}

fn rect_intersect(a: &Rect, b: &Rect) -> bool {
Rect::intersects2(a, b)
fn rect_contains(a: &Rect, b: &Rect) -> bool {
Rect::contains(a, b) || Rect::contains(b, a)
}

fn group_windows_with_regions(windows: &mut Vec<LayerWindow>, regions: &[PixelRect<f32>]) {
Expand All @@ -166,7 +166,7 @@ fn group_windows_with_regions(windows: &mut Vec<LayerWindow>, regions: &[PixelRe
let group_i = get_window_group(windows, i);
let group_j = get_window_group(windows, j);
if group_i != group_j
&& rect_intersect(&to_skia_rect(&regions[i]), &to_skia_rect(&regions[j]))
&& rect_contains(&to_skia_rect(&regions[i]), &to_skia_rect(&regions[j]))
{
let new_group = group_i.min(group_j);
if group_i != group_j {
Expand Down