Add example for setting the initial popup geometry

This commit is contained in:
Christian Meissl 2021-08-03 19:47:13 +02:00
parent 6d3d5f7933
commit 85fa46ad2c
1 changed files with 12 additions and 2 deletions

View File

@ -374,10 +374,21 @@ pub fn init_shell<BackendData: 'static>(display: Rc<RefCell<Display>>, log: ::sl
.borrow_mut()
.insert(SurfaceKind::Xdg(surface), (x, y).into());
}
XdgRequest::NewPopup { surface, .. } => {
XdgRequest::NewPopup { surface, positioner } => {
// Do not send a configure here, the initial configure
// of a xdg_surface has to be sent during the commit if
// the surface is not already configured
// TODO: properly recompute the geometry with the whole of positioner state
surface
.with_pending_state(|state| {
// NOTE: This is not really necessary as the default geometry
// is already set the same way, but for demonstrating how
// to set the initial popup geometry this code is left as
// an example
state.geometry = positioner.get_geometry();
})
.unwrap();
xdg_window_map.borrow_mut().insert_popup(PopupKind::Xdg(surface));
}
XdgRequest::RePosition {
@ -1108,7 +1119,6 @@ fn surface_commit(
})
.unwrap();
if !initial_configure_sent {
// TODO: properly recompute the geometry with the whole of positioner state
// NOTE: This should never fail as the initial configure is always
// allowed.
popup.send_configure().expect("initial configure failed");