diff --git a/portal/assets/stop.svg b/portal/assets/stop.svg
deleted file mode 100644
index a2a7347..0000000
--- a/portal/assets/stop.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/portal/src/backend.rs b/portal/src/backend.rs
index 789149f..16f82dd 100644
--- a/portal/src/backend.rs
+++ b/portal/src/backend.rs
@@ -364,14 +364,14 @@ impl Backend {
}
let result = tokio::select! {
_ = cancel.wait() => Err(StartError::Cancelled),
- result = tokio::time::timeout(Duration::from_secs(120), start_streams(if bar_controlled { "Ferese" } else { &app_id }, multiple, cursor, !bar_controlled)) => result.unwrap_or_else(|_| Err(StartError::Failed("Sharing request timed out".into()))),
+ result = tokio::time::timeout(Duration::from_secs(120), start_streams(if bar_controlled { "Ferese" } else { &app_id }, multiple, cursor)) => result.unwrap_or_else(|_| Err(StartError::Failed("Sharing request timed out".into()))),
};
let _ = connection
.object_server()
.remove::(handle)
.await;
match result {
- Ok((children, indicator, streams)) if !cancel.stopped.load(Ordering::SeqCst) => {
+ Ok((children, streams)) if !cancel.stopped.load(Ordering::SeqCst) => {
if let Some(session) = self.sessions.lock().await.get_mut(session_handle.as_str()) {
session.phase = Phase::Running;
}
@@ -379,7 +379,7 @@ impl Backend {
let connection = connection.clone();
let path = session_handle.to_string();
tokio::spawn(async move {
- supervise(children, indicator, cancel).await;
+ supervise(children, cancel).await;
backend.end(&connection, &path).await;
});
let streams: Vec<(u32, Options)> = streams
@@ -488,8 +488,7 @@ async fn start_streams(
app: &str,
multiple: bool,
cursor: bool,
- show_indicator: bool,
-) -> Result<(Vec, Option, Vec), StartError> {
+) -> Result<(Vec, Vec), StartError> {
let sources = tokio::task::spawn_blocking(|| {
Capture::connect(&AtomicBool::new(false)).map(|capture| capture.sources())
})
@@ -499,7 +498,6 @@ async fn start_streams(
app: app.to_owned(),
sources,
multiple,
- indicator: false,
};
let selection = picker(&prompt)
.await?
@@ -544,20 +542,7 @@ async fn start_streams(
streams.push(ready);
children.push(child);
}
- let indicator = if show_indicator {
- Some(
- picker(&Prompt {
- app: app.to_owned(),
- sources: selected,
- multiple,
- indicator: true,
- })
- .await?,
- )
- } else {
- None
- };
- Ok((children, indicator, streams))
+ Ok((children, streams))
}
fn validate_selection(
sources: &[Source],
@@ -582,12 +567,9 @@ fn validate_selection(
}
Ok(selected)
}
-async fn supervise(mut children: Vec, mut indicator: Option, cancel: Arc) {
+async fn supervise(mut children: Vec, cancel: Arc) {
loop {
if cancel.stopped.load(Ordering::SeqCst)
- || indicator
- .as_mut()
- .is_some_and(|child| !matches!(child.try_wait(), Ok(None)))
|| children
.iter_mut()
.any(|c| !matches!(c.try_wait(), Ok(None)))
@@ -600,9 +582,6 @@ async fn supervise(mut children: Vec, mut indicator: Option, cance
for child in &mut children {
let _ = child.kill().await;
}
- if let Some(indicator) = &mut indicator {
- let _ = indicator.kill().await;
- }
}
pub async fn run() -> Result<(), Box> {
let backend = Backend::default();
diff --git a/portal/src/picker.rs b/portal/src/picker.rs
index 8ee7846..85190b9 100644
--- a/portal/src/picker.rs
+++ b/portal/src/picker.rs
@@ -13,7 +13,6 @@ pub struct Prompt {
pub app: String,
pub sources: Vec,
pub multiple: bool,
- pub indicator: bool,
}
#[derive(Clone, Debug)]
@@ -86,15 +85,10 @@ impl cosmic::Application for Picker {
background,
foreground,
};
- let title = if app.prompt.indicator {
- "Ferese — screen sharing"
- } else {
- "Ferese — share your screen"
- };
let task = app
.core
.main_window_id()
- .map(|id| app.set_window_title(title.into(), id))
+ .map(|id| app.set_window_title("Ferese — share your screen".into(), id))
.unwrap_or_else(Task::none);
(app, task)
@@ -148,18 +142,8 @@ impl cosmic::Application for Picker {
row![
glyph(include_bytes!("../assets/display.svg"), 24),
column![
- text(if self.prompt.indicator {
- "Screen sharing"
- } else {
- "Choose a display"
- })
- .size(18),
- text(if self.prompt.indicator {
- format!("Shared with {app}")
- } else {
- format!("Share with {app}")
- })
- .size(12),
+ text("Choose a display").size(18),
+ text(format!("Share with {app}")).size(12),
]
.spacing(2)
.width(Length::Fill),
@@ -181,24 +165,20 @@ impl cosmic::Application for Picker {
]
.spacing(12)
.align_y(Alignment::Center);
- if selected || self.prompt.indicator {
+ if selected {
entry = entry.push(glyph(include_bytes!("../assets/check.svg"), 20));
}
- if self.prompt.indicator {
- sources = sources.push(container(entry).padding(8).width(Length::Fill));
- } else {
- sources = sources.push(
- button::custom(entry)
- .class(if selected {
- ferese_theme::accent_button()
- } else {
- cosmic::theme::Button::Standard
- })
- .padding(8)
- .width(Length::Fill)
- .on_press(Message::Select(index)),
- );
- }
+ sources = sources.push(
+ button::custom(entry)
+ .class(if selected {
+ ferese_theme::accent_button()
+ } else {
+ cosmic::theme::Button::Standard
+ })
+ .padding(8)
+ .width(Length::Fill)
+ .on_press(Message::Select(index)),
+ );
}
content = content.push(scrollable(sources).height(Length::Fixed(
(self.prompt.sources.len().min(4) * 56) as f32,
@@ -208,37 +188,21 @@ impl cosmic::Application for Picker {
.size(12)
.width(Length::Fill),
);
- if self.prompt.indicator {
- content = content.push(
- button::custom(
- row![
- glyph(include_bytes!("../assets/stop.svg"), 16),
- text("Stop sharing")
- ]
- .spacing(8)
- .align_y(Alignment::Center),
- )
- .class(cosmic::theme::Button::Destructive)
- .padding([6, 16])
- .on_press(Message::Cancel),
- );
- } else {
- let mut share = button::custom(
- row![
- text("Share"),
- glyph(include_bytes!("../assets/arrow.svg"), 16)
- ]
- .spacing(8)
- .align_y(Alignment::Center),
- )
- .class(ferese_theme::accent_button())
- .padding([6, 16]);
- if !self.selected.is_empty() {
- share = share.on_press(Message::Share);
- }
- content = content
- .push(row![button::text("Cancel").on_press(Message::Cancel), share].spacing(8));
+ let mut share = button::custom(
+ row![
+ text("Share"),
+ glyph(include_bytes!("../assets/arrow.svg"), 16)
+ ]
+ .spacing(8)
+ .align_y(Alignment::Center),
+ )
+ .class(ferese_theme::accent_button())
+ .padding([6, 16]);
+ if !self.selected.is_empty() {
+ share = share.on_press(Message::Share);
}
+ content =
+ content.push(row![button::text("Cancel").on_press(Message::Cancel), share].spacing(8));
container(content).padding(14).width(Length::Fill).into()
}
}