active_call_popover.rs

 1use gpui::{color::Color, elements::*, Entity, RenderContext, View, ViewContext};
 2
 3pub enum Event {
 4    Deactivated,
 5}
 6
 7pub struct ActiveCallPopover {
 8    _subscription: gpui::Subscription,
 9}
10
11impl Entity for ActiveCallPopover {
12    type Event = Event;
13}
14
15impl View for ActiveCallPopover {
16    fn ui_name() -> &'static str {
17        "ActiveCallPopover"
18    }
19
20    fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
21        Empty::new()
22            .contained()
23            .with_background_color(Color::red())
24            .boxed()
25    }
26}
27
28impl ActiveCallPopover {
29    pub fn new(cx: &mut ViewContext<Self>) -> Self {
30        Self {
31            _subscription: cx.observe_window_activation(Self::window_activation_changed),
32        }
33    }
34
35    fn window_activation_changed(&mut self, is_active: bool, cx: &mut ViewContext<Self>) {
36        if !is_active {
37            cx.emit(Event::Deactivated);
38        }
39    }
40}