shell: Add zoom UI
This commit is contained in:
parent
55e4dd7c0f
commit
f72d2b91f3
10 changed files with 1247 additions and 261 deletions
|
|
@ -20,6 +20,7 @@ pub trait PointExt<C: Coordinate> {
|
|||
|
||||
pub trait PointGlobalExt<C: Coordinate> {
|
||||
fn to_local(self, output: &Output) -> Point<C, Local>;
|
||||
fn to_zoomed(self, output: &Output, level: f64) -> Point<C, Local>;
|
||||
fn as_logical(self) -> Point<C, Logical>;
|
||||
}
|
||||
|
||||
|
|
@ -65,6 +66,14 @@ impl<C: Coordinate> PointGlobalExt<C> for Point<C, Global> {
|
|||
(C::from_f64(point.x), C::from_f64(point.y)).into()
|
||||
}
|
||||
|
||||
fn to_zoomed(self, output: &Output, level: f64) -> Point<C, Local> {
|
||||
let zoomed_output_geometry = output.zoomed_geometry(level).unwrap();
|
||||
let point = (self.to_f64() - zoomed_output_geometry.loc.to_f64())
|
||||
.upscale(level)
|
||||
.as_logical();
|
||||
(C::from_f64(point.x), C::from_f64(point.y)).into()
|
||||
}
|
||||
|
||||
fn as_logical(self) -> Point<C, Logical> {
|
||||
(self.x, self.y).into()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,13 @@ use smithay::{
|
|||
};
|
||||
|
||||
pub use super::geometry::*;
|
||||
use crate::config::{AdaptiveSync, OutputConfig, OutputState};
|
||||
pub use crate::shell::{SeatExt, Shell, Workspace};
|
||||
pub use crate::state::{Common, State};
|
||||
pub use crate::wayland::handlers::xdg_shell::popup::update_reactive_popups;
|
||||
use crate::{
|
||||
config::{AdaptiveSync, OutputConfig, OutputState},
|
||||
shell::zoom::OutputZoomState,
|
||||
};
|
||||
|
||||
use std::{
|
||||
cell::{Ref, RefCell, RefMut},
|
||||
|
|
@ -20,6 +23,8 @@ use std::{
|
|||
|
||||
pub trait OutputExt {
|
||||
fn geometry(&self) -> Rectangle<i32, Global>;
|
||||
fn zoomed_geometry(&self, level: f64) -> Option<Rectangle<i32, Global>>;
|
||||
|
||||
fn adaptive_sync(&self) -> AdaptiveSync;
|
||||
fn set_adaptive_sync(&self, vrr: AdaptiveSync);
|
||||
fn adaptive_sync_support(&self) -> Option<Support>;
|
||||
|
|
@ -52,6 +57,21 @@ impl OutputExt for Output {
|
|||
.as_global()
|
||||
}
|
||||
|
||||
fn zoomed_geometry(&self, level: f64) -> Option<Rectangle<i32, Global>> {
|
||||
let output_geometry = self.geometry();
|
||||
|
||||
let output_state = self.user_data().get::<Mutex<OutputZoomState>>()?;
|
||||
let mut output_state_ref = output_state.lock().unwrap();
|
||||
|
||||
let focal_point = output_state_ref.focal_point().to_global(self);
|
||||
let mut zoomed_output_geo = output_geometry.to_f64();
|
||||
zoomed_output_geo.loc -= focal_point;
|
||||
zoomed_output_geo = zoomed_output_geo.downscale(level);
|
||||
zoomed_output_geo.loc += focal_point;
|
||||
|
||||
Some(zoomed_output_geo.to_i32_round())
|
||||
}
|
||||
|
||||
fn adaptive_sync(&self) -> AdaptiveSync {
|
||||
self.user_data()
|
||||
.get::<Vrr>()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue