shell: Don't use output-relative coords for windwo geometry
This commit is contained in:
parent
4940d0823d
commit
0090122ffe
4 changed files with 46 additions and 20 deletions
|
|
@ -176,7 +176,7 @@ impl ResizeSurfaceGrab {
|
|||
}
|
||||
|
||||
pub fn apply_resize_to_location(window: CosmicMapped, space: &mut Workspace) {
|
||||
if let Some(mut location) = space.floating_layer.space.element_location(&window) {
|
||||
if let Some(location) = space.floating_layer.space.element_location(&window) {
|
||||
let mut new_location = None;
|
||||
|
||||
let mut resize_state = window.resize_state.lock().unwrap();
|
||||
|
|
@ -193,16 +193,15 @@ impl ResizeSurfaceGrab {
|
|||
|
||||
if edges.intersects(ResizeEdge::TOP_LEFT) {
|
||||
let size = window.geometry().size;
|
||||
let mut new = location.clone();
|
||||
if edges.intersects(ResizeEdge::LEFT) {
|
||||
location.x =
|
||||
initial_window_location.x + (initial_window_size.w - size.w);
|
||||
new.x = initial_window_location.x + (initial_window_size.w - size.w);
|
||||
}
|
||||
if edges.intersects(ResizeEdge::TOP) {
|
||||
location.y =
|
||||
initial_window_location.y + (initial_window_size.h - size.h);
|
||||
new.y = initial_window_location.y + (initial_window_size.h - size.h);
|
||||
}
|
||||
|
||||
new_location = Some(location);
|
||||
new_location = Some(new);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
@ -227,7 +226,7 @@ impl ResizeSurfaceGrab {
|
|||
}
|
||||
}
|
||||
let mut geometry = window.geometry();
|
||||
geometry.loc = new_location;
|
||||
geometry.loc += location - new_location;
|
||||
let _ = window.set_geometry(geometry);
|
||||
space
|
||||
.floating_layer
|
||||
|
|
|
|||
|
|
@ -146,7 +146,16 @@ impl FloatingLayout {
|
|||
});
|
||||
|
||||
mapped.set_tiled(false);
|
||||
mapped.set_geometry(Rectangle::from_loc_and_size(position, win_geo.size));
|
||||
let offset = output.geometry().loc
|
||||
- self
|
||||
.space
|
||||
.output_geometry(output)
|
||||
.map(|g| g.loc)
|
||||
.unwrap_or_default();
|
||||
mapped.set_geometry(Rectangle::from_loc_and_size(
|
||||
position + offset,
|
||||
win_geo.size,
|
||||
));
|
||||
mapped.configure();
|
||||
self.space.map_element(mapped, position, false);
|
||||
}
|
||||
|
|
@ -199,7 +208,21 @@ impl FloatingLayout {
|
|||
let last_geometry = mapped.last_geometry.lock().unwrap().clone();
|
||||
let last_size = last_geometry.map(|g| g.size).expect("No previous size?");
|
||||
let last_location = last_geometry.map(|g| g.loc).expect("No previous location?");
|
||||
mapped.set_geometry(Rectangle::from_loc_and_size(last_location, last_size));
|
||||
let output = self
|
||||
.space
|
||||
.output_under(last_location.to_f64())
|
||||
.next()
|
||||
.unwrap_or(self.space.outputs().next().unwrap());
|
||||
let offset = output.geometry().loc
|
||||
- self
|
||||
.space
|
||||
.output_geometry(output)
|
||||
.map(|g| g.loc)
|
||||
.unwrap_or_default();
|
||||
mapped.set_geometry(Rectangle::from_loc_and_size(
|
||||
last_location + offset,
|
||||
last_size,
|
||||
));
|
||||
self.space.map_element(mapped, last_location, true);
|
||||
Some(last_size)
|
||||
} else {
|
||||
|
|
@ -308,7 +331,16 @@ impl FloatingLayout {
|
|||
.get(&output)
|
||||
.copied()
|
||||
.unwrap_or_else(|| (0, 0).into());
|
||||
element.set_geometry(elem_geo);
|
||||
let offset = output.geometry().loc
|
||||
- self
|
||||
.space
|
||||
.output_geometry(&output)
|
||||
.map(|g| g.loc)
|
||||
.unwrap_or_default();
|
||||
element.set_geometry(Rectangle::from_loc_and_size(
|
||||
elem_geo.loc + offset,
|
||||
elem_geo.size,
|
||||
));
|
||||
self.space.map_element(element.clone(), elem_geo.loc, false);
|
||||
}
|
||||
self.refresh(); //fixup any out of bounds elements
|
||||
|
|
|
|||
|
|
@ -1158,8 +1158,10 @@ impl TilingLayout {
|
|||
if !(mapped.is_fullscreen() || mapped.is_maximized()) {
|
||||
mapped.set_tiled(true);
|
||||
let size = (geo.size.w - inner * 2, geo.size.h - inner * 2);
|
||||
let internal_geometry =
|
||||
Rectangle::from_loc_and_size(geo.loc, size);
|
||||
let internal_geometry = Rectangle::from_loc_and_size(
|
||||
geo.loc + output.geometry().loc,
|
||||
size,
|
||||
);
|
||||
if mapped.geometry() != internal_geometry {
|
||||
mapped.set_geometry(internal_geometry);
|
||||
mapped.configure();
|
||||
|
|
|
|||
|
|
@ -238,14 +238,7 @@ impl Workspace {
|
|||
mapped.set_active(window);
|
||||
}
|
||||
|
||||
let size = output
|
||||
.current_mode()
|
||||
.map(|m| m.size)
|
||||
.unwrap_or((0, 0).into())
|
||||
.to_f64()
|
||||
.to_logical(output.current_scale().fractional_scale())
|
||||
.to_i32_round();
|
||||
window.set_geometry(Rectangle::from_loc_and_size((0, 0), size));
|
||||
window.set_geometry(output.geometry());
|
||||
window.send_configure();
|
||||
self.fullscreen.insert(output.clone(), window.clone());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue