Skip to content

Commit

Permalink
refactor: rename the action of iced_layershell
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Nov 28, 2024
1 parent c41423c commit e168571
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
10 changes: 5 additions & 5 deletions iced_examples/zbus_invoked_widget/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ impl TryInto<LaLaShellIdAction> for Message {
match self {
Self::NewWindow => Ok(LaLaShellIdAction::new(
None,
LalaShellAction::NewLayerShell((
NewLayerShellSettings {
LalaShellAction::NewLayerShell {
settings: NewLayerShellSettings {
size: None,
exclusive_zone: None,
anchor: Anchor::Right | Anchor::Top | Anchor::Left | Anchor::Bottom,
Expand All @@ -56,9 +56,9 @@ impl TryInto<LaLaShellIdAction> for Message {
use_last_output: false,
..Default::default()
},
(),
false,
)),
info: (),
single_tone: false,
},
)),
_ => Err(self),
}
Expand Down
17 changes: 14 additions & 3 deletions iced_layershell/src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,20 @@ pub enum LayershellCustomActionsWithInfo<INFO: Clone> {
time: u32,
key: u32,
},
NewLayerShell((NewLayerShellSettings, INFO, bool)),
NewPopUp((IcedNewPopupSettings, INFO)),
NewMenu((IcedNewMenuSettings, INFO)),
// settings, info, single_tone
NewLayerShell {
settings: NewLayerShellSettings,
info: INFO,
single_tone: bool,
},
NewPopUp {
settings: IcedNewPopupSettings,
info: INFO,
},
NewMenu {
settings: IcedNewMenuSettings,
info: INFO,
},
/// is same with WindowAction::Close(id)
RemoveWindow(IcedId),
ForgetLastOutput,
Expand Down
21 changes: 17 additions & 4 deletions iced_layershell/src/multi_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ where
)
.ok();
}
LayershellCustomActionsWithInfo::NewLayerShell((settings, info, _)) => {
LayershellCustomActionsWithInfo::NewLayerShell {
settings, info, ..
} => {
ev.append_return_data(ReturnData::NewLayerShell((
settings,
Some(info),
Expand All @@ -403,7 +405,10 @@ where
))
.ok();
}
LayershellCustomActionsWithInfo::NewPopUp((menusettings, info)) => {
LayershellCustomActionsWithInfo::NewPopUp {
settings: menusettings,
info,
} => {
let IcedNewPopupSettings { size, position } = menusettings;
let Some(id) = ev.current_surface_id() else {
break 'out;
Expand All @@ -414,7 +419,10 @@ where
Some(info),
)));
}
LayershellCustomActionsWithInfo::NewMenu((menusetting, info)) => {
LayershellCustomActionsWithInfo::NewMenu {
settings: menusetting,
info,
} => {
let Some(id) = ev.current_surface_id() else {
break 'out;
};
Expand Down Expand Up @@ -1000,7 +1008,12 @@ pub(crate) fn run_action<A, C>(
Action::Output(stream) => match stream.try_into() {
Ok(action) => {
let action: LayershellCustomActionsWithIdAndInfo<A::WindowInfo> = action;
if let LayershellCustomActionsWithInfo::NewLayerShell((_, info, true)) = &action.1 {
if let LayershellCustomActionsWithInfo::NewLayerShell {
info,
single_tone: true,
..
} = &action.1
{
if singleton_layers.contains(info) {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions iced_layershell_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ pub fn to_layer_message(attr: TokenStream2, input: TokenStream2) -> manyhow::Res
None,
InnerLayerAction::VirtualKeyboardPressed { time, key })
),
Self::NewLayerShell {settings, info, single_tone } => Ok(InnerLayerActionId::new(None, InnerLayerAction::NewLayerShell((settings, info, single_tone)))),
Self::NewPopUp { settings, info } => Ok(InnerLayerActionId::new(None, InnerLayerAction::NewPopUp((settings, info)))),
Self::NewMenu { settings, info } => Ok(InnerLayerActionId::new(None, InnerLayerAction::NewMenu((settings, info)))),
Self::NewLayerShell {settings, info, single_tone } => Ok(InnerLayerActionId::new(None, InnerLayerAction::NewLayerShell { settings, info, single_tone })),
Self::NewPopUp { settings, info } => Ok(InnerLayerActionId::new(None, InnerLayerAction::NewPopUp { settings, info })),
Self::NewMenu { settings, info } => Ok(InnerLayerActionId::new(None, InnerLayerAction::NewMenu {settings, info })),
Self::RemoveWindow(id) => Ok(InnerLayerActionId::new(None, InnerLayerAction::RemoveWindow(id))),
Self::ForgetLastOutput => Ok(InnerLayerActionId::new(None, InnerLayerAction::ForgetLastOutput)),
_ => Err(self)
Expand Down

0 comments on commit e168571

Please sign in to comment.