floating/resize: Fix local/global coordinate conversions
This commit is contained in:
parent
8da782df67
commit
ebd781b678
2 changed files with 12 additions and 20 deletions
|
|
@ -29,7 +29,7 @@ pub struct ResizeData {
|
|||
/// The edges the surface is being resized with.
|
||||
pub edges: ResizeEdge,
|
||||
/// The initial window location.
|
||||
pub initial_window_location: Point<i32, Logical>,
|
||||
pub initial_window_location: Point<i32, Local>,
|
||||
/// The initial window size (geometry width and height).
|
||||
pub initial_window_size: Size<i32, Logical>,
|
||||
}
|
||||
|
|
@ -277,7 +277,7 @@ impl ResizeSurfaceGrab {
|
|||
start_data: PointerGrabStartData<State>,
|
||||
mapped: CosmicMapped,
|
||||
edges: ResizeEdge,
|
||||
initial_window_location: Point<i32, Logical>,
|
||||
initial_window_location: Point<i32, Local>,
|
||||
initial_window_size: Size<i32, Logical>,
|
||||
seat: &Seat<State>,
|
||||
) -> ResizeSurfaceGrab {
|
||||
|
|
@ -324,6 +324,7 @@ impl ResizeSurfaceGrab {
|
|||
initial_window_location,
|
||||
initial_window_size,
|
||||
} = resize_data;
|
||||
let initial_window_location = initial_window_location.to_global(space.output());
|
||||
|
||||
if edges.intersects(ResizeEdge::TOP_LEFT) {
|
||||
let size = window.geometry().size;
|
||||
|
|
|
|||
|
|
@ -457,7 +457,7 @@ impl FloatingLayout {
|
|||
edges: ResizeEdge,
|
||||
) -> Option<ResizeSurfaceGrab> {
|
||||
if seat.get_pointer().is_some() {
|
||||
let location = self.space.element_location(&mapped).unwrap();
|
||||
let location = self.space.element_location(&mapped).unwrap().as_local();
|
||||
let size = mapped.geometry().size;
|
||||
mapped.moved_since_mapped.store(true, Ordering::SeqCst);
|
||||
|
||||
|
|
@ -502,7 +502,7 @@ impl FloatingLayout {
|
|||
|
||||
if edge.contains(ResizeEdge::RIGHT) || edge.contains(ResizeEdge::LEFT) {
|
||||
if direction == ResizeDirection::Inwards {
|
||||
geo.size.w -= amount;
|
||||
geo.size.w = (geo.size.w as u32).saturating_sub(amount as u32) as i32;
|
||||
} else {
|
||||
geo.size.w += amount;
|
||||
}
|
||||
|
|
@ -510,13 +510,13 @@ impl FloatingLayout {
|
|||
if direction == ResizeDirection::Inwards {
|
||||
geo.loc.x += amount;
|
||||
} else {
|
||||
geo.loc.x -= amount;
|
||||
geo.loc.x = (geo.loc.x as u32).saturating_sub(amount as u32) as i32;
|
||||
}
|
||||
}
|
||||
}
|
||||
if edge.contains(ResizeEdge::BOTTOM) || edge.contains(ResizeEdge::TOP) {
|
||||
if direction == ResizeDirection::Inwards {
|
||||
geo.size.h -= amount;
|
||||
geo.size.h = (geo.size.h as u32).saturating_sub(amount as u32) as i32;
|
||||
} else {
|
||||
geo.size.h += amount;
|
||||
}
|
||||
|
|
@ -524,24 +524,15 @@ impl FloatingLayout {
|
|||
if direction == ResizeDirection::Inwards {
|
||||
geo.loc.y += amount;
|
||||
} else {
|
||||
geo.loc.y -= amount;
|
||||
geo.loc.y = (geo.loc.y as u32).saturating_sub(amount as u32) as i32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let Some(bounding_box) = self
|
||||
let bounding_box = self
|
||||
.space
|
||||
.outputs()
|
||||
.map(|o| self.space.output_geometry(o).unwrap())
|
||||
.filter(|output_geo| output_geo.overlaps(geo))
|
||||
.fold(None, |res, output_geo| match res {
|
||||
None => Some(output_geo),
|
||||
Some(other) => Some(other.merge(output_geo)),
|
||||
})
|
||||
else {
|
||||
return true;
|
||||
};
|
||||
|
||||
.output_geometry(self.space.outputs().next().unwrap())
|
||||
.unwrap();
|
||||
let (min_size, max_size) = (mapped.min_size(), mapped.max_size());
|
||||
let min_width = min_size.map(|s| s.w).unwrap_or(360);
|
||||
let min_height = min_size.map(|s| s.h).unwrap_or(240);
|
||||
|
|
@ -554,7 +545,7 @@ impl FloatingLayout {
|
|||
|
||||
*mapped.resize_state.lock().unwrap() = Some(ResizeState::Resizing(ResizeData {
|
||||
edges: edge,
|
||||
initial_window_location: original_geo.loc,
|
||||
initial_window_location: original_geo.loc.as_local(),
|
||||
initial_window_size: original_geo.size,
|
||||
}));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue