Bug 499936 - Clicking on Trash widget fails to bring Dolphin forward if it was already open
Summary: Clicking on Trash widget fails to bring Dolphin forward if it was already open
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Trash widget (other bugs)
Version First Reported In: 6.2.5
Platform: Other Linux
: NOR minor
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: wayland-only
Depends on:
Blocks: 460318
  Show dependency treegraph
 
Reported: 2025-02-12 23:28 UTC by Nate Graham
Modified: 2025-04-22 14:50 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.4.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nate Graham 2025-02-12 23:28:03 UTC
STEPS TO REPRODUCE
1. Add a Trash widget to a panel
2. Open Dolphin
3. Click on the Trash widget


OBSERVED RESULT
The Dolphin window opens trash:/ in a new tab, but the window does not come forward.


SOFTWARE/OS VERSIONS
Git master everything on top of Fedora KDE 41 with Qt 6.8.2 


ADDITIONAL INFORMATION
Somehow it only affects the Trash widget. Clicking on it simply runs:

> Plasmoid.onActivated: Qt.openUrlExternally("trash:/")

However Qt.openUrlExternally() works as expected to raise Dolphin when invoked from a little test program:

import QtQuick
import QtQuick.Controls as QQC

Item {
    width: 300
    height: 300

    QQC.Button {
        anchors.centerIn: parent

        text: "Open Trash"
        icon.name: "user-trash-symbolic"
        onClicked: {
            Qt.openUrlExternally("trash:/")
        }
    }
}

And Qt.openUrlExternally() raises dolphin when invoked from the slideshow wallpaper config UI, where added folders display "Open folder…" buttons. So somehow, the issue seems to be specific to just the Trash widget!
Comment 1 Nicolas Fella 2025-02-13 00:05:24 UTC
Problem is this line: https://invent.kde.org/qt/qt/qtbase/-/blob/dev/src/gui/platform/unix/qdesktopunixservices.cpp#L446

QWindow *window = qGuiApp->focusWindow();

focusWindow() is null, presumably because plasmashell isn't your average application. And without a window we can't get a token
Comment 2 Nate Graham 2025-02-13 03:11:36 UTC
Fascinating. I guess it works from a widget's FullRepresentation because that's technically a window, right?
Comment 3 Bug Janitor Service 2025-04-22 13:48:22 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/2957
Comment 4 Kai Uwe Broulik 2025-04-22 14:09:37 UTC
Git commit a2ed9f88c16a8b8be504c1a0b9c7a93b8b65415f by Kai Uwe Broulik.
Committed on 22/04/2025 at 13:46.
Pushed by broulik into branch 'master'.

applets/trash: Use KIO CommandLauncherJob to open trash

QDesktopServices::openUrl (through Qt.openUrlExternally) requests a
token from the focus window. When trash is clicked in a panel, the panel
doesn't have focus, resulting in no token being created.

KProcessRunner used by KIO CommandLauncherJob as a fallback takes
whatever first window in qApp making activation work.

While at it, also use KNotificationJobUiDelegate for proper error
reporting in case opening trash fails.

M  +1    -1    applets/trash/package/contents/ui/main.qml
M  +1    -0    applets/trash/plugin/CMakeLists.txt
M  +10   -0    applets/trash/plugin/trash.cpp
M  +1    -0    applets/trash/plugin/trash.h

https://invent.kde.org/plasma/plasma-desktop/-/commit/a2ed9f88c16a8b8be504c1a0b9c7a93b8b65415f