Fix compositor output routing and pointer hints; format imports
This commit is contained in:
1 parent
88e4f3c135
commit
46509f880a
108 files changed
+3682
-8371
No files matched your search
@@ -108,13 +108,7 @@ impl AnimatedValue {
|
||||
|
||||
for _ in 0..steps {
|
||||
let previous_error = self.current - self.target;
|
||||
advance_value(
|
||||
&mut self.current,
|
||||
self.target,
|
||||
&mut self.velocity,
|
||||
step,
|
||||
config,
|
||||
);
|
||||
advance_value(&mut self.current, self.target, &mut self.velocity, step, config);
|
||||
let current_error = self.current - self.target;
|
||||
if previous_error != 0.0 && previous_error.signum() != current_error.signum() {
|
||||
self.snap();
|
||||
@@ -163,20 +157,8 @@ impl AnimatedRect {
|
||||
let step = seconds / steps as f64;
|
||||
|
||||
for _ in 0..steps {
|
||||
advance_value(
|
||||
&mut self.current.x,
|
||||
self.target.x,
|
||||
&mut self.velocity.x,
|
||||
step,
|
||||
config,
|
||||
);
|
||||
advance_value(
|
||||
&mut self.current.y,
|
||||
self.target.y,
|
||||
&mut self.velocity.y,
|
||||
step,
|
||||
config,
|
||||
);
|
||||
advance_value(&mut self.current.x, self.target.x, &mut self.velocity.x, step, config);
|
||||
advance_value(&mut self.current.y, self.target.y, &mut self.velocity.y, step, config);
|
||||
advance_value(
|
||||
&mut self.current.width,
|
||||
self.target.width,
|
||||
@@ -321,12 +303,7 @@ impl WindowGeometry {
|
||||
self.client.request_size(size, now).then_some(size)
|
||||
}
|
||||
|
||||
pub fn set_presentation_target(
|
||||
&mut self,
|
||||
rect: Rect,
|
||||
fullscreen: bool,
|
||||
now: Duration,
|
||||
) -> Option<ClientSize> {
|
||||
pub fn set_presentation_target(&mut self, rect: Rect, fullscreen: bool, now: Duration) -> Option<ClientSize> {
|
||||
self.set_presentation_mode(
|
||||
rect,
|
||||
if fullscreen {
|
||||
@@ -338,12 +315,7 @@ impl WindowGeometry {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn set_presentation_mode(
|
||||
&mut self,
|
||||
rect: Rect,
|
||||
mode: PresentationMode,
|
||||
now: Duration,
|
||||
) -> Option<ClientSize> {
|
||||
pub fn set_presentation_mode(&mut self, rect: Rect, mode: PresentationMode, now: Duration) -> Option<ClientSize> {
|
||||
let rect = normalized_rect(rect);
|
||||
if self.mode != mode || (self.zoom.is_some() && self.logical != rect) {
|
||||
let mut progress = AnimatedValue::new(0.0);
|
||||
@@ -359,14 +331,9 @@ impl WindowGeometry {
|
||||
let speed = [velocity.x, velocity.y, velocity.width, velocity.height];
|
||||
let squared_length = distance.iter().map(|value| value * value).sum::<f64>();
|
||||
if squared_length > 0.001 {
|
||||
let projected =
|
||||
distance.iter().zip(speed).map(|(d, v)| d * v).sum::<f64>() / squared_length;
|
||||
let projected = distance.iter().zip(speed).map(|(d, v)| d * v).sum::<f64>() / squared_length;
|
||||
// Keep forward momentum; soften a reversal without jumping position.
|
||||
progress.velocity = if projected < 0.0 {
|
||||
projected * 0.35
|
||||
} else {
|
||||
projected
|
||||
};
|
||||
progress.velocity = if projected < 0.0 { projected * 0.35 } else { projected };
|
||||
}
|
||||
self.zoom = Some(ZoomTransition {
|
||||
from: self.visual.current,
|
||||
@@ -412,24 +379,14 @@ impl WindowGeometry {
|
||||
requested_size
|
||||
}
|
||||
|
||||
pub fn advance(
|
||||
&mut self,
|
||||
delta: Duration,
|
||||
config: SpringConfig,
|
||||
animations_enabled: bool,
|
||||
) -> bool {
|
||||
pub fn advance(&mut self, delta: Duration, config: SpringConfig, animations_enabled: bool) -> bool {
|
||||
let previous = (self.visual.current, self.decorations);
|
||||
let active = self.advance_presentation(delta, config, animations_enabled);
|
||||
self.presentation_changed = previous != (self.visual.current, self.decorations);
|
||||
active
|
||||
}
|
||||
|
||||
fn advance_presentation(
|
||||
&mut self,
|
||||
delta: Duration,
|
||||
config: SpringConfig,
|
||||
animations_enabled: bool,
|
||||
) -> bool {
|
||||
fn advance_presentation(&mut self, delta: Duration, config: SpringConfig, animations_enabled: bool) -> bool {
|
||||
if !animations_enabled {
|
||||
self.visual.snap();
|
||||
self.decorations = if self.is_fullscreen() { 0.0 } else { 1.0 };
|
||||
@@ -506,15 +463,8 @@ impl WindowGeometry {
|
||||
}
|
||||
}
|
||||
|
||||
fn advance_value(
|
||||
current: &mut f64,
|
||||
target: f64,
|
||||
velocity: &mut f64,
|
||||
delta: f64,
|
||||
config: SpringConfig,
|
||||
) {
|
||||
let acceleration =
|
||||
(-config.stiffness * (*current - target) - config.damping * *velocity) / config.mass;
|
||||
fn advance_value(current: &mut f64, target: f64, velocity: &mut f64, delta: f64, config: SpringConfig) {
|
||||
let acceleration = (-config.stiffness * (*current - target) - config.damping * *velocity) / config.mass;
|
||||
*velocity += acceleration * delta;
|
||||
let previous_error = *current - target;
|
||||
*current += *velocity * delta;
|
||||
@@ -641,17 +591,10 @@ mod tests {
|
||||
assert_eq!(geometry.visual.current, rect);
|
||||
assert_eq!(
|
||||
geometry.decorations,
|
||||
if mode == PresentationMode::Fullscreen {
|
||||
0.0
|
||||
} else {
|
||||
1.0
|
||||
}
|
||||
if mode == PresentationMode::Fullscreen { 0.0 } else { 1.0 }
|
||||
);
|
||||
assert!(!geometry.is_zooming());
|
||||
assert_eq!(
|
||||
geometry.is_fullscreen(),
|
||||
mode == PresentationMode::Fullscreen
|
||||
);
|
||||
assert_eq!(geometry.is_fullscreen(), mode == PresentationMode::Fullscreen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,9 +621,7 @@ mod tests {
|
||||
fn zoom_finishes_without_a_visible_final_edge_jump() {
|
||||
let tiled = Rect::new(12.0, 12.0, 942.0, 1056.0);
|
||||
let fullscreen = Rect::new(0.0, 0.0, 1920.0, 1080.0);
|
||||
for (start, target, fullscreen_target) in
|
||||
[(tiled, fullscreen, true), (fullscreen, tiled, false)]
|
||||
{
|
||||
for (start, target, fullscreen_target) in [(tiled, fullscreen, true), (fullscreen, tiled, false)] {
|
||||
let mut geometry = WindowGeometry::new(start, None);
|
||||
if !fullscreen_target {
|
||||
geometry.set_presentation_target(start, true, Duration::ZERO);
|
||||
@@ -690,11 +631,7 @@ mod tests {
|
||||
let mut finished = false;
|
||||
for _ in 0..1000 {
|
||||
let before = geometry.visual.current;
|
||||
if !geometry.advance(
|
||||
Duration::from_secs_f64(1.0 / 144.0),
|
||||
SpringConfig::default(),
|
||||
true,
|
||||
) {
|
||||
if !geometry.advance(Duration::from_secs_f64(1.0 / 144.0), SpringConfig::default(), true) {
|
||||
let right_before = before.x + before.width;
|
||||
let right_after = target.x + target.width;
|
||||
assert!(
|
||||
@@ -721,9 +658,7 @@ mod tests {
|
||||
let progress = 1.0 - geometry.decorations;
|
||||
let visual = geometry.visual.current;
|
||||
assert!((visual.x - (start.x + (end.x - start.x) * progress)).abs() < 1e-9);
|
||||
assert!(
|
||||
(visual.width - (start.width + (end.width - start.width) * progress)).abs() < 1e-9
|
||||
);
|
||||
assert!((visual.width - (start.width + (end.width - start.width) * progress)).abs() < 1e-9);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,11 +669,7 @@ mod tests {
|
||||
let mut geometry = WindowGeometry::new(tiled, None);
|
||||
for enabled in [true, false, true, false] {
|
||||
let before = (geometry.visual.current, geometry.decorations);
|
||||
geometry.set_presentation_target(
|
||||
if enabled { fullscreen } else { tiled },
|
||||
enabled,
|
||||
Duration::ZERO,
|
||||
);
|
||||
geometry.set_presentation_target(if enabled { fullscreen } else { tiled }, enabled, Duration::ZERO);
|
||||
assert_eq!((geometry.visual.current, geometry.decorations), before);
|
||||
geometry.advance(Duration::from_millis(48), SpringConfig::default(), true);
|
||||
}
|
||||
@@ -782,24 +713,15 @@ mod tests {
|
||||
Some(ClientSize::from_rect(middle))
|
||||
);
|
||||
geometry.advance(Duration::from_millis(64), SpringConfig::default(), true);
|
||||
assert_eq!(geometry.presentation_size_request(Duration::from_millis(64)), None);
|
||||
assert_eq!(
|
||||
geometry.presentation_size_request(Duration::from_millis(64)),
|
||||
None
|
||||
);
|
||||
assert_eq!(
|
||||
geometry.set_presentation_mode(
|
||||
end,
|
||||
PresentationMode::Normal,
|
||||
Duration::from_millis(64)
|
||||
),
|
||||
geometry.set_presentation_mode(end, PresentationMode::Normal, Duration::from_millis(64)),
|
||||
Some(ClientSize::from_rect(end))
|
||||
);
|
||||
let mut requests = Vec::new();
|
||||
for frame in 1..240 {
|
||||
geometry.advance(Duration::from_millis(8), SpringConfig::default(), true);
|
||||
if let Some(size) =
|
||||
geometry.presentation_size_request(Duration::from_millis(64 + frame * 8))
|
||||
{
|
||||
if let Some(size) = geometry.presentation_size_request(Duration::from_millis(64 + frame * 8)) {
|
||||
assert_eq!(geometry.visual.current.width, end.width);
|
||||
requests.push(size);
|
||||
}
|
||||
@@ -844,13 +766,8 @@ mod tests {
|
||||
true,
|
||||
);
|
||||
let current = geometry.visual.current;
|
||||
let edges = |rect: Rect| {
|
||||
[rect.x, rect.y, rect.x + rect.width, rect.y + rect.height]
|
||||
};
|
||||
for ((before, after), end) in edges(previous)
|
||||
.into_iter()
|
||||
.zip(edges(current))
|
||||
.zip(edges(target))
|
||||
let edges = |rect: Rect| [rect.x, rect.y, rect.x + rect.width, rect.y + rect.height];
|
||||
for ((before, after), end) in edges(previous).into_iter().zip(edges(current)).zip(edges(target))
|
||||
{
|
||||
assert!((after - end).abs() <= (before - end).abs() + 1e-9);
|
||||
}
|
||||
@@ -1004,11 +921,7 @@ mod tests {
|
||||
let mut geometry = WindowGeometry::new(rect, None);
|
||||
|
||||
assert!(geometry.set_logical_target(rect, Duration::ZERO).is_some());
|
||||
assert!(
|
||||
geometry
|
||||
.set_logical_target(rect, Duration::from_millis(16))
|
||||
.is_none()
|
||||
);
|
||||
assert!(geometry.set_logical_target(rect, Duration::from_millis(16)).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1067,10 +980,7 @@ mod tests {
|
||||
assert!(sixty.current.width <= target.width);
|
||||
}
|
||||
for _ in 0..288 {
|
||||
one_forty_four.advance(
|
||||
Duration::from_secs_f64(1.0 / 144.0),
|
||||
SpringConfig::default(),
|
||||
);
|
||||
one_forty_four.advance(Duration::from_secs_f64(1.0 / 144.0), SpringConfig::default());
|
||||
}
|
||||
|
||||
assert!(sixty.is_settled(SpringConfig::default()));
|
||||
|
||||
Reference in new issue
Block a user