fix(app-tray): reorder app tray elements with DnD shouldn't create extra items
This commit is contained in:
parent
e50aa334f3
commit
b4b4657122
2 changed files with 31 additions and 27 deletions
41
Cargo.lock
generated
41
Cargo.lock
generated
|
|
@ -1402,7 +1402,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-config"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"atomicwrites",
|
||||
"cosmic-config-derive",
|
||||
|
|
@ -1424,7 +1424,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-config-derive"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
|
|
@ -1502,7 +1502,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-panel-config"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/cosmic-panel#af73ac840b72cfe760c4b6e3747fc19d611367e1"
|
||||
source = "git+https://github.com/pop-os/cosmic-panel#36a8e558ea326383821bf50f2bbc5f45c9f41aff"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cosmic-config",
|
||||
|
|
@ -1566,7 +1566,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-text"
|
||||
version = "0.14.2"
|
||||
source = "git+https://github.com/pop-os/cosmic-text.git#b017d7c856aed4b1a3ef0952df75d02d889a1f7b"
|
||||
source = "git+https://github.com/pop-os/cosmic-text.git#987ff45ff20f3cee1322e2f2909ac4c2c26f8321"
|
||||
dependencies = [
|
||||
"bitflags 2.9.0",
|
||||
"fontdb 0.23.0",
|
||||
|
|
@ -1588,7 +1588,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-theme"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"almost",
|
||||
"cosmic-config",
|
||||
|
|
@ -1660,9 +1660,9 @@ checksum = "42aaeae719fd78ce501d77c6cdf01f7e96f26bcd5617a4903a1c2b97e388543a"
|
|||
|
||||
[[package]]
|
||||
name = "csscolorparser"
|
||||
version = "0.7.0"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46f9a16a848a7fb95dd47ce387ac1ee9a6df879ba784b815537fcd388a1a8288"
|
||||
checksum = "148247664b27bf6bf5041b46cf1e8c4872f70e75e3281348deb88abd75c915ab"
|
||||
dependencies = [
|
||||
"phf",
|
||||
"serde",
|
||||
|
|
@ -2918,7 +2918,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"dnd",
|
||||
"iced_accessibility",
|
||||
|
|
@ -2936,7 +2936,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_accessibility"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"accesskit_winit",
|
||||
|
|
@ -2945,7 +2945,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_core"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"bitflags 2.9.0",
|
||||
"bytes",
|
||||
|
|
@ -2969,7 +2969,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_futures"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"iced_core",
|
||||
|
|
@ -2995,7 +2995,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_graphics"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"bitflags 2.9.0",
|
||||
"bytemuck",
|
||||
|
|
@ -3017,7 +3017,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_renderer"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"iced_graphics",
|
||||
"iced_tiny_skia",
|
||||
|
|
@ -3029,7 +3029,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_runtime"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"cosmic-client-toolkit",
|
||||
|
|
@ -3044,7 +3044,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_tiny_skia"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"cosmic-text",
|
||||
|
|
@ -3060,7 +3060,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_wgpu"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"as-raw-xcb-connection",
|
||||
"bitflags 2.9.0",
|
||||
|
|
@ -3091,12 +3091,13 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_widget"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"cosmic-client-toolkit",
|
||||
"dnd",
|
||||
"iced_renderer",
|
||||
"iced_runtime",
|
||||
"log",
|
||||
"num-traits",
|
||||
"once_cell",
|
||||
"ouroboros",
|
||||
|
|
@ -3109,7 +3110,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_winit"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"cosmic-client-toolkit",
|
||||
"dnd",
|
||||
|
|
@ -3835,7 +3836,7 @@ checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
|
|||
[[package]]
|
||||
name = "libcosmic"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7151638f519941d8439ad0ee05723c39ed561941"
|
||||
source = "git+https://github.com/pop-os/libcosmic#ce56237ab9ea2aa7777656a32c9c28e2a38fc6c7"
|
||||
dependencies = [
|
||||
"apply",
|
||||
"ashpd 0.9.2",
|
||||
|
|
@ -7476,7 +7477,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "xdg-shell-wrapper-config"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/cosmic-panel#af73ac840b72cfe760c4b6e3747fc19d611367e1"
|
||||
source = "git+https://github.com/pop-os/cosmic-panel#36a8e558ea326383821bf50f2bbc5f45c9f41aff"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"wayland-protocols-wlr",
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ use cctk::{
|
|||
workspace::v1::client::ext_workspace_handle_v1::ExtWorkspaceHandleV1,
|
||||
},
|
||||
};
|
||||
use cosmic::desktop::fde;
|
||||
use cosmic::desktop::fde::{get_languages_from_env, DesktopEntry};
|
||||
use cosmic::{
|
||||
app,
|
||||
|
|
@ -50,6 +49,7 @@ use cosmic::{
|
|||
},
|
||||
Apply, Element, Task,
|
||||
};
|
||||
use cosmic::{desktop::fde, widget};
|
||||
use cosmic_app_list_config::{AppListConfig, APP_ID};
|
||||
use cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1::State;
|
||||
use futures::future::pending;
|
||||
|
|
@ -76,6 +76,8 @@ struct AppletIconData {
|
|||
padding: Padding,
|
||||
}
|
||||
|
||||
static DND_FAVORITES: u64 = u64::MAX;
|
||||
|
||||
impl AppletIconData {
|
||||
fn new(applet: &Context) -> Self {
|
||||
let icon_size = applet.suggested_size(false).0;
|
||||
|
|
@ -364,7 +366,7 @@ enum Message {
|
|||
StartDrag(u32),
|
||||
DragFinished,
|
||||
DndEnter(f64, f64),
|
||||
DndExit,
|
||||
DndLeave,
|
||||
DndMotion(f64, f64),
|
||||
DndDropFinished,
|
||||
DndData(Option<DndPathBuf>),
|
||||
|
|
@ -962,8 +964,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
o.preview_index = index;
|
||||
}
|
||||
}
|
||||
Message::DndExit => {
|
||||
// remove the preview and restore to original list
|
||||
Message::DndLeave => {
|
||||
let mut cnt = 0;
|
||||
if let Some((_, ref toplevel_group, _, pinned_pos)) = self.dnd_source.as_ref() {
|
||||
let mut pos = 0;
|
||||
|
|
@ -1676,7 +1677,8 @@ impl cosmic::Application for CosmicAppList {
|
|||
DndDestination::for_data::<DndPathBuf>(
|
||||
row(favorites).spacing(app_icon.icon_spacing),
|
||||
|_, _| Message::DndDropFinished,
|
||||
),
|
||||
)
|
||||
.drag_id(DND_FAVORITES.clone()),
|
||||
row(active).spacing(app_icon.icon_spacing).into(),
|
||||
container(vertical_rule(1))
|
||||
.height(Length::Fill)
|
||||
|
|
@ -1690,7 +1692,8 @@ impl cosmic::Application for CosmicAppList {
|
|||
DndDestination::for_data(
|
||||
column(favorites).spacing(app_icon.icon_spacing),
|
||||
|_data: Option<DndPathBuf>, _| Message::DndDropFinished,
|
||||
),
|
||||
)
|
||||
.drag_id(DND_FAVORITES.clone()),
|
||||
column(active).spacing(app_icon.icon_spacing).into(),
|
||||
container(divider::horizontal::default())
|
||||
.width(Length::Fill)
|
||||
|
|
@ -1702,7 +1705,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
let favorites = favorites
|
||||
.on_enter(|x, y, _| Message::DndEnter(x, y))
|
||||
.on_motion(Message::DndMotion)
|
||||
.on_leave(|| Message::DndExit);
|
||||
.on_leave(|| Message::DndLeave);
|
||||
|
||||
let show_pinned =
|
||||
!self.pinned_list.is_empty() || self.dnd_offer.is_some() || self.is_listening_for_dnd;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue