Deduplicate drag_surface code a bit
This commit is contained in:
parent
a6832ef888
commit
7ff45540e8
1 changed files with 16 additions and 17 deletions
|
|
@ -88,31 +88,30 @@ pub(crate) fn drag_surface<'a>(
|
||||||
drag_surface: &DragSurface,
|
drag_surface: &DragSurface,
|
||||||
size: Size,
|
size: Size,
|
||||||
) -> Option<cosmic::Element<'a, Msg>> {
|
) -> Option<cosmic::Element<'a, Msg>> {
|
||||||
match drag_surface {
|
let item = match drag_surface {
|
||||||
DragSurface::Workspace { handle, output } => {
|
DragSurface::Workspace { handle, output } => {
|
||||||
if let Some(workspace) = app.workspaces.iter().find(|x| &x.handle == handle) {
|
if let Some(workspace) = app.workspaces.iter().find(|x| &x.handle == handle) {
|
||||||
let item = workspace_item(workspace, output, false);
|
workspace_item(workspace, output, false)
|
||||||
return Some(
|
} else {
|
||||||
widget::container(item)
|
return None;
|
||||||
.height(iced::Length::Fixed(size.height))
|
|
||||||
.width(iced::Length::Fixed(size.width))
|
|
||||||
.into(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DragSurface::Toplevel { handle, .. } => {
|
DragSurface::Toplevel { handle, .. } => {
|
||||||
if let Some(toplevel) = app.toplevels.iter().find(|x| &x.handle == handle) {
|
if let Some(toplevel) = app.toplevels.iter().find(|x| &x.handle == handle) {
|
||||||
let item = toplevel_preview(toplevel, true);
|
toplevel_preview(toplevel, true)
|
||||||
return Some(
|
} else {
|
||||||
widget::container(item)
|
return None;
|
||||||
.height(iced::Length::Fixed(size.height))
|
|
||||||
.width(iced::Length::Fixed(size.width))
|
|
||||||
.into(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
None
|
// TODO Use `mouse_interaction_wrapper` (need to modify iced_sctk to update view of
|
||||||
|
// drag surfaces)
|
||||||
|
Some(
|
||||||
|
widget::container(item)
|
||||||
|
.height(iced::Length::Fixed(size.height))
|
||||||
|
.width(iced::Length::Fixed(size.width))
|
||||||
|
.into(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close_button(on_press: Msg) -> cosmic::Element<'static, Msg> {
|
fn close_button(on_press: Msg) -> cosmic::Element<'static, Msg> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue