refactor: make SurfaceMessage handling opt in
This commit is contained in:
parent
9352c0241e
commit
17ad618fae
4 changed files with 16 additions and 7 deletions
|
|
@ -71,7 +71,9 @@ wayland = [
|
|||
"iced/wayland",
|
||||
"iced_winit/wayland",
|
||||
"cctk",
|
||||
"surface-message",
|
||||
]
|
||||
surface-message = []
|
||||
# multi-window support
|
||||
multi-window = ["iced/multi-window"]
|
||||
# Render with wgpu
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use apply::Apply;
|
|||
use cosmic::app::{Core, Settings, Task};
|
||||
use cosmic::dialog::file_chooser::{self, FileFilter};
|
||||
use cosmic::iced_core::Length;
|
||||
use cosmic::surface_message::{SurfaceMessage, SurfaceMessageHandler};
|
||||
use cosmic::surface_message::{MessageWrapper, SurfaceMessage};
|
||||
use cosmic::widget::button;
|
||||
use cosmic::{executor, iced, ApplicationExt, Element};
|
||||
use std::sync::Arc;
|
||||
|
|
@ -38,11 +38,11 @@ pub enum Message {
|
|||
Surface(SurfaceMessage),
|
||||
}
|
||||
|
||||
impl SurfaceMessageHandler for Message {
|
||||
fn to_surface_message(self) -> cosmic::surface_message::MessageWrapper<Self> {
|
||||
match self {
|
||||
Message::Surface(m) => cosmic::surface_message::MessageWrapper::Surface(m),
|
||||
m => cosmic::surface_message::MessageWrapper::Message(m),
|
||||
impl From<Message> for MessageWrapper<Message> {
|
||||
fn from(value: Message) -> Self {
|
||||
match value {
|
||||
Message::Surface(s) => MessageWrapper::Surface(s),
|
||||
m => MessageWrapper::Message(m),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ impl Core {
|
|||
id
|
||||
}
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
#[cfg(feature = "surface-message")]
|
||||
/// # Panics
|
||||
///
|
||||
/// Will panic if the menu bar collapses without tracking the size
|
||||
|
|
|
|||
|
|
@ -7,6 +7,13 @@ pub enum MessageWrapper<M> {
|
|||
Message(M),
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "surface-message"))]
|
||||
impl<M> From<M> for MessageWrapper<M> {
|
||||
fn from(value: M) -> Self {
|
||||
MessageWrapper::Message(value)
|
||||
}
|
||||
}
|
||||
|
||||
/// Ignore this message in your application. It will be intercepted.
|
||||
#[derive(Clone)]
|
||||
pub enum SurfaceMessage {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue