dnd: Keep track of drop target
Now just need a protocol to move the toplevel to a workspace.
This commit is contained in:
parent
f2c77d035c
commit
5550f41814
2 changed files with 20 additions and 4 deletions
20
src/main.rs
20
src/main.rs
|
|
@ -104,7 +104,13 @@ enum Msg {
|
||||||
ActivateToplevel(zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1),
|
ActivateToplevel(zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1),
|
||||||
CloseToplevel(zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1),
|
CloseToplevel(zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1),
|
||||||
StartDrag(Size, DragSurface),
|
StartDrag(Size, DragSurface),
|
||||||
DndWorkspaceEnter(DndAction, Vec<String>, (f32, f32)),
|
DndWorkspaceEnter(
|
||||||
|
zcosmic_workspace_handle_v1::ZcosmicWorkspaceHandleV1,
|
||||||
|
wl_output::WlOutput,
|
||||||
|
DndAction,
|
||||||
|
Vec<String>,
|
||||||
|
(f32, f32),
|
||||||
|
),
|
||||||
DndWorkspaceLeave,
|
DndWorkspaceLeave,
|
||||||
DndWorkspaceDrop,
|
DndWorkspaceDrop,
|
||||||
DndWorkspaceData(String, Vec<u8>),
|
DndWorkspaceData(String, Vec<u8>),
|
||||||
|
|
@ -188,6 +194,10 @@ struct App {
|
||||||
drag_surface: Option<(SurfaceId, DragSurface, Size)>,
|
drag_surface: Option<(SurfaceId, DragSurface, Size)>,
|
||||||
conf: Conf,
|
conf: Conf,
|
||||||
core: cosmic::app::Core,
|
core: cosmic::app::Core,
|
||||||
|
drop_target: Option<(
|
||||||
|
zcosmic_workspace_handle_v1::ZcosmicWorkspaceHandleV1,
|
||||||
|
wl_output::WlOutput,
|
||||||
|
)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
|
|
@ -516,7 +526,8 @@ impl Application for App {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Msg::DndWorkspaceEnter(action, mimes, (_x, _y)) => {
|
Msg::DndWorkspaceEnter(handle, output, action, mimes, (_x, _y)) => {
|
||||||
|
self.drop_target = Some((handle, output));
|
||||||
// XXX
|
// XXX
|
||||||
// if mimes.iter().any(|x| x == WORKSPACE_MIME) && action == DndAction::Move {
|
// if mimes.iter().any(|x| x == WORKSPACE_MIME) && action == DndAction::Move {
|
||||||
if mimes.iter().any(|x| x == &*TOPLEVEL_MIME) {
|
if mimes.iter().any(|x| x == &*TOPLEVEL_MIME) {
|
||||||
|
|
@ -527,6 +538,7 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Msg::DndWorkspaceLeave => {
|
Msg::DndWorkspaceLeave => {
|
||||||
|
self.drop_target = None;
|
||||||
return accept_mime_type(None);
|
return accept_mime_type(None);
|
||||||
}
|
}
|
||||||
Msg::DndWorkspaceDrop => {
|
Msg::DndWorkspaceDrop => {
|
||||||
|
|
@ -541,7 +553,9 @@ impl Application for App {
|
||||||
if let Some((_, DragSurface::Toplevel { handle, .. }, _)) = &self.drag_surface {
|
if let Some((_, DragSurface::Toplevel { handle, .. }, _)) = &self.drag_surface {
|
||||||
if let Some(toplevel) = self.toplevels.iter().find(|t| &t.handle == handle)
|
if let Some(toplevel) = self.toplevels.iter().find(|t| &t.handle == handle)
|
||||||
{
|
{
|
||||||
dbg!(toplevel);
|
if let Some(drop_target) = &self.drop_target {
|
||||||
|
dbg!(drop_target, toplevel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,9 @@ fn workspace_sidebar_entry<'a>(
|
||||||
.into()
|
.into()
|
||||||
*/
|
*/
|
||||||
iced::widget::dnd_listener(workspace_item(workspace, output))
|
iced::widget::dnd_listener(workspace_item(workspace, output))
|
||||||
.on_enter(Msg::DndWorkspaceEnter)
|
.on_enter(|actions, mime, pos| {
|
||||||
|
Msg::DndWorkspaceEnter(workspace.handle.clone(), output.clone(), actions, mime, pos)
|
||||||
|
})
|
||||||
.on_exit(Msg::DndWorkspaceLeave)
|
.on_exit(Msg::DndWorkspaceLeave)
|
||||||
.on_drop(Msg::DndWorkspaceDrop)
|
.on_drop(Msg::DndWorkspaceDrop)
|
||||||
.on_data(Msg::DndWorkspaceData)
|
.on_data(Msg::DndWorkspaceData)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue