Apply both offset and alpha to drag surfaces
This commit is contained in:
parent
5e6c6054a9
commit
594ecffa66
2 changed files with 19 additions and 11 deletions
|
|
@ -490,7 +490,7 @@ impl Application for App {
|
||||||
// TODO confirmation?
|
// TODO confirmation?
|
||||||
self.send_wayland_cmd(backend::Cmd::CloseToplevel(toplevel_handle));
|
self.send_wayland_cmd(backend::Cmd::CloseToplevel(toplevel_handle));
|
||||||
}
|
}
|
||||||
Msg::StartDrag(size, _offset, drag_surface) => {
|
Msg::StartDrag(size, offset, drag_surface) => {
|
||||||
let (output, mime_type) = match &drag_surface {
|
let (output, mime_type) = match &drag_surface {
|
||||||
DragSurface::Workspace { handle: _, output } => (output, &*WORKSPACE_MIME),
|
DragSurface::Workspace { handle: _, output } => (output, &*WORKSPACE_MIME),
|
||||||
DragSurface::Toplevel { handle: _, output } => (output, &*TOPLEVEL_MIME),
|
DragSurface::Toplevel { handle: _, output } => (output, &*TOPLEVEL_MIME),
|
||||||
|
|
@ -506,9 +506,7 @@ impl Application for App {
|
||||||
vec![mime_type.to_string()],
|
vec![mime_type.to_string()],
|
||||||
DndAction::Move,
|
DndAction::Move,
|
||||||
*parent_id,
|
*parent_id,
|
||||||
Some((DndIcon::Custom(id), iced::Vector::ZERO)),
|
Some((DndIcon::Custom(id), offset * -1.0)),
|
||||||
// Applying offset doesn't seem quite right without transparency?
|
|
||||||
// Some((DndIcon::Custom(id), offset * -1.0)),
|
|
||||||
Box::new(WlDndId { mime_type }),
|
Box::new(WlDndId { mime_type }),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -676,7 +674,7 @@ impl Application for App {
|
||||||
DragSurface::Toplevel { handle, .. } => {
|
DragSurface::Toplevel { handle, .. } => {
|
||||||
if let Some(toplevel) = self.toplevels.iter().find(|x| &x.handle == handle)
|
if let Some(toplevel) = self.toplevels.iter().find(|x| &x.handle == handle)
|
||||||
{
|
{
|
||||||
let item = view::toplevel_preview(toplevel);
|
let item = view::toplevel_preview(toplevel, true);
|
||||||
return widget::container(item)
|
return widget::container(item)
|
||||||
.height(iced::Length::Fixed(size.height))
|
.height(iced::Length::Fixed(size.height))
|
||||||
.width(iced::Length::Fixed(size.width))
|
.width(iced::Length::Fixed(size.width))
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ pub(crate) fn workspace_item<'a>(
|
||||||
output: &wl_output::WlOutput,
|
output: &wl_output::WlOutput,
|
||||||
is_drop_target: bool,
|
is_drop_target: bool,
|
||||||
) -> cosmic::Element<'a, Msg> {
|
) -> cosmic::Element<'a, Msg> {
|
||||||
let image = capture_image(workspace.img_for_output.get(output));
|
let image = capture_image(workspace.img_for_output.get(output), 1.0);
|
||||||
let is_active = workspace.is_active;
|
let is_active = workspace.is_active;
|
||||||
column![
|
column![
|
||||||
// TODO editable name?
|
// TODO editable name?
|
||||||
|
|
@ -255,7 +255,10 @@ fn workspaces_sidebar<'a>(
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn toplevel_preview(toplevel: &Toplevel) -> cosmic::Element<Msg> {
|
pub(crate) fn toplevel_preview(
|
||||||
|
toplevel: &Toplevel,
|
||||||
|
is_being_dragged: bool,
|
||||||
|
) -> cosmic::Element<Msg> {
|
||||||
let label = widget::text(&toplevel.info.title);
|
let label = widget::text(&toplevel.info.title);
|
||||||
let label = if let Some(icon) = &toplevel.icon {
|
let label = if let Some(icon) = &toplevel.icon {
|
||||||
row![widget::icon(widget::icon::from_path(icon.clone())), label].spacing(4)
|
row![widget::icon(widget::icon::from_path(icon.clone())), label].spacing(4)
|
||||||
|
|
@ -263,10 +266,11 @@ pub(crate) fn toplevel_preview(toplevel: &Toplevel) -> cosmic::Element<Msg> {
|
||||||
row![label]
|
row![label]
|
||||||
}
|
}
|
||||||
.padding(4);
|
.padding(4);
|
||||||
|
let alpha = if is_being_dragged { 0.5 } else { 1.0 };
|
||||||
crate::widgets::toplevel_item(
|
crate::widgets::toplevel_item(
|
||||||
vec![
|
vec![
|
||||||
close_button(Msg::CloseToplevel(toplevel.handle.clone())),
|
close_button(Msg::CloseToplevel(toplevel.handle.clone())),
|
||||||
widget::button(capture_image(toplevel.img.as_ref()))
|
widget::button(capture_image(toplevel.img.as_ref(), alpha))
|
||||||
.selected(
|
.selected(
|
||||||
toplevel
|
toplevel
|
||||||
.info
|
.info
|
||||||
|
|
@ -295,7 +299,10 @@ fn toplevel_previews_entry<'a>(
|
||||||
) -> cosmic::Element<'a, Msg> {
|
) -> cosmic::Element<'a, Msg> {
|
||||||
// Dragged window still takes up space until moved, but isn't rendered while drag surface is
|
// Dragged window still takes up space until moved, but isn't rendered while drag surface is
|
||||||
// shown.
|
// shown.
|
||||||
let preview = crate::widgets::visibility_wrapper(toplevel_preview(toplevel), !is_being_dragged);
|
let preview = crate::widgets::visibility_wrapper(
|
||||||
|
toplevel_preview(toplevel, is_being_dragged),
|
||||||
|
!is_being_dragged,
|
||||||
|
);
|
||||||
iced::widget::dnd_source(preview)
|
iced::widget::dnd_source(preview)
|
||||||
.on_drag(|size, offset| {
|
.on_drag(|size, offset| {
|
||||||
Msg::StartDrag(
|
Msg::StartDrag(
|
||||||
|
|
@ -401,15 +408,18 @@ fn bg_element<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn capture_image(image: Option<&CaptureImage>) -> cosmic::Element<'_, Msg> {
|
fn capture_image(image: Option<&CaptureImage>, alpha: f32) -> cosmic::Element<'_, Msg> {
|
||||||
if let Some(image) = image {
|
if let Some(image) = image {
|
||||||
#[cfg(feature = "no-subsurfaces")]
|
#[cfg(feature = "no-subsurfaces")]
|
||||||
{
|
{
|
||||||
|
// TODO alpha
|
||||||
widget::Image::new(image.image.clone()).into()
|
widget::Image::new(image.image.clone()).into()
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "no-subsurfaces"))]
|
#[cfg(not(feature = "no-subsurfaces"))]
|
||||||
{
|
{
|
||||||
Subsurface::new(image.width, image.height, &image.wl_buffer).into()
|
Subsurface::new(image.width, image.height, &image.wl_buffer)
|
||||||
|
.alpha(alpha)
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
widget::Image::new(widget::image::Handle::from_pixels(1, 1, vec![0, 0, 0, 255])).into()
|
widget::Image::new(widget::image::Handle::from_pixels(1, 1, vec![0, 0, 0, 255])).into()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue