diff --git a/src/app.rs b/src/app.rs index a1654c4..0c42738 100644 --- a/src/app.rs +++ b/src/app.rs @@ -210,7 +210,6 @@ enum Message { FinishDndOffer(usize, DesktopEntryData), LeaveDndOffer, ScrollYOffset(f32), - Ignore, GpuUpdate(Option>), } @@ -580,7 +579,6 @@ impl cosmic::Application for CosmicAppLibrary { self.group_to_delete = None; return destroy_layer_surface(DELETE_GROUP_WINDOW_ID.clone()); } - Message::Ignore => {} Message::FilterApps(input, filtered_apps) => { self.entry_path_input = filtered_apps; self.waiting_for_filtered = false; @@ -922,27 +920,25 @@ impl cosmic::Application for CosmicAppLibrary { .iter() .enumerate() .map(|(i, entry)| { + let gpu_idx = self.gpus.as_ref().map(|gpus| { + if entry.prefers_dgpu { + gpus.iter().position(|gpu| !gpu.default).unwrap_or(0) + } else { + gpus.iter().position(|gpu| gpu.default).unwrap_or(0) + } + }); let mut b = ApplicationButton::new( &entry, - Message::Ignore, move |rect| Message::OpenContextMenu(rect, i), - if self.menu.is_some() { - None + if self.menu.is_none() { + Some(Message::ActivateApp(i, gpu_idx)) } else { - Some(Message::Ignore) + None }, spacing, ); if self.menu.is_none() { - let gpu_idx = self.gpus.as_ref().map(|gpus| { - if entry.prefers_dgpu { - gpus.iter().position(|gpu| !gpu.default).unwrap_or(0) - } else { - gpus.iter().position(|gpu| gpu.default).unwrap_or(0) - } - }); b = b - .on_pressed(Message::ActivateApp(i, gpu_idx)) .on_cancel(Message::CancelDrag) .on_finish(Message::FinishDrag) .on_create_dnd_source(Message::StartDrag(i)) diff --git a/src/widgets/application.rs b/src/widgets/application.rs index 24dc3d5..37d617a 100644 --- a/src/widgets/application.rs +++ b/src/widgets/application.rs @@ -36,8 +36,6 @@ pub struct ApplicationButton<'a, Message> { on_right_release: Box Message + 'a>, - on_pressed: Option, - on_create_dnd_source: Option, on_finish: Option Message + 'a>>, @@ -68,7 +66,6 @@ impl<'a, Message: Clone + 'static> ApplicationButton<'a, Message> { path, .. }: &'a DesktopEntryData, - ignore_button: Message, on_right_release: impl Fn(Rectangle) -> Message + 'a, on_pressed: Option, spacing: &Spacing, @@ -99,7 +96,7 @@ impl<'a, Message: Clone + 'static> ApplicationButton<'a, Message> { .style(theme::Button::IconVertical) .padding(spacing.space_s); let content = if on_pressed.is_some() { - content.on_press(ignore_button.clone()) + content.on_press_maybe(on_pressed.clone()) } else { content } @@ -108,7 +105,6 @@ impl<'a, Message: Clone + 'static> ApplicationButton<'a, Message> { path: path.clone().unwrap(), content, on_right_release: Box::new(on_right_release), - on_pressed, on_create_dnd_source: None, on_dnd_command_produced: None, on_finish: None, @@ -116,13 +112,6 @@ impl<'a, Message: Clone + 'static> ApplicationButton<'a, Message> { } } - pub fn on_pressed(self, on_pressed: Message) -> Self { - Self { - on_pressed: Some(on_pressed), - ..self - } - } - pub fn on_dnd_command_produced( self, message: impl Fn( @@ -391,16 +380,6 @@ where DraggingState::Pressed(start) } } - event::Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) - | event::Event::Touch( - touch::Event::FingerLifted { .. } | touch::Event::FingerLost { .. }, - ) => { - ret = event::Status::Captured; - if let Some(on_pressed) = self.on_pressed.clone() { - shell.publish(on_pressed); - } - DraggingState::None - } _ => DraggingState::Pressed(start), } }