utils: New geometry spaces local/global
This commit is contained in:
parent
c38a236ffa
commit
42aaafe586
18 changed files with 516 additions and 300 deletions
|
|
@ -4,7 +4,7 @@ use crate::{
|
|||
GlMultiError, GlMultiFrame, GlMultiRenderer,
|
||||
},
|
||||
state::State,
|
||||
utils::prelude::SeatExt,
|
||||
utils::prelude::*,
|
||||
};
|
||||
use calloop::LoopHandle;
|
||||
use id_tree::NodeId;
|
||||
|
|
@ -94,8 +94,8 @@ pub struct CosmicMapped {
|
|||
//tiling
|
||||
pub tiling_node_id: Arc<Mutex<Option<NodeId>>>,
|
||||
//floating
|
||||
pub(super) last_geometry: Arc<Mutex<Option<Rectangle<i32, Logical>>>>,
|
||||
pub(super) resize_state: Arc<Mutex<Option<ResizeState>>>,
|
||||
pub last_geometry: Arc<Mutex<Option<Rectangle<i32, Local>>>>,
|
||||
|
||||
#[cfg(feature = "debug")]
|
||||
debug: Arc<Mutex<Option<smithay_egui::EguiState>>>,
|
||||
|
|
@ -108,6 +108,7 @@ impl fmt::Debug for CosmicMapped {
|
|||
.field("last_cursor_position", &self.last_cursor_position)
|
||||
.field("tiling_node_id", &self.tiling_node_id)
|
||||
.field("resize_state", &self.resize_state)
|
||||
.field("last_geometry", &self.last_geometry)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
|
@ -361,7 +362,7 @@ impl CosmicMapped {
|
|||
window.is_activated(pending)
|
||||
}
|
||||
|
||||
pub fn set_geometry(&self, geo: Rectangle<i32, Logical>) {
|
||||
pub fn set_geometry(&self, geo: Rectangle<i32, Global>) {
|
||||
match &self.element {
|
||||
CosmicMappedInternal::Stack(s) => s.set_geometry(geo),
|
||||
CosmicMappedInternal::Window(w) => w.set_geometry(geo),
|
||||
|
|
@ -501,11 +502,9 @@ impl CosmicMapped {
|
|||
|
||||
let stack = CosmicStack::new(std::iter::once(surface), handle);
|
||||
if let Some(geo) = self.last_geometry.lock().unwrap().clone() {
|
||||
stack.set_geometry(geo);
|
||||
}
|
||||
for (output, overlap) in outputs {
|
||||
stack.output_enter(output, overlap);
|
||||
stack.set_geometry(geo.to_global(&output));
|
||||
}
|
||||
stack.output_enter(output, overlap);
|
||||
stack.set_activate(activated);
|
||||
stack.active().send_configure();
|
||||
stack.refresh();
|
||||
|
|
@ -527,11 +526,9 @@ impl CosmicMapped {
|
|||
let window = CosmicWindow::new(surface, handle);
|
||||
|
||||
if let Some(geo) = self.last_geometry.lock().unwrap().clone() {
|
||||
window.set_geometry(geo);
|
||||
}
|
||||
for (output, overlap) in outputs {
|
||||
window.output_enter(output, overlap);
|
||||
window.set_geometry(geo.to_global(&output));
|
||||
}
|
||||
window.output_enter(output, overlap);
|
||||
window.set_activate(self.is_activated(true));
|
||||
window.surface().send_configure();
|
||||
window.refresh();
|
||||
|
|
@ -1068,8 +1065,8 @@ impl From<CosmicWindow> for CosmicMapped {
|
|||
element: CosmicMappedInternal::Window(w),
|
||||
last_cursor_position: Arc::new(Mutex::new(HashMap::new())),
|
||||
tiling_node_id: Arc::new(Mutex::new(None)),
|
||||
last_geometry: Arc::new(Mutex::new(None)),
|
||||
resize_state: Arc::new(Mutex::new(None)),
|
||||
last_geometry: Arc::new(Mutex::new(None)),
|
||||
#[cfg(feature = "debug")]
|
||||
debug: Arc::new(Mutex::new(None)),
|
||||
}
|
||||
|
|
@ -1082,8 +1079,8 @@ impl From<CosmicStack> for CosmicMapped {
|
|||
element: CosmicMappedInternal::Stack(s),
|
||||
last_cursor_position: Arc::new(Mutex::new(HashMap::new())),
|
||||
tiling_node_id: Arc::new(Mutex::new(None)),
|
||||
last_geometry: Arc::new(Mutex::new(None)),
|
||||
resize_state: Arc::new(Mutex::new(None)),
|
||||
last_geometry: Arc::new(Mutex::new(None)),
|
||||
#[cfg(feature = "debug")]
|
||||
debug: Arc::new(Mutex::new(None)),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
},
|
||||
state::State,
|
||||
utils::iced::{IcedElement, Program},
|
||||
utils::prelude::SeatExt,
|
||||
utils::prelude::*,
|
||||
wayland::handlers::screencopy::ScreencopySessions,
|
||||
};
|
||||
use calloop::LoopHandle;
|
||||
|
|
@ -91,7 +91,7 @@ pub struct CosmicStackInternal {
|
|||
override_alive: Arc<AtomicBool>,
|
||||
last_seat: Arc<Mutex<Option<(Seat<State>, Serial)>>>,
|
||||
last_location: Arc<Mutex<Option<(Point<f64, Logical>, Serial, u32)>>>,
|
||||
geometry: Arc<Mutex<Option<Rectangle<i32, Logical>>>>,
|
||||
geometry: Arc<Mutex<Option<Rectangle<i32, Global>>>>,
|
||||
mask: Arc<Mutex<Option<tiny_skia::Mask>>>,
|
||||
}
|
||||
|
||||
|
|
@ -406,7 +406,7 @@ impl CosmicStack {
|
|||
Point::from((0, TAB_HEIGHT))
|
||||
}
|
||||
|
||||
pub fn set_geometry(&self, geo: Rectangle<i32, Logical>) {
|
||||
pub fn set_geometry(&self, geo: Rectangle<i32, Global>) {
|
||||
self.0.with_program(|p| {
|
||||
let loc = (geo.loc.x, geo.loc.y + TAB_HEIGHT);
|
||||
let size = (geo.size.w, geo.size.h - TAB_HEIGHT);
|
||||
|
|
@ -1047,11 +1047,11 @@ impl PointerTarget<State> for CosmicStack {
|
|||
if let Some(workspace) = data.common.shell.space_for(stack_mapped) {
|
||||
// TODO: Unify this somehow with Shell::move_request/Workspace::move_request
|
||||
let button = 0x110; // BTN_LEFT
|
||||
let pos = event.location;
|
||||
let pos = event.location.as_global();
|
||||
let start_data = PointerGrabStartData {
|
||||
focus: None,
|
||||
button,
|
||||
location: pos,
|
||||
location: pos.as_logical(),
|
||||
};
|
||||
let mapped = CosmicMapped::from(CosmicWindow::new(
|
||||
surface,
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ use smithay::{
|
|||
|
||||
use crate::{
|
||||
state::{State, SurfaceDmabufFeedback},
|
||||
utils::prelude::*,
|
||||
wayland::handlers::decoration::PreferredDecorationMode,
|
||||
};
|
||||
|
||||
|
|
@ -122,13 +123,13 @@ impl CosmicSurface {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_geometry(&self, geo: Rectangle<i32, Logical>) {
|
||||
pub fn set_geometry(&self, geo: Rectangle<i32, Global>) {
|
||||
match self {
|
||||
CosmicSurface::Wayland(window) => window
|
||||
.toplevel()
|
||||
.with_pending_state(|state| state.size = Some(geo.size)),
|
||||
.with_pending_state(|state| state.size = Some(geo.size.as_logical())),
|
||||
CosmicSurface::X11(surface) => {
|
||||
let _ = surface.configure(geo);
|
||||
let _ = surface.configure(geo.as_logical());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
state::State,
|
||||
utils::{
|
||||
iced::{IcedElement, Program},
|
||||
prelude::SeatExt,
|
||||
prelude::*,
|
||||
},
|
||||
wayland::handlers::screencopy::ScreencopySessions,
|
||||
};
|
||||
|
|
@ -132,7 +132,7 @@ impl CosmicWindow {
|
|||
))
|
||||
}
|
||||
|
||||
pub fn set_geometry(&self, geo: Rectangle<i32, Logical>) {
|
||||
pub fn set_geometry(&self, geo: Rectangle<i32, Global>) {
|
||||
self.0.with_program(|p| {
|
||||
let loc = (
|
||||
geo.loc.x,
|
||||
|
|
|
|||
|
|
@ -82,15 +82,21 @@ impl MoveGrabState {
|
|||
|
||||
let mut window_geo = self.window.geometry();
|
||||
window_geo.loc += cursor_at.to_i32_round() + self.window_offset;
|
||||
if !output.geometry().intersection(window_geo).is_some() {
|
||||
if !output
|
||||
.geometry()
|
||||
.as_logical()
|
||||
.intersection(window_geo)
|
||||
.is_some()
|
||||
{
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
let output_scale: Scale<f64> = output.current_scale().fractional_scale().into();
|
||||
let scaling_offset =
|
||||
self.window_offset - self.window_offset.to_f64().upscale(scale).to_i32_round();
|
||||
let render_location =
|
||||
cursor_at.to_i32_round() - output.geometry().loc + self.window_offset - scaling_offset;
|
||||
let render_location = cursor_at.to_i32_round() - output.geometry().loc.as_logical()
|
||||
+ self.window_offset
|
||||
- scaling_offset;
|
||||
|
||||
let focus_element = if self.indicator_thickness > 0 {
|
||||
Some(
|
||||
|
|
@ -105,7 +111,8 @@ impl MoveGrabState {
|
|||
.to_f64()
|
||||
.upscale(scale)
|
||||
.to_i32_round(),
|
||||
),
|
||||
)
|
||||
.as_local(),
|
||||
self.indicator_thickness,
|
||||
output_scale.x,
|
||||
1.0,
|
||||
|
|
@ -208,6 +215,7 @@ impl PointerGrab<State> for MoveGrab {
|
|||
.find(|output| {
|
||||
output
|
||||
.geometry()
|
||||
.as_logical()
|
||||
.contains(handle.current_location().to_i32_round())
|
||||
})
|
||||
.cloned()
|
||||
|
|
@ -233,8 +241,8 @@ impl PointerGrab<State> for MoveGrab {
|
|||
if let Some(grab_state) = borrow.as_mut().and_then(|s| s.as_mut()) {
|
||||
let mut window_geo = self.window.geometry();
|
||||
window_geo.loc += event.location.to_i32_round() + grab_state.window_offset;
|
||||
for output in &state.common.shell.outputs {
|
||||
if let Some(overlap) = output.geometry().intersection(window_geo) {
|
||||
for output in state.common.shell.outputs() {
|
||||
if let Some(overlap) = output.geometry().as_logical().intersection(window_geo) {
|
||||
if self.window_outputs.insert(output.clone()) {
|
||||
self.window.output_enter(output, overlap);
|
||||
if let Some(indicator) =
|
||||
|
|
@ -261,11 +269,20 @@ impl PointerGrab<State> for MoveGrab {
|
|||
|
||||
if indicator_location.is_some() != grab_state.stacking_indicator.is_some() {
|
||||
grab_state.stacking_indicator = indicator_location.map(|geo| {
|
||||
let element = stack_hover(state.common.event_loop_handle.clone(), geo.size);
|
||||
let element = stack_hover(
|
||||
state.common.event_loop_handle.clone(),
|
||||
geo.size.as_logical(),
|
||||
);
|
||||
for output in &self.window_outputs {
|
||||
element.output_enter(output, output.geometry());
|
||||
element.output_enter(
|
||||
output,
|
||||
Rectangle::from_loc_and_size(
|
||||
(0, 0),
|
||||
output.geometry().size.as_logical(),
|
||||
),
|
||||
);
|
||||
}
|
||||
(element, geo.loc)
|
||||
(element, geo.loc.as_logical())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -397,8 +414,8 @@ impl MoveGrab {
|
|||
start_data: PointerGrabStartData<State>,
|
||||
window: CosmicMapped,
|
||||
seat: &Seat<State>,
|
||||
initial_cursor_location: Point<f64, Logical>,
|
||||
initial_window_location: Point<i32, Logical>,
|
||||
initial_cursor_location: Point<f64, Global>,
|
||||
initial_window_location: Point<i32, Global>,
|
||||
indicator_thickness: u8,
|
||||
was_tiled: bool,
|
||||
) -> MoveGrab {
|
||||
|
|
@ -409,7 +426,8 @@ impl MoveGrab {
|
|||
|
||||
let grab_state = MoveGrabState {
|
||||
window: window.clone(),
|
||||
window_offset: initial_window_location - initial_cursor_location.to_i32_round(),
|
||||
window_offset: (initial_window_location - initial_cursor_location.to_i32_round())
|
||||
.as_logical(),
|
||||
indicator_thickness,
|
||||
start: Instant::now(),
|
||||
stacking_indicator: None,
|
||||
|
|
@ -451,16 +469,16 @@ impl MoveGrab {
|
|||
// No more buttons are pressed, release the grab.
|
||||
let output = self.seat.active_output();
|
||||
|
||||
let position = if let Some(grab_state) = self
|
||||
let position: Option<(CosmicMapped, Point<i32, Global>)> = if let Some(grab_state) = self
|
||||
.seat
|
||||
.user_data()
|
||||
.get::<SeatMoveGrabState>()
|
||||
.and_then(|s| s.borrow_mut().take())
|
||||
{
|
||||
if grab_state.window.alive() {
|
||||
let window_location = handle.current_location().to_i32_round()
|
||||
- output.geometry().loc
|
||||
+ grab_state.window_offset;
|
||||
let window_location = (handle.current_location().to_i32_round()
|
||||
+ grab_state.window_offset)
|
||||
.as_global();
|
||||
|
||||
let workspace_handle = state.common.shell.active_space(&output).handle;
|
||||
for old_output in self.window_outputs.iter().filter(|o| *o != &output) {
|
||||
|
|
@ -480,41 +498,26 @@ impl MoveGrab {
|
|||
}
|
||||
|
||||
if self.tiling {
|
||||
Some(
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.active_space_mut(&output)
|
||||
.tiling_layer
|
||||
.drop_window(grab_state.window, &output, handle.current_location()),
|
||||
)
|
||||
} else {
|
||||
let offset = state
|
||||
.common
|
||||
.shell
|
||||
.active_space(&output)
|
||||
.floating_layer
|
||||
.space
|
||||
.output_geometry(&output)
|
||||
.unwrap()
|
||||
.loc;
|
||||
grab_state.window.set_geometry(Rectangle::from_loc_and_size(
|
||||
window_location + offset,
|
||||
grab_state.window.geometry().size,
|
||||
));
|
||||
state
|
||||
let (window, location) = state
|
||||
.common
|
||||
.shell
|
||||
.active_space_mut(&output)
|
||||
.floating_layer
|
||||
.map_internal(grab_state.window, &output, Some(window_location + offset));
|
||||
.tiling_layer
|
||||
.drop_window(grab_state.window);
|
||||
Some((window, location.to_global(&output)))
|
||||
} else {
|
||||
grab_state.window.set_geometry(Rectangle::from_loc_and_size(
|
||||
window_location,
|
||||
grab_state.window.geometry().size.as_global(),
|
||||
));
|
||||
let workspace = state.common.shell.active_space_mut(&output);
|
||||
workspace.floating_layer.map_internal(
|
||||
grab_state.window,
|
||||
Some(window_location.to_local(&workspace.output)),
|
||||
None,
|
||||
);
|
||||
|
||||
let pointer_pos = handle.current_location();
|
||||
let relative_pos = state.common.shell.map_global_to_space(pointer_pos, &output);
|
||||
Some((
|
||||
self.window.clone(),
|
||||
window_location + offset + (pointer_pos - relative_pos).to_i32_round(),
|
||||
))
|
||||
Some((self.window.clone(), window_location))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
|
|
@ -535,7 +538,7 @@ impl MoveGrab {
|
|||
state,
|
||||
Some((
|
||||
PointerFocusTarget::from(mapped.clone()),
|
||||
position - self.window.geometry().loc,
|
||||
position.as_logical() - self.window.geometry().loc,
|
||||
)),
|
||||
&MotionEvent {
|
||||
location: handle.current_location(),
|
||||
|
|
|
|||
|
|
@ -101,10 +101,10 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
|||
self.window.set_resizing(true);
|
||||
self.window.set_geometry(Rectangle::from_loc_and_size(
|
||||
match self.window.active_window() {
|
||||
CosmicSurface::X11(s) => s.geometry().loc,
|
||||
CosmicSurface::X11(s) => s.geometry().loc.as_global(),
|
||||
_ => (0, 0).into(),
|
||||
},
|
||||
self.last_window_size,
|
||||
self.last_window_size.as_global(),
|
||||
));
|
||||
self.window.configure();
|
||||
}
|
||||
|
|
@ -139,10 +139,10 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
|||
self.window.set_resizing(false);
|
||||
self.window.set_geometry(Rectangle::from_loc_and_size(
|
||||
match self.window.active_window() {
|
||||
CosmicSurface::X11(s) => s.geometry().loc,
|
||||
CosmicSurface::X11(s) => s.geometry().loc.as_global(),
|
||||
_ => (0, 0).into(),
|
||||
},
|
||||
self.last_window_size,
|
||||
self.last_window_size.as_global(),
|
||||
));
|
||||
self.window.configure();
|
||||
|
||||
|
|
@ -271,7 +271,13 @@ impl ResizeSurfaceGrab {
|
|||
}
|
||||
|
||||
pub fn apply_resize_to_location(window: CosmicMapped, space: &mut Workspace) {
|
||||
if let Some(location) = space.floating_layer.space.element_location(&window) {
|
||||
if let Some(location) = space
|
||||
.floating_layer
|
||||
.space
|
||||
.element_location(&window)
|
||||
.map(PointExt::as_local)
|
||||
.map(|p| p.to_global(space.output()))
|
||||
{
|
||||
let mut new_location = None;
|
||||
|
||||
let mut resize_state = window.resize_state.lock().unwrap();
|
||||
|
|
@ -316,13 +322,13 @@ impl ResizeSurfaceGrab {
|
|||
CosmicSurface::Wayland(window) => {
|
||||
update_reactive_popups(
|
||||
&window,
|
||||
new_location + offset,
|
||||
new_location + offset.as_global(),
|
||||
space.floating_layer.space.outputs(),
|
||||
);
|
||||
}
|
||||
CosmicSurface::X11(surface) => {
|
||||
let mut geometry = surface.geometry();
|
||||
geometry.loc += location - new_location;
|
||||
geometry.loc += (location - new_location).as_logical();
|
||||
let _ = surface.configure(geometry);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
|
|
@ -331,7 +337,7 @@ impl ResizeSurfaceGrab {
|
|||
space
|
||||
.floating_layer
|
||||
.space
|
||||
.map_element(window, new_location, false);
|
||||
.map_element(window, new_location.as_logical(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -471,7 +471,7 @@ impl FloatingLayout {
|
|||
})
|
||||
.then_some(pos);
|
||||
|
||||
self.map_internal(mapped.clone(), &output, position);
|
||||
self.map_internal(mapped.clone(), position.map(PointExt::as_local), None);
|
||||
return MoveResult::ShiftFocus(KeyboardFocusTarget::Element(mapped));
|
||||
}
|
||||
StackMoveResult::Default => {}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ pub struct NodeDesc {
|
|||
enum TargetZone {
|
||||
Initial,
|
||||
InitialPlaceholder(NodeId),
|
||||
WindowStack(NodeId, Rectangle<i32, Logical>),
|
||||
WindowStack(NodeId, Rectangle<i32, Local>),
|
||||
WindowSplit(NodeId, Direction),
|
||||
GroupEdge(NodeId, Direction),
|
||||
GroupInterior(NodeId, usize),
|
||||
|
|
@ -171,22 +171,22 @@ pub enum Data {
|
|||
Group {
|
||||
orientation: Orientation,
|
||||
sizes: Vec<i32>,
|
||||
last_geometry: Rectangle<i32, Logical>,
|
||||
last_geometry: Rectangle<i32, Local>,
|
||||
alive: Arc<()>,
|
||||
pill_indicator: Option<PillIndicator>,
|
||||
},
|
||||
Mapped {
|
||||
mapped: CosmicMapped,
|
||||
last_geometry: Rectangle<i32, Logical>,
|
||||
last_geometry: Rectangle<i32, Local>,
|
||||
},
|
||||
Placeholder {
|
||||
last_geometry: Rectangle<i32, Logical>,
|
||||
last_geometry: Rectangle<i32, Local>,
|
||||
initial_placeholder: bool,
|
||||
},
|
||||
}
|
||||
|
||||
impl Data {
|
||||
fn new_group(orientation: Orientation, geo: Rectangle<i32, Logical>) -> Data {
|
||||
fn new_group(orientation: Orientation, geo: Rectangle<i32, Local>) -> Data {
|
||||
Data::Group {
|
||||
orientation,
|
||||
sizes: vec![
|
||||
|
|
@ -296,7 +296,7 @@ impl Data {
|
|||
}
|
||||
}
|
||||
|
||||
fn geometry(&self) -> &Rectangle<i32, Logical> {
|
||||
fn geometry(&self) -> &Rectangle<i32, Local> {
|
||||
match self {
|
||||
Data::Group { last_geometry, .. } => last_geometry,
|
||||
Data::Mapped { last_geometry, .. } => last_geometry,
|
||||
|
|
@ -304,7 +304,7 @@ impl Data {
|
|||
}
|
||||
}
|
||||
|
||||
fn update_geometry(&mut self, geo: Rectangle<i32, Logical>) {
|
||||
fn update_geometry(&mut self, geo: Rectangle<i32, Local>) {
|
||||
match self {
|
||||
Data::Group {
|
||||
orientation,
|
||||
|
|
@ -2816,7 +2816,9 @@ impl TilingLayout {
|
|||
let mut configures = Vec::new();
|
||||
|
||||
let (outer, inner) = gaps;
|
||||
let mut geo = layer_map_for_output(&output).non_exclusive_zone();
|
||||
let mut geo = layer_map_for_output(&output)
|
||||
.non_exclusive_zone()
|
||||
.as_local();
|
||||
geo.loc.x += outer;
|
||||
geo.loc.y += outer;
|
||||
geo.size.w -= outer * 2;
|
||||
|
|
@ -3861,8 +3863,8 @@ fn swap_factor(size: Size<i32, Logical>) -> f64 {
|
|||
|
||||
fn swap_geometry(
|
||||
size: Size<i32, Logical>,
|
||||
relative_to: Rectangle<i32, Logical>,
|
||||
) -> Rectangle<i32, Logical> {
|
||||
relative_to: Rectangle<i32, Local>,
|
||||
) -> Rectangle<i32, Local> {
|
||||
let factor = swap_factor(size);
|
||||
|
||||
let new_size = Size::from((
|
||||
|
|
@ -3881,7 +3883,7 @@ fn swap_geometry(
|
|||
fn geometries_for_groupview<'a, R>(
|
||||
tree: &Tree<Data>,
|
||||
renderer: impl Into<Option<&'a mut R>>,
|
||||
non_exclusive_zone: Rectangle<i32, Logical>,
|
||||
non_exclusive_zone: Rectangle<i32, Local>,
|
||||
seat: Option<&Seat<State>>,
|
||||
alpha: f32,
|
||||
transition: f32,
|
||||
|
|
@ -3891,7 +3893,7 @@ fn geometries_for_groupview<'a, R>(
|
|||
swap_desc: Option<NodeDesc>,
|
||||
swap_tree: Option<&Tree<Data>>,
|
||||
) -> (
|
||||
HashMap<NodeId, Rectangle<i32, Logical>>,
|
||||
HashMap<NodeId, Rectangle<i32, Local>>,
|
||||
Vec<CosmicMappedRenderElement<R>>,
|
||||
)
|
||||
where
|
||||
|
|
@ -3921,7 +3923,7 @@ where
|
|||
}
|
||||
|
||||
let mut elements = Vec::new();
|
||||
let mut geometries: HashMap<NodeId, Rectangle<i32, Logical>> = HashMap::new();
|
||||
let mut geometries: HashMap<NodeId, Rectangle<i32, Local>> = HashMap::new();
|
||||
let alpha = alpha * transition;
|
||||
|
||||
let focused = seat
|
||||
|
|
@ -4268,7 +4270,7 @@ where
|
|||
);
|
||||
}
|
||||
let swap_geo = swap_geometry(
|
||||
geo.size,
|
||||
geo.size.as_logical(),
|
||||
focused_geo.unwrap_or({
|
||||
let mut geo = non_exclusive_zone;
|
||||
geo.loc += (WINDOW_BACKDROP_BORDER, WINDOW_BACKDROP_BORDER).into();
|
||||
|
|
@ -4469,7 +4471,7 @@ where
|
|||
if matches!(swap_desc, Some(ref desc) if &desc.node == &node_id && desc.stack_window.is_none())
|
||||
{
|
||||
let swap_geo = swap_geometry(
|
||||
geo.size,
|
||||
geo.size.as_logical(),
|
||||
focused_geo.unwrap_or({
|
||||
let mut geo = non_exclusive_zone;
|
||||
geo.loc += (WINDOW_BACKDROP_BORDER, WINDOW_BACKDROP_BORDER).into();
|
||||
|
|
@ -4523,7 +4525,7 @@ fn render_old_tree<R>(
|
|||
reference_tree: &Tree<Data>,
|
||||
target_tree: &Tree<Data>,
|
||||
renderer: &mut R,
|
||||
geometries: Option<HashMap<NodeId, Rectangle<i32, Logical>>>,
|
||||
geometries: Option<HashMap<NodeId, Rectangle<i32, Local>>>,
|
||||
output_scale: f64,
|
||||
percentage: f32,
|
||||
is_swap_mode: bool,
|
||||
|
|
@ -4585,7 +4587,10 @@ where
|
|||
.unwrap_or(*original_geo);
|
||||
|
||||
let crop_rect = geo.clone();
|
||||
let original_location = original_geo.loc.to_physical_precise_round(output_scale)
|
||||
let original_location = original_geo
|
||||
.loc
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale)
|
||||
- mapped
|
||||
.geometry()
|
||||
.loc
|
||||
|
|
@ -4605,7 +4610,9 @@ where
|
|||
let cropped = CropRenderElement::from_element(
|
||||
elem,
|
||||
output_scale,
|
||||
crop_rect.to_physical_precise_round(output_scale),
|
||||
crop_rect
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale),
|
||||
)?;
|
||||
let rescaled = RescaleRenderElement::from_element(
|
||||
cropped,
|
||||
|
|
@ -4615,6 +4622,7 @@ where
|
|||
let relocated = RelocateRenderElement::from_element(
|
||||
rescaled,
|
||||
(geo.loc - original_geo.loc)
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale),
|
||||
Relocate::Relative,
|
||||
);
|
||||
|
|
@ -4626,7 +4634,9 @@ where
|
|||
let cropped = CropRenderElement::from_element(
|
||||
elem,
|
||||
output_scale,
|
||||
crop_rect.to_physical_precise_round(output_scale),
|
||||
crop_rect
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale),
|
||||
)?;
|
||||
let rescaled = RescaleRenderElement::from_element(
|
||||
cropped,
|
||||
|
|
@ -4636,6 +4646,7 @@ where
|
|||
let relocated = RelocateRenderElement::from_element(
|
||||
rescaled,
|
||||
(geo.loc - original_geo.loc)
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale),
|
||||
Relocate::Relative,
|
||||
);
|
||||
|
|
@ -4655,9 +4666,9 @@ fn render_new_tree<R>(
|
|||
target_tree: &Tree<Data>,
|
||||
reference_tree: Option<&Tree<Data>>,
|
||||
renderer: &mut R,
|
||||
non_exclusive_zone: Rectangle<i32, Logical>,
|
||||
geometries: Option<HashMap<NodeId, Rectangle<i32, Logical>>>,
|
||||
old_geometries: Option<HashMap<NodeId, Rectangle<i32, Logical>>>,
|
||||
non_exclusive_zone: Rectangle<i32, Local>,
|
||||
geometries: Option<HashMap<NodeId, Rectangle<i32, Local>>>,
|
||||
old_geometries: Option<HashMap<NodeId, Rectangle<i32, Local>>>,
|
||||
is_overview: bool,
|
||||
seat: Option<&Seat<State>>,
|
||||
output: &Output,
|
||||
|
|
@ -4685,13 +4696,7 @@ where
|
|||
seat.get_keyboard()
|
||||
.unwrap()
|
||||
.current_focus()
|
||||
.and_then(|target| {
|
||||
TilingLayout::currently_focused_node(
|
||||
&target_tree,
|
||||
&seat.active_output(),
|
||||
target,
|
||||
)
|
||||
})
|
||||
.and_then(|target| TilingLayout::currently_focused_node(&target_tree, target))
|
||||
})
|
||||
.map(|(id, _)| id);
|
||||
let focused_geo = if let Some(focused) = focused.as_ref() {
|
||||
|
|
@ -4778,7 +4783,8 @@ where
|
|||
transition.unwrap_or(1.0),
|
||||
));
|
||||
|
||||
let render_loc = (swap_geo.loc - window_geo.loc).to_physical_precise_round(output_scale);
|
||||
let render_loc =
|
||||
(swap_geo.loc.as_logical() - window_geo.loc).to_physical_precise_round(output_scale);
|
||||
|
||||
swap_elements.extend(
|
||||
window
|
||||
|
|
@ -4792,7 +4798,10 @@ where
|
|||
.map(|window| {
|
||||
CosmicMappedRenderElement::GrabbedWindow(RescaleRenderElement::from_element(
|
||||
window,
|
||||
swap_geo.loc.to_physical_precise_round(output_scale),
|
||||
swap_geo
|
||||
.loc
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale),
|
||||
ease(
|
||||
Linear,
|
||||
1.0,
|
||||
|
|
@ -4985,12 +4994,12 @@ where
|
|||
.unwrap_or(false))
|
||||
{
|
||||
if let Some(swap) = swap_indicator.as_ref() {
|
||||
swap.resize(geo.size);
|
||||
swap.output_enter(output, output_geo);
|
||||
swap.resize(geo.size.as_logical());
|
||||
swap.output_enter(output, output_geo.as_logical());
|
||||
swap_elements.extend(
|
||||
swap.render_elements::<CosmicWindowRenderElement<R>>(
|
||||
renderer,
|
||||
geo.loc.to_physical_precise_round(output_scale),
|
||||
geo.loc.as_logical().to_physical_precise_round(output_scale),
|
||||
output_scale.into(),
|
||||
alpha * overview.0.alpha().unwrap_or(1.0),
|
||||
)
|
||||
|
|
@ -5006,8 +5015,8 @@ where
|
|||
geo.loc -= (18, 18).into();
|
||||
geo.size += (36, 36).into();
|
||||
|
||||
resize.resize(geo.size);
|
||||
resize.output_enter(output, output_geo);
|
||||
resize.resize(geo.size.as_logical());
|
||||
resize.output_enter(output, output_geo.as_logical());
|
||||
let possible_edges =
|
||||
TilingLayout::possible_resizes(target_tree, node_id.clone());
|
||||
if !possible_edges.is_empty() {
|
||||
|
|
@ -5026,7 +5035,7 @@ where
|
|||
resize
|
||||
.render_elements::<CosmicWindowRenderElement<R>>(
|
||||
renderer,
|
||||
geo.loc.to_physical_precise_round(output_scale),
|
||||
geo.loc.as_logical().to_physical_precise_round(output_scale),
|
||||
output_scale.into(),
|
||||
alpha * mode.alpha().unwrap_or(1.0),
|
||||
)
|
||||
|
|
@ -5039,7 +5048,7 @@ where
|
|||
}
|
||||
|
||||
if let Data::Mapped { mapped, .. } = data {
|
||||
let original_location = (original_geo.loc - mapped.geometry().loc)
|
||||
let original_location = (original_geo.loc.as_logical() - mapped.geometry().loc)
|
||||
.to_physical_precise_round(output_scale);
|
||||
|
||||
let (mut w_elements, p_elements) = mapped
|
||||
|
|
@ -5069,7 +5078,7 @@ where
|
|||
})
|
||||
.unwrap_or(false)
|
||||
{
|
||||
let mut geo = mapped.active_window_geometry();
|
||||
let mut geo = mapped.active_window_geometry().as_local();
|
||||
geo.loc += original_geo.loc;
|
||||
w_elements.insert(
|
||||
0,
|
||||
|
|
@ -5090,16 +5099,22 @@ where
|
|||
let cropped = CropRenderElement::from_element(
|
||||
elem,
|
||||
output_scale,
|
||||
crop_rect.to_physical_precise_round(output_scale),
|
||||
crop_rect
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale),
|
||||
)?;
|
||||
let rescaled = RescaleRenderElement::from_element(
|
||||
cropped,
|
||||
original_geo.loc.to_physical_precise_round(output_scale),
|
||||
original_geo
|
||||
.loc
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale),
|
||||
scale,
|
||||
);
|
||||
let relocated = RelocateRenderElement::from_element(
|
||||
rescaled,
|
||||
(geo.loc - original_geo.loc)
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale),
|
||||
Relocate::Relative,
|
||||
);
|
||||
|
|
@ -5111,16 +5126,22 @@ where
|
|||
let cropped = CropRenderElement::from_element(
|
||||
elem,
|
||||
output_scale,
|
||||
crop_rect.to_physical_precise_round(output_scale),
|
||||
crop_rect
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale),
|
||||
)?;
|
||||
let rescaled = RescaleRenderElement::from_element(
|
||||
cropped,
|
||||
original_geo.loc.to_physical_precise_round(output_scale),
|
||||
original_geo
|
||||
.loc
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale),
|
||||
scale,
|
||||
);
|
||||
let relocated = RelocateRenderElement::from_element(
|
||||
rescaled,
|
||||
(geo.loc - original_geo.loc)
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale),
|
||||
Relocate::Relative,
|
||||
);
|
||||
|
|
@ -5132,16 +5153,22 @@ where
|
|||
let cropped = CropRenderElement::from_element(
|
||||
elem,
|
||||
output_scale,
|
||||
crop_rect.to_physical_precise_round(output_scale),
|
||||
crop_rect
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale),
|
||||
)?;
|
||||
let rescaled = RescaleRenderElement::from_element(
|
||||
cropped,
|
||||
original_geo.loc.to_physical_precise_round(output_scale),
|
||||
original_geo
|
||||
.loc
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale),
|
||||
scale,
|
||||
);
|
||||
let relocated = RelocateRenderElement::from_element(
|
||||
rescaled,
|
||||
(geo.loc - original_geo.loc)
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale),
|
||||
Relocate::Relative,
|
||||
);
|
||||
|
|
@ -5187,10 +5214,10 @@ where
|
|||
(window_elements, popup_elements)
|
||||
}
|
||||
|
||||
fn scale_to_center(
|
||||
old_geo: &Rectangle<i32, Logical>,
|
||||
new_geo: &Rectangle<i32, Logical>,
|
||||
) -> (f64, Point<i32, Logical>) {
|
||||
fn scale_to_center<C>(
|
||||
old_geo: &Rectangle<i32, C>,
|
||||
new_geo: &Rectangle<i32, C>,
|
||||
) -> (f64, Point<i32, C>) {
|
||||
let scale_w = new_geo.size.w as f64 / old_geo.size.w as f64;
|
||||
let scale_h = new_geo.size.h as f64 / old_geo.size.h as f64;
|
||||
|
||||
|
|
|
|||
|
|
@ -1073,7 +1073,10 @@ impl Shell {
|
|||
.filter(|o| {
|
||||
self.override_redirect_windows.iter().any(|or| {
|
||||
if or.wl_surface().as_ref() == Some(surface) {
|
||||
or.geometry().intersection(o.geometry()).is_some()
|
||||
or.geometry()
|
||||
.as_global()
|
||||
.intersection(o.geometry())
|
||||
.is_some()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
|
@ -1393,13 +1396,12 @@ impl Shell {
|
|||
|
||||
pub fn map_override_redirect(state: &mut State, window: X11Surface) {
|
||||
let geo = window.geometry();
|
||||
for (output, overlap) in state
|
||||
.common
|
||||
.shell
|
||||
.outputs()
|
||||
.cloned()
|
||||
.filter_map(|o| o.geometry().intersection(geo).map(|overlap| (o, overlap)))
|
||||
{
|
||||
for (output, overlap) in state.common.shell.outputs().cloned().filter_map(|o| {
|
||||
o.geometry()
|
||||
.as_logical()
|
||||
.intersection(geo)
|
||||
.map(|overlap| (o, overlap))
|
||||
}) {
|
||||
window.output_enter(&output, overlap);
|
||||
}
|
||||
|
||||
|
|
@ -1444,7 +1446,7 @@ impl Shell {
|
|||
to: (&Output, Option<usize>),
|
||||
follow: bool,
|
||||
direction: Option<Direction>,
|
||||
) -> Result<Option<Point<i32, Logical>>, InvalidWorkspaceIndex> {
|
||||
) -> Result<Option<Point<i32, Global>>, InvalidWorkspaceIndex> {
|
||||
let (to_output, to_idx) = to;
|
||||
let to_idx = to_idx.unwrap_or(state.common.shell.workspaces.active_num(to_output).1);
|
||||
if state
|
||||
|
|
@ -1578,14 +1580,18 @@ impl Shell {
|
|||
|
||||
pub fn update_reactive_popups(&self, mapped: &CosmicMapped) {
|
||||
if let Some(workspace) = self.space_for(mapped) {
|
||||
let element_loc = workspace.element_geometry(mapped).unwrap().loc;
|
||||
let element_loc = workspace
|
||||
.element_geometry(mapped)
|
||||
.unwrap()
|
||||
.loc
|
||||
.to_global(&workspace.output);
|
||||
for (toplevel, offset) in mapped.windows() {
|
||||
if let CosmicSurface::Wayland(toplevel) = toplevel {
|
||||
let window_geo_offset = toplevel.geometry().loc;
|
||||
let window_geo_offset = toplevel.geometry().loc.as_global();
|
||||
update_reactive_popups(
|
||||
&toplevel,
|
||||
element_loc + offset + window_geo_offset,
|
||||
self.outputs.iter(),
|
||||
element_loc + offset.as_global() + window_geo_offset,
|
||||
self.outputs(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -935,20 +935,28 @@ impl Workspace {
|
|||
let mut window_elements = Vec::new();
|
||||
let mut popup_elements = Vec::new();
|
||||
|
||||
let output_scale = output.current_scale().fractional_scale();
|
||||
let layer_map = layer_map_for_output(output);
|
||||
let zone = layer_map.non_exclusive_zone();
|
||||
let output_scale = self.output.current_scale().fractional_scale();
|
||||
let zone = {
|
||||
let layer_map = layer_map_for_output(&self.output);
|
||||
layer_map.non_exclusive_zone().as_local()
|
||||
};
|
||||
|
||||
// OR windows above all
|
||||
popup_elements.extend(
|
||||
override_redirect_windows
|
||||
.iter()
|
||||
.filter(|or| (*or).geometry().intersection(output.geometry()).is_some())
|
||||
.filter(|or| {
|
||||
(*or)
|
||||
.geometry()
|
||||
.as_global()
|
||||
.intersection(self.output.geometry())
|
||||
.is_some()
|
||||
})
|
||||
.flat_map(|or| {
|
||||
AsRenderElements::<R>::render_elements::<WorkspaceRenderElement<R>>(
|
||||
or,
|
||||
renderer,
|
||||
(or.geometry().loc - output.geometry().loc)
|
||||
(or.geometry().loc - self.output.geometry().loc.as_logical())
|
||||
.to_physical_precise_round(output_scale),
|
||||
Scale::from(output_scale),
|
||||
1.0,
|
||||
|
|
@ -1027,7 +1035,10 @@ impl Workspace {
|
|||
(None, None) => (full_geo, 1.0),
|
||||
};
|
||||
|
||||
let render_loc = target_geo.loc.to_physical_precise_round(output_scale);
|
||||
let render_loc = target_geo
|
||||
.loc
|
||||
.as_logical()
|
||||
.to_physical_precise_round(output_scale);
|
||||
let scale = Scale {
|
||||
x: target_geo.size.w as f64 / bbox.size.w as f64,
|
||||
y: target_geo.size.h as f64 / bbox.size.h as f64,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue