Bug 482185 - Context menu (when right-clicking on the desktop) appears in a separate window after external monitor restart
Summary: Context menu (when right-clicking on the desktop) appears in a separate windo...
Status: RESOLVED DUPLICATE of bug 481933
Alias: None
Product: plasmashell
Classification: Plasma
Component: Panel (show other bugs)
Version: 6.0.4
Platform: NixOS Linux
: NOR minor
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: multiscreen, qt6, wayland
Depends on:
Blocks:
 
Reported: 2024-03-01 18:15 UTC by Naxdy
Modified: 2024-05-16 22:29 UTC (History)
14 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Context menu shown as a window (981.70 KB, image/png)
2024-03-11 16:22 UTC, Ye Jingchen
Details
Context menu window (209.33 KB, image/png)
2024-04-24 16:11 UTC, Sjoerd
Details
Demo screen recording for my code in comment 16. (217.10 KB, video/webm)
2024-05-14 20:13 UTC, Sin Jeong-hun
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Naxdy 2024-03-01 18:15:21 UTC
SUMMARY
I have a panel at the bottom set to auto-hide that only contains an icons-only task manager, and a panel at the top that contains a bunch of widgets. Just now, I've noticed that right-clicking the top panel (doesn't matter if on empty space, or on a widget) causes the context menu to appear in a separate wayland window at the center of the screen. This does not happen for the bottom panel.

Not sure how to reliably reproduce this yet, I will update this report with more info as I uncover it. However, I felt it pertinent to make the initial report in case someone else has more info on this. I'm immediately setting this to NEEDSMOREINFO for this reason.


STEPS TO REPRODUCE
Unclear :(


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: NixOS
(available in About System)
KDE Plasma Version: 6.0.0
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2

ADDITIONAL INFORMATION
-
Comment 1 Naxdy 2024-03-01 18:15:55 UTC
Not sure how to reliably reproduce this yet, I will update this report with more info as I uncover it. However, I felt it pertinent to make the initial report in case someone else has more info on this. I'm immediately setting this to NEEDSMOREINFO for this reason.
Comment 2 Naxdy 2024-03-02 10:13:24 UTC
Found the cause of the bug, it happens when the monitor is turned off! As such, here are the steps to reproduce:

STEPS TO REPRODUCE
0. Confirm right-click context menu is working correctly, by focusing a window, then right clicking on the desktop.
1. Lock your session and turn off your monitor with ESC. Wait ~10 seconds.
2. Log back in to your session
3. Focus a window and right-click the on the desktop.

OBSERVED RESULT
The context menu opens in a separate Wayland window

EXPECTED RESULT
The context menu opens at the mouse cursor, not in a separate window

ADDITIONAL INFORMATION
A `plasmashell --replace` fixes the issue until the next time the monitor turns off. This is on a single-monitor setup FYI.
Comment 3 Nate Graham 2024-03-05 22:56:59 UTC
Hmm, cannot reproduce with those steps with my setup (Plasma 6 built from source on top of Fedora 29). I wonder if this is in any way related to Bug 482076.
Comment 4 Naxdy 2024-03-05 23:09:00 UTC
As discussed on Matrix, this issue seems to require an external monitor (=the sole monitor?) to power off fully (=become disconnected)
Comment 5 Ye Jingchen 2024-03-11 16:20:31 UTC
Can confirm. This happens when using external monitor as the only screen, and when the screen powers off during lock screen.

STEPS TO REPRODUCE

1. Connect laptop to external monitor and disable internal screen in display settings.
2. Add a panel to the top of the screen. Bottom, left and right panel don't trigger this.
3. Check that context menu on panels and desktop is working when focused on a window.
4. Win+L to lock screen.
5. Press the power button to turn off the external monitor. Note that monitor's sleep feature might not be able to trigger this consistently.
6. Power on external monitor.
7. Unlock, focus a window, and try right clicking on panels and desktops.

OBSERVED RESULT

Right clicking on top panel or the desktop when a window is focused will bring the context menu as a small window titled `plasmashell`. Running `systemctl --user restart plasma-plasmashell.service` will reset to normal behavior, until next time external monitor is powered off during lock screen.
Comment 6 Ye Jingchen 2024-03-11 16:22:03 UTC
Created attachment 166966 [details]
Context menu shown as a window
Comment 7 Ye Jingchen 2024-03-11 16:43:53 UTC
Might not be related, but the last "unlock" step comes with an additional lock screen with only a "Unlock" button, after the normal password unlock screen.
Comment 8 revinary 2024-03-15 16:09:55 UTC
I experience this bug as well under Plasma 6.0.2 and Qt 6.6.2 on Arch Linux.

Regular panel (vertical, not floating, no auto-hide) containing "Application Menu", "Icon-Only Task Manager", "System Tray" and "Digital Clock".
Context menus of the task and tray icons work correctly.
Context menus of the app menu, task manager and clock show as top-level windows in the middle of the screen.

When the Application Menu is open the button's context menu works correclty.

In my case there is no screen (un)locking involved.
Simply power cycling my DP monitor does not trigger the bug, either.
In addition, after the power cycle I need to open a context menu in another application first (Vivaldi in my case, menu shows correctly) and then the bug manifests for plasmashell context menus.
Comment 9 Ye Jingchen 2024-03-16 02:30:43 UTC
(In reply to revinary from comment #8)
> I experience this bug as well under Plasma 6.0.2 and Qt 6.6.2 on Arch Linux.
> 
> Regular panel (vertical, not floating, no auto-hide) containing "Application
> Menu", "Icon-Only Task Manager", "System Tray" and "Digital Clock".
> Context menus of the task and tray icons work correctly.
> Context menus of the app menu, task manager and clock show as top-level
> windows in the middle of the screen.
> 
> When the Application Menu is open the button's context menu works correclty.
In my experience, a window need to be focused to trigger this bug. Opening application window changes the focus to application menu itself, thus bypassing the issue.
> 
> In my case there is no screen (un)locking involved.
> Simply power cycling my DP monitor does not trigger the bug, either.
> In addition, after the power cycle I need to open a context menu in another
> application first (Vivaldi in my case, menu shows correctly) and then the
> bug manifests for plasmashell context menus.
Comment 10 ivan 2024-03-16 10:42:04 UTC
Using Neon and Wayland, can confirm this issue. I'm on a desktop workstation with a single DP monitor and as soon as it gets powered off by either power saving rules or a suspend action, when the monitor turns on, the right client context menu on desktop gets rendered in a window at the center of the screen if another window is in focus. A plasmashell restart fixes it temporarly, until the screen goes off again.
Comment 11 antroids 2024-04-24 08:19:37 UTC
I have the same issue on my laptop after several sleep-wakes or external/internal monitor switches.

> Operating System: KDE neon 6.0
> KDE Plasma Version: 6.0.4
> KDE Frameworks Version: 6.1.0
> Qt Version: 6.7.0
> Kernel Version: 6.5.0-28-generic (64-bit)
> Graphics Platform: Wayland
> Processors: 12 × AMD Ryzen 5 PRO 4650U with Radeon Graphics
> Memory: 14.8 GiB of RAM
> Graphics Processor: AMD Radeon Graphics
> Manufacturer: LENOVO
> Product Name: 20UH001JRT
> System Version: ThinkPad T14s Gen 1
Comment 12 ivan 2024-04-24 08:21:48 UTC
Issue is still present in 6.0.4 on Kde Neon running on amd cpu and gpu.
Comment 13 Sjoerd 2024-04-24 16:11:15 UTC
Created attachment 168872 [details]
Context menu window

Happens for me as well with Tumbleweed and Plasma 6.0.4 on Wayland.

When I have a window focused, and right click on the desktop, the context menu opens in a window. If I then click again, with no window focused, it opens normally.

And the same happens for the right click menu of the taskbar, see attachted picture. Also only when a different window is focused.
Comment 14 adrian 2024-05-04 16:53:05 UTC
I have a single DP monitor, but for me this issue appeared after I plugged in a dummy HDMI dongle to my PC to act as a virtual display for game streaming. Fedora 40, Plasma 6.0.4 on Wayland.
Comment 15 Boctor 2024-05-10 04:02:51 UTC
Using a Plasma 6.0.4 Wayland session on Arch, I encounter this issue on a desktop computer with only one display (DP) ever being used. However, I regularly suspend, so this display is likely being reconnected during resume. I also see the extra "Unlock" button after confirming my password in the screen locker, as described in comment number 7.
Comment 16 Sin Jeong-hun 2024-05-14 20:08:11 UTC
This problem is not because of external/dual monitors. This happens when the context menu has no parent and you right click the widget when its parent window is not focused. I know this because I recently wrote a simple PySide6 myself and had this exact same problem, and after spending a lot of time, I discovered the reason.

 So, this problem can be reproduced in the say way in Plasma desktop. Open any window (not maximised) and click to focus that window. Then, directly right-click the desktop. Since the desktop (desktop context menu's parent) is not focused, it's opened as a pop-up. This also happens with the Up arrow in the notification area that shows hidden items.

Below is a simple code to demonstrate this problem. Right-click both text boxes when the window is NOT focused (i.e. click some other window).

    from PySide6.QtGui import QAction, QIcon, Qt
    from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QTextEdit, QMenu
    
    class MainWindow(QMainWindow):
        def __init__(self):
            super().__init__()
            self.resize(600, 400)
    
            self.context_menu1 = QMenu()
            menu_item1 = QAction(QIcon.fromTheme("edit-copy"), "I have no parent", self)
            self.context_menu1.addAction(menu_item1)
    
            self.context_menu2 = QMenu(self)
            menu_item2 = QAction(QIcon.fromTheme("edit-copy"), "I have a parent", self)
            self.context_menu2.addAction(menu_item2)
    
            self.widget1 = QTextEdit()
            self.widget1.setText("Context menu NO parent")
            self.widget1.setContextMenuPolicy(Qt.CustomContextMenu)
            self.widget1.customContextMenuRequested.connect(self.show_custom_context_menu1)
    
            self.widget2 = QTextEdit()
            self.widget2.setText("Context menu WITH parent")
            self.widget2.setContextMenuPolicy(Qt.CustomContextMenu)
            self.widget2.customContextMenuRequested.connect(self.show_custom_context_menu2)
    
            layout = QVBoxLayout()
            layout.addWidget(self.widget1)
            layout.addWidget(self.widget2)
    
            self.central_widget = QWidget()
            self.central_widget.setLayout(layout)
            self.setCentralWidget(self.central_widget)
    
        def show_custom_context_menu1(self, point):
            self.context_menu1.popup(self.widget1.viewport().mapToGlobal(point))
    
        def show_custom_context_menu2(self, point):
            self.context_menu2.popup(self.widget2.viewport().mapToGlobal(point))
    
    app = QApplication([])
    win = MainWindow()
    win.show()
    app.exec()
Comment 17 Sin Jeong-hun 2024-05-14 20:13:04 UTC
Created attachment 169483 [details]
Demo screen recording for my code in comment 16.

When the window is not focused, I right-clicked on the two text boxes.
Comment 18 Nate Graham 2024-05-16 22:29:36 UTC

*** This bug has been marked as a duplicate of bug 481933 ***