fix popup geometry calculation and relative

placement to parent geometry
This commit is contained in:
Christian Meissl 2021-07-01 22:59:16 +02:00 committed by Victor Berger
parent 7114111ba5
commit 6b2273235a
2 changed files with 10 additions and 3 deletions

View File

@ -211,9 +211,16 @@ where
result = Err(err); result = Err(err);
} }
// furthermore, draw its popups // furthermore, draw its popups
let toplevel_geometry_offset = window_map
.geometry(toplevel_surface)
.map(|g| (g.x, g.y))
.unwrap_or_default();
window_map.with_child_popups(&wl_surface, |popup| { window_map.with_child_popups(&wl_surface, |popup| {
let location = popup.location(); let location = popup.location();
let draw_location = (initial_place.0 + location.0, initial_place.1 + location.1); let draw_location = (
initial_place.0 + location.0 + toplevel_geometry_offset.0,
initial_place.1 + location.1 + toplevel_geometry_offset.1,
);
if let Some(wl_surface) = popup.get_surface() { if let Some(wl_surface) = popup.get_surface() {
if let Err(err) = draw_surface_tree(renderer, frame, &wl_surface, draw_location, log) { if let Err(err) = draw_surface_tree(renderer, frame, &wl_surface, draw_location, log) {
result = Err(err); result = Err(err);

View File

@ -490,13 +490,13 @@ impl PositionerState {
// gravity specified. // gravity specified.
if self.gravity_has_edge(xdg_positioner::Gravity::Top) { if self.gravity_has_edge(xdg_positioner::Gravity::Top) {
geometry.y -= geometry.height; geometry.y -= geometry.height;
} else if self.gravity_has_edge(xdg_positioner::Gravity::Bottom) { } else if !self.gravity_has_edge(xdg_positioner::Gravity::Bottom) {
geometry.y -= geometry.height / 2; geometry.y -= geometry.height / 2;
} }
if self.gravity_has_edge(xdg_positioner::Gravity::Left) { if self.gravity_has_edge(xdg_positioner::Gravity::Left) {
geometry.x -= geometry.width; geometry.x -= geometry.width;
} else if self.gravity_has_edge(xdg_positioner::Gravity::Right) { } else if !self.gravity_has_edge(xdg_positioner::Gravity::Right) {
geometry.x -= geometry.width / 2; geometry.x -= geometry.width / 2;
} }