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 popup_margin_width = DevicePixels::from(16);
28 let popup_margin_height = DevicePixels::from(-0) - DevicePixels::from(48);
29
30 let window_size = Size {
31 width: px(400.),
32 height: px(72.),
33 };
34
35 let screen_bounds = screen.bounds();
36 let size: Size<DevicePixels> = window_size.into();
37
38 let bounds = gpui::Bounds::<DevicePixels> {
39 origin: screen_bounds.upper_right()
40 - point(size.width + popup_margin_width, popup_margin_height),
41 size: window_size.into(),
42 };
43
44 WindowOptions {
45 // Set the bounds of the window in screen coordinates
46 window_bounds: Some(WindowBounds::Windowed(bounds)),
47 // Specify the display_id to ensure the window is created on the correct screen
48 display_id: Some(screen.id()),
49
50 titlebar: None,
51 window_background: WindowBackgroundAppearance::default(),
52 focus: false,
53 show: true,
54 kind: WindowKind::PopUp,
55 is_movable: false,
56 app_id: None,
57 }
58 };
59
60 cx.open_window(options, |cx| {
61 cx.new_view(|_| WindowContent {
62 text: format!("{:?}", screen.id()).into(),
63 })
64 });
65 }
66 });
67}