Skip to content

Commit c1b70e0

Browse files
committed
fix dropdown position for gtk backend
We need to position internal windows (dropdowns, tooltips) relative to the content area. Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
1 parent b11f8ed commit c1b70e0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

druid-shell/src/backend/gtk/window.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,19 @@ impl WindowHandle {
983983
pub fn set_position(&self, mut position: Point) {
984984
if let Some(state) = self.state.upgrade() {
985985
if let Some(parent_state) = &state.parent {
986-
let pos = (*parent_state).get_position();
986+
let pos = if let Some(parent_state) = parent_state.0.state.upgrade() {
987+
let parent_window = &(*parent_state).window;
988+
let (root_x, root_y) = match state.window.type_hint() {
989+
WindowTypeHint::Tooltip | WindowTypeHint::DropdownMenu => {
990+
// position relative to the content area
991+
parent_window.window().unwrap().position()
992+
}
993+
_ => parent_window.position(),
994+
};
995+
Point::new(root_x as f64, root_y as f64).to_dp(state.scale.get())
996+
} else {
997+
(*parent_state).get_position()
998+
};
987999
position += (pos.x, pos.y)
9881000
}
9891001
};

0 commit comments

Comments
 (0)