Bug 470147 - Symlinked Folders: Cut elements are not desaturated anymore
Summary: Symlinked Folders: Cut elements are not desaturated anymore
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: panels: folders (show other bugs)
Version: 23.04.1
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-22 23:53 UTC by Henning
Modified: 2023-12-15 14:01 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Henning 2023-05-22 23:53:05 UTC
It seems a recent update brokw the display of cut elements. They are not visually distinct from other elements, while they should have reduced saturation.


Specified App:
dolphin-23.04.1-1.fc38.x86_64

--- Software ---
OS: Fedora Linux 38.20230522.0 (Kinoite)
KDE Plasma: 5.27.5
KDE Frameworks: 5.106.0
Qt: 5.15.9
Kernel: 6.2.15-300.fc38.x86_64
Compositor: wayland
Comment 1 Henning 2023-05-23 01:15:25 UTC
reproduce: select some elements, Cut (Ctrl+X) and click somewhere to remove the blue selection.

What happens: you cant see they are cut.
Comment 2 Henning 2023-06-10 14:24:30 UTC
This occurs on files but not on folders, folders are normally desaturated

Specified App:
dolphin-libs-23.04.1-1.fc38.x86_64
dolphin-plugins-23.04.1-1.fc38.x86_64
dolphin-23.04.1-1.fc38.x86_64
--- Software ---
OS: Fedora Linux 38.20230609.0 (Kinoite)
KDE Plasma: 5.27.5
KDE Frameworks: 5.106.0
Qt: 5.15.9
Kernel: 6.3.5-200.fc38.x86_64
Compositor: wayland
Comment 3 Henning 2023-06-10 14:25:22 UTC
tested on filetype .txt, .jpg
Comment 4 Jin Liu 2023-06-13 13:15:43 UTC
In my case this problem only happens inside symlinked dirs. Normal dirs seem ok.
Comment 5 Jin Liu 2023-06-13 13:17:48 UTC
And they don't desaturate when I press cut, when the blue selection is on.
Comment 6 Henning 2023-06-24 19:05:37 UTC
@Jin Liu true! This only happens in folders that are entirely symlinked. Not in folders that contain symlinks, the symlinks themselves are desaturated.
Comment 7 Jin Liu 2023-08-07 08:21:13 UTC
I've found the cause of this bug:

Dolphin (in KFileItemClipboard) uses KUrlMimeData::urlsFromMimeData to get the list of cut files from the clipboard.
(https://invent.kde.org/system/dolphin/-/blob/master/src/kitemviews/private/kfileitemclipboard.cpp#L55)

That method was modified about 1 year ago to get the list from xdg-portal.FileTransfer, instead of directly from the clipboard.
(https://invent.kde.org/frameworks/kcoreaddons/-/blob/master/src/lib/io/kurlmimedata.cpp#L149)

And the FileTransfer portal, which operates on fds, not paths, obviously can't preserve the original (symlinked) path. So when you cut some files inside a symlinked dir, while the text/uri-list and application/x-kde4-urilist types in the clipboard contain the correct path, what you get from the FileTransfer portal are canonical paths inside the target dir. Therefore, files in the symlinked dir are not shown as cut (desaturated). But if you go to the target dir, files there are desaturated.

So there are 3 ways to fix this:

1. When checking for cut files, Dolphin can resolve both the current dir and paths from the clipboard to their canonical form. This could be slow, and unnecessary (reasoning below).

2. Instead of KUrlMimeData::urlsFromMimeData, KFileItemClipboard can call some new method that doesn't use xdg-portal, but read the application/x-kde4-urilist type from the clipboard directly. I don't think there's requirement that files cut in Dolphin inside a sandbox shall be shown as cut in another Dolphin outside the sandbox, so it's really unnecessary to call xdg-portal here.

3. Better, Dolphin can set some marker in the clipboard item when cutting files, so when pasting/checking in the same Dolphin process (or in the same sandbox), KUrlMimeData::urlsFromMimeData sees this marker and uses the clipboard item directly, not calling xdg-portal. That would fix this and other xdg-portal related bugs (e.g. https://bugs.kde.org/show_bug.cgi?id=464225) once for all, when not actually doing cross-application cut&paste.
Comment 8 Jin Liu 2023-08-07 09:02:16 UTC
After all, the purpose of the FileTransfer portal is "for transferring files between apps". Probably it's not intended for a file manager to use the FileTransfer portal to manage the clipboard internally. The portal always resolves symlinks, probably because that's just what "transferring files between apps" need. Thus Dolphin should only use the portal when cut&paste from/to another application, not itself.
Comment 9 Bug Janitor Service 2023-08-07 09:51:36 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kcoreaddons/-/merge_requests/364
Comment 10 Bug Janitor Service 2023-08-09 08:45:16 UTC
A possibly relevant merge request was started @ https://invent.kde.org/system/dolphin/-/merge_requests/586
Comment 11 Bug Janitor Service 2023-12-14 11:05:34 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kcoreaddons/-/merge_requests/408
Comment 12 Harald Sitter 2023-12-15 14:01:12 UTC
Git commit ab55eb6e9eb54d2982b026db40cec9c218a043be by Harald Sitter, on behalf of Jin Liu.
Committed on 15/12/2023 at 15:01.
Pushed by sitter into branch 'master'.

KUrlMimeData: don't use xdg-portal when copy&paste in the same process

There's no need to use the FileTransfer portal when the sender and receiver process are the same process

When copying, sets application/x-kde-source-id in the mime to the app's dbus unique connection name. When pasting, compares the source id against the current process, and skips the portal if they match.

Some previously internal functions are exported in kurlmimedata_p.h for use in unittests.

M  +34   -0    autotests/kurlmimedatatest.cpp
M  +4    -0    autotests/kurlmimedatatest.h
M  +26   -2    src/lib/io/kurlmimedata.cpp
A  +19   -0    src/lib/io/kurlmimedata_p.h     [License: LGPL(v2.0+)]

https://invent.kde.org/frameworks/kcoreaddons/-/commit/ab55eb6e9eb54d2982b026db40cec9c218a043be