1use gpui::*;
2
3struct WindowContent {
4 text: SharedString,
5}
6
7impl Render for WindowContent {
8 fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
9 div()
10 .flex()
11 .bg(rgb(0x1e2025))
12 .size_full()
13 .justify_center()
14 .items_center()
15 .text_xl()
16 .text_color(rgb(0xffffff))
17 .child(self.text.clone())
18 }
19}
20
21fn main() {
22 App::new().run(|cx: &mut AppContext| {
23 // Create several new windows, positioned in the top right corner of each screen
24
25 for screen in cx.displays() {
26 let options = {
27 let margin_right = px(16.);
28 let margin_height = px(-48.);
29
30 let size = Size {
31 width: px(400.),
32 height: px(72.),
33 };
34
35 let bounds = gpui::Bounds::<Pixels> {
36 origin: screen.bounds().upper_right()
37 - point(size.width + margin_right, margin_height),
38 size,
39 };
40
41 WindowOptions {
42 // Set the bounds of the window in screen coordinates
43 window_bounds: Some(WindowBounds::Windowed(bounds)),
44 // Specify the display_id to ensure the window is created on the correct screen
45 display_id: Some(screen.id()),
46
47 titlebar: None,
48 window_background: WindowBackgroundAppearance::default(),
49 focus: false,
50 show: true,
51 kind: WindowKind::PopUp,
52 is_movable: false,
53 app_id: None,
54 window_min_size: None,
55 }
56 };
57
58 cx.open_window(options, |cx| {
59 cx.new_view(|_| WindowContent {
60 text: format!("{:?}", screen.id()).into(),
61 })
62 })
63 .unwrap();
64 }
65 });
66}