libcosmic-yoda/src/surface/mod.rs
Lionel DARNIS 9535ada4d0 Merge upstream/master (COSMIC 1.6) into main
Aligne le fork sur epoch-1.6.0 (63 commits amont) en preservant les 19
commits yoda.

Resolutions notables :
- les cfg `all(feature = "wayland", target_os = "linux")` deviennent
  l alias `wayland_platform` introduit en amont ; il exclut winit comme
  le faisait le patch yoda 45eaaf16, l intention est donc preservee ;
- les features iced `cctk` ont ete renommees `wayland` en amont, la
  feature `wayland` locale est adaptee ; `winit` reste un marqueur vide
  et `iced/winit` est liste explicitement ;
- cctk/ashpd gardent leurs chemins locaux dans la section conditionnelle
  unix introduite en amont ;
- la garde anti-crash c0b653f5 (context_menu non assigne) est conservee
  par-dessus la nouvelle structure amont ;
- traductions ca/oc restaurees depuis amont.

Le submodule iced suit (merge + correctif du cfg cctk residuel).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-19 21:55:00 +02:00

154 lines
5.3 KiB
Rust

// Copyright 2025 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
pub mod action;
#[cfg(wayland_platform)]
pub mod corner_radius;
use iced::{Limits, Size, Task};
use std::any::Any;
use std::sync::Arc;
type BoxedSetting = Arc<Box<dyn Any + Send + Sync + 'static>>;
/// Ignore this message in your application. It will be intercepted.
#[derive(Clone)]
pub enum Action {
/// Create a subsurface with a view function accepting the App as a parameter
AppSubsurface(BoxedSetting, BoxedSetting, Option<BoxedSetting>),
/// Create a subsurface with a view function
Subsurface(BoxedSetting, BoxedSetting, Option<BoxedSetting>),
/// Destroy a subsurface with a view function
DestroySubsurface(iced::window::Id),
/// Create a popup with a view function accepting the App as a parameter
AppPopup(BoxedSetting, BoxedSetting, Option<BoxedSetting>),
/// Create a popup
Popup(BoxedSetting, BoxedSetting, Option<BoxedSetting>),
/// Destroy a subsurface with a view function
DestroyPopup(iced::window::Id),
/// Destroys the global tooltip popup subsurface
DestroyTooltipPopup,
/// Create a window with a view function accepting the App as a parameter
AppWindow(
iced::window::Id,
BoxedSetting,
BoxedSetting,
Option<BoxedSetting>,
),
/// Create a window with a view function
Window(
iced::window::Id,
BoxedSetting,
BoxedSetting,
Option<BoxedSetting>,
),
/// Destroy a window
DestroyWindow(iced::window::Id),
/// Create a layer shell surface with a view function accepting the App as a parameter
AppLayerShell(BoxedSetting, BoxedSetting, Option<BoxedSetting>),
/// Create a layer shell surface with a view function
LayerShell(BoxedSetting, BoxedSetting, Option<BoxedSetting>),
/// Destroy a layer shell surface
DestroyLayerShell(iced::window::Id),
/// Responsive menu bar update
ResponsiveMenuBar {
/// Id of the menu bar
menu_bar: crate::widget::Id,
/// Limits of the menu bar
limits: Limits,
/// Requested Full Size for expanded menu bar
size: Size,
},
Ignore,
SyncLiveSettings(iced::window::Id),
Task(Arc<dyn Fn() -> Task<Action> + Send + Sync>),
}
pub fn surface_task<M: Send + 'static>(action: Action) -> Task<crate::Action<M>> {
crate::task::message(crate::Action::Cosmic(crate::app::Action::Surface(action)))
}
impl std::fmt::Debug for Action {
#[cold]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::AppSubsurface(arg0, arg1, arg2) => f
.debug_tuple("AppSubsurface")
.field(arg0)
.field(arg1)
.field(arg2)
.finish(),
Self::Subsurface(arg0, arg1, arg2) => f
.debug_tuple("Subsurface")
.field(arg0)
.field(arg1)
.field(arg2)
.finish(),
Self::DestroySubsurface(arg0) => {
f.debug_tuple("DestroySubsurface").field(arg0).finish()
}
Self::AppPopup(arg0, arg1, arg2) => f
.debug_tuple("AppPopup")
.field(arg0)
.field(arg1)
.field(arg2)
.finish(),
Self::Popup(arg0, arg1, arg2) => f
.debug_tuple("Popup")
.field(arg0)
.field(arg1)
.field(arg2)
.finish(),
Self::DestroyPopup(arg0) => f.debug_tuple("DestroyPopup").field(arg0).finish(),
Self::DestroyTooltipPopup => f.debug_tuple("DestroyTooltipPopup").finish(),
Self::ResponsiveMenuBar {
menu_bar,
limits,
size,
} => f
.debug_struct("ResponsiveMenuBar")
.field("menu_bar", menu_bar)
.field("limits", limits)
.field("size", size)
.finish(),
Self::Ignore => write!(f, "Ignore"),
Self::AppWindow(id, arg0, arg1, arg2) => f
.debug_tuple("AppWindow")
.field(id)
.field(arg0)
.field(arg1)
.field(arg2)
.finish(),
Self::Window(id, arg0, arg1, arg2) => f
.debug_tuple("Window")
.field(id)
.field(arg0)
.field(arg1)
.field(arg2)
.finish(),
Self::DestroyWindow(arg0) => f.debug_tuple("DestroyWindow").field(arg0).finish(),
Self::Task(_) => f.debug_tuple("Future").finish(),
Self::AppLayerShell(arg, arg1, arg2) => f
.debug_tuple("AppLayerShell")
.field(arg)
.field(arg1)
.field(arg2)
.finish(),
Self::LayerShell(arg, arg1, arg2) => f
.debug_tuple("LayerShell")
.field(arg)
.field(arg1)
.field(arg2)
.finish(),
Self::DestroyLayerShell(arg0) => {
f.debug_tuple("DestroyLayerShell").field(arg0).finish()
}
Self::SyncLiveSettings(arg0) => f.debug_tuple("SyncLiveSettings").field(arg0).finish(),
}
}
}