1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
use insta::assert_snapshot;
use smithay::reexports::wayland_protocols_wlr::layer_shell::v1::client::zwlr_layer_shell_v1::Layer;
use smithay::reexports::wayland_protocols_wlr::layer_shell::v1::client::zwlr_layer_surface_v1::Anchor;
use super::*;
use crate::tests::client::{LayerConfigureProps, LayerMargin};
#[test]
fn simple_top_anchor() {
let mut f = Fixture::new();
f.add_output(1, (1920, 1080));
let id = f.add_client();
let layer = f.client(id).create_layer(None, Layer::Top, "");
let surface = layer.surface.clone();
layer.set_configure_props(LayerConfigureProps {
anchor: Some(Anchor::Left | Anchor::Right | Anchor::Top),
size: Some((0, 50)),
..Default::default()
});
layer.commit();
f.roundtrip(id);
let layer = f.client(id).layer(&surface);
layer.attach_new_buffer();
layer.set_size(100, 100);
layer.ack_last_and_commit();
f.double_roundtrip(id);
let layer = f.client(id).layer(&surface);
assert_snapshot!(layer.format_recent_configures(), @"size: 1920 × 50");
}
#[test]
fn margin_overflow() {
let mut f = Fixture::new();
f.add_output(1, (1920, 1080));
let id = f.add_client();
let layer = f.client(id).create_layer(None, Layer::Top, "");
let surface = layer.surface.clone();
layer.set_configure_props(LayerConfigureProps {
anchor: Some(Anchor::Left | Anchor::Right | Anchor::Top | Anchor::Bottom),
margin: Some(LayerMargin {
top: i32::MAX,
right: i32::MAX,
bottom: i32::MAX,
left: i32::MAX,
}),
exclusive_zone: Some(i32::MAX),
..Default::default()
});
layer.commit();
f.roundtrip(id);
let layer = f.client(id).layer(&surface);
layer.attach_new_buffer();
layer.set_size(100, 100);
layer.ack_last_and_commit();
f.double_roundtrip(id);
let layer = f.client(id).layer(&surface);
assert_snapshot!(layer.format_recent_configures(), @"size: 0 × 0");
// Add a second one for good measure.
let layer = f.client(id).create_layer(None, Layer::Top, "");
let surface = layer.surface.clone();
layer.set_configure_props(LayerConfigureProps {
anchor: Some(Anchor::Left | Anchor::Right | Anchor::Top | Anchor::Bottom),
margin: Some(LayerMargin {
top: i32::MAX,
right: i32::MAX,
bottom: i32::MAX,
left: i32::MAX,
}),
exclusive_zone: Some(i32::MAX),
..Default::default()
});
layer.commit();
f.roundtrip(id);
let layer = f.client(id).layer(&surface);
layer.attach_new_buffer();
layer.set_size(100, 100);
layer.ack_last_and_commit();
f.double_roundtrip(id);
let layer = f.client(id).layer(&surface);
assert_snapshot!(layer.format_recent_configures(), @"size: 0 × 0");
}
|