mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
layout/scrolling: Store parent_area in ScrollingSpace
This commit is contained in:
+19
-6
@@ -75,6 +75,12 @@ pub struct ScrollingSpace<W: LayoutElement> {
|
|||||||
/// Takes into account layer-shell exclusive zones and niri struts.
|
/// Takes into account layer-shell exclusive zones and niri struts.
|
||||||
working_area: Rectangle<f64, Logical>,
|
working_area: Rectangle<f64, Logical>,
|
||||||
|
|
||||||
|
/// Working area for this space excluding struts.
|
||||||
|
///
|
||||||
|
/// Used for popup unconstraining. Popups can go over struts, but they shouldn't go over
|
||||||
|
/// the layer-shell top layer (which renders on top of popups).
|
||||||
|
parent_area: Rectangle<f64, Logical>,
|
||||||
|
|
||||||
/// Scale of the output the space is on (and rounds its sizes to).
|
/// Scale of the output the space is on (and rounds its sizes to).
|
||||||
scale: f64,
|
scale: f64,
|
||||||
|
|
||||||
@@ -251,12 +257,12 @@ pub enum ScrollDirection {
|
|||||||
impl<W: LayoutElement> ScrollingSpace<W> {
|
impl<W: LayoutElement> ScrollingSpace<W> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
view_size: Size<f64, Logical>,
|
view_size: Size<f64, Logical>,
|
||||||
working_area: Rectangle<f64, Logical>,
|
parent_area: Rectangle<f64, Logical>,
|
||||||
scale: f64,
|
scale: f64,
|
||||||
clock: Clock,
|
clock: Clock,
|
||||||
options: Rc<Options>,
|
options: Rc<Options>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let working_area = compute_working_area(working_area, scale, options.struts);
|
let working_area = compute_working_area(parent_area, scale, options.struts);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
columns: Vec::new(),
|
columns: Vec::new(),
|
||||||
@@ -269,6 +275,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
|||||||
closing_windows: Vec::new(),
|
closing_windows: Vec::new(),
|
||||||
view_size,
|
view_size,
|
||||||
working_area,
|
working_area,
|
||||||
|
parent_area,
|
||||||
scale,
|
scale,
|
||||||
clock,
|
clock,
|
||||||
options,
|
options,
|
||||||
@@ -278,11 +285,11 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
|||||||
pub fn update_config(
|
pub fn update_config(
|
||||||
&mut self,
|
&mut self,
|
||||||
view_size: Size<f64, Logical>,
|
view_size: Size<f64, Logical>,
|
||||||
working_area: Rectangle<f64, Logical>,
|
parent_area: Rectangle<f64, Logical>,
|
||||||
scale: f64,
|
scale: f64,
|
||||||
options: Rc<Options>,
|
options: Rc<Options>,
|
||||||
) {
|
) {
|
||||||
let working_area = compute_working_area(working_area, scale, options.struts);
|
let working_area = compute_working_area(parent_area, scale, options.struts);
|
||||||
|
|
||||||
for (column, data) in zip(&mut self.columns, &mut self.data) {
|
for (column, data) in zip(&mut self.columns, &mut self.data) {
|
||||||
column.update_config(view_size, working_area, scale, options.clone());
|
column.update_config(view_size, working_area, scale, options.clone());
|
||||||
@@ -291,6 +298,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
|||||||
|
|
||||||
self.view_size = view_size;
|
self.view_size = view_size;
|
||||||
self.working_area = working_area;
|
self.working_area = working_area;
|
||||||
|
self.parent_area = parent_area;
|
||||||
self.scale = scale;
|
self.scale = scale;
|
||||||
self.options = options;
|
self.options = options;
|
||||||
|
|
||||||
@@ -3534,6 +3542,11 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
|||||||
self.view_size
|
self.view_size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub fn parent_area(&self) -> Rectangle<f64, Logical> {
|
||||||
|
self.parent_area
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub fn clock(&self) -> &Clock {
|
pub fn clock(&self) -> &Clock {
|
||||||
&self.clock
|
&self.clock
|
||||||
@@ -3555,7 +3568,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub fn verify_invariants(&self, working_area: Rectangle<f64, Logical>) {
|
pub fn verify_invariants(&self) {
|
||||||
assert!(self.view_size.w > 0.);
|
assert!(self.view_size.w > 0.);
|
||||||
assert!(self.view_size.h > 0.);
|
assert!(self.view_size.h > 0.);
|
||||||
assert!(self.scale > 0.);
|
assert!(self.scale > 0.);
|
||||||
@@ -3563,7 +3576,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
|||||||
assert_eq!(self.columns.len(), self.data.len());
|
assert_eq!(self.columns.len(), self.data.len());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
self.working_area,
|
self.working_area,
|
||||||
compute_working_area(working_area, self.scale, self.options.struts)
|
compute_working_area(self.parent_area, self.scale, self.options.struts)
|
||||||
);
|
);
|
||||||
|
|
||||||
if !self.columns.is_empty() {
|
if !self.columns.is_empty() {
|
||||||
|
|||||||
@@ -1784,9 +1784,10 @@ impl<W: LayoutElement> Workspace<W> {
|
|||||||
assert!(scale.is_finite());
|
assert!(scale.is_finite());
|
||||||
|
|
||||||
assert_eq!(self.view_size, self.scrolling.view_size());
|
assert_eq!(self.view_size, self.scrolling.view_size());
|
||||||
|
assert_eq!(self.working_area, self.scrolling.parent_area());
|
||||||
assert_eq!(&self.clock, self.scrolling.clock());
|
assert_eq!(&self.clock, self.scrolling.clock());
|
||||||
assert!(Rc::ptr_eq(&self.options, self.scrolling.options()));
|
assert!(Rc::ptr_eq(&self.options, self.scrolling.options()));
|
||||||
self.scrolling.verify_invariants(self.working_area);
|
self.scrolling.verify_invariants();
|
||||||
|
|
||||||
assert_eq!(self.view_size, self.floating.view_size());
|
assert_eq!(self.view_size, self.floating.view_size());
|
||||||
assert_eq!(self.working_area, self.floating.working_area());
|
assert_eq!(self.working_area, self.floating.working_area());
|
||||||
|
|||||||
Reference in New Issue
Block a user