anvil.shell: store min_size and max_size

This commit is contained in:
Ivan Molodetskikh 2020-02-08 09:24:27 +03:00
parent 097445bc20
commit e76f9f14ed
No known key found for this signature in database
GPG Key ID: 02CE38DA47E9D691
1 changed files with 22 additions and 4 deletions

View File

@ -25,7 +25,7 @@ use smithay::{
}, },
xdg::{ xdg::{
xdg_shell_init, PopupConfigure, ShellState as XdgShellState, ToplevelConfigure, XdgRequest, xdg_shell_init, PopupConfigure, ShellState as XdgShellState, ToplevelConfigure, XdgRequest,
XdgSurfaceRole, XdgSurfacePendingState, XdgSurfaceRole,
}, },
}, },
SERIAL_COUNTER as SCOUNTER, SERIAL_COUNTER as SCOUNTER,
@ -577,6 +577,14 @@ pub struct SurfaceData {
pub geometry: Option<Rectangle>, pub geometry: Option<Rectangle>,
pub input_region: Option<RegionAttributes>, pub input_region: Option<RegionAttributes>,
pub resize_state: ResizeState, pub resize_state: ResizeState,
/// Minimum width and height, as requested by the surface.
///
/// `0` means unlimited.
pub min_size: (i32, i32),
/// Maximum width and height, as requested by the surface.
///
/// `0` means unlimited.
pub max_size: (i32, i32),
} }
impl SurfaceData { impl SurfaceData {
@ -622,9 +630,17 @@ fn surface_commit(
buffer_utils: &BufferUtils, buffer_utils: &BufferUtils,
window_map: &RefCell<MyWindowMap>, window_map: &RefCell<MyWindowMap>,
) { ) {
let geometry = token let mut geometry = None;
.with_role_data(surface, |role: &mut XdgSurfaceRole| role.window_geometry) let mut min_size = (0, 0);
.unwrap_or(None); let mut max_size = (0, 0);
let _ = token.with_role_data(surface, |role: &mut XdgSurfaceRole| {
if let XdgSurfacePendingState::Toplevel(ref state) = role.pending_state {
min_size = state.min_size;
max_size = state.max_size;
}
geometry = role.window_geometry;
});
let refresh = token.with_surface_data(surface, |attributes| { let refresh = token.with_surface_data(surface, |attributes| {
attributes.user_data.insert_if_missing(SurfaceData::default); attributes.user_data.insert_if_missing(SurfaceData::default);
@ -632,6 +648,8 @@ fn surface_commit(
data.geometry = geometry; data.geometry = geometry;
data.input_region = attributes.input_region.clone(); data.input_region = attributes.input_region.clone();
data.min_size = min_size;
data.max_size = max_size;
// we retrieve the contents of the associated buffer and copy it // we retrieve the contents of the associated buffer and copy it
match attributes.buffer.take() { match attributes.buffer.take() {