Bug 382604

Summary: Plasma must be restarted to for cursor size changes to take effect for the desktop and empty areas of the panel
Product: [Plasma] plasmashell Reporter: Patrick Silva <bugseforuns>
Component: generalAssignee: Plasma Bugs List <plasma-bugs>
Severity: normal CC: agurenko, Alydar715, aspotashev, bednarczyk.pawel, chermnykh2001, dashonwwIII, david.cortes.rivera, david.kahles96, ddascalescu+kde, foss, Fritz.Martin99, gabor, groot, inasprecali, kde, kde, kukububu, maker.ok.mo, nate, plasma-bugs, postix, rullger, tynach2, unassigned-bugs, yerimyah1
Priority: HI    
Version: master   
Target Milestone: 1.0   
Platform: Arch Linux   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=414109
Latest Commit: Version Fixed In: 6.0
Attachments: Cursors KCM on Wayland

Description Patrick Silva 2017-07-22 20:20:34 UTC
When I change my cursor theme, the previous cursor is still active in many parts of my system/programs.
Some menu bars and window decorations, for example, shows the previous cursor on mouseover until plasma session is restarted.

I use Plasma 5.10.4 on Arch.
Comment 1 Nate Graham 2019-08-01 17:06:52 UTC
Is this still happening?
Comment 2 Patrick Silva 2019-08-04 01:04:57 UTC
yes, it's still happening on X11. Wayland session requires relogin to apply a new cursor theme.
On X11 changing the cursor theme only takes effect immediately on plasma panel, widgets placed on panel/desktop, apps launcher and window decorations. 
If you hover over the files list of Dolphin or the text area of Kate, for example, you see the previous cursor until relogin.

Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.16.80
KDE Frameworks Version: 5.61.0
Qt Version: 5.12.3
Comment 3 Christoph Feck 2019-08-14 01:45:41 UTC
Information was provided with comment #2; changing status.
Comment 4 Patrick Silva 2019-10-29 22:22:42 UTC
Changing cursor size also is not immediately applied to the whole system.
I see the cursor of the previous size on mouseover my wallpaper until plasma session is restarted.

Operating System: Arch Linux 
KDE Plasma Version: 5.17.1
KDE Frameworks Version: 5.63.0
Qt Version: 5.13.2
Comment 5 Nate Graham 2020-01-11 19:32:04 UTC
Looks like restarting just KWin is enough actually. Moving to KWin.
Comment 6 Nate Graham 2020-01-11 19:32:21 UTC
*** Bug 371059 has been marked as a duplicate of this bug. ***
Comment 7 Nate Graham 2020-01-13 05:40:38 UTC
*** Bug 347471 has been marked as a duplicate of this bug. ***
Comment 8 Martin Fritz 2020-01-20 13:19:07 UTC
For me changing cursors only affects applications running while it is changed.
Newly started applications use the old cursor theme. kcminputrc shows the new cursor theme though
Comment 9 Martin Fritz 2020-01-20 13:19:29 UTC
For me changing cursors only affects applications running while it is changed.
Newly started applications use the old cursor theme. kcminputrc shows the new cursor theme though
Comment 10 Nate Graham 2020-01-21 16:52:52 UTC
*** Bug 414109 has been marked as a duplicate of this bug. ***
Comment 11 Patrick Silva 2020-02-02 12:52:02 UTC
Created attachment 125613 [details]
Cursors KCM on Wayland

Watch the following screen recording please.

I change from red cursor theme to the yellow one.
Cursor is still in red when I hover over the following areas:
- wallpaper
- the header of Cursors kcm
- "hard disk i/o monitor", "network monitor" and "thermal monitor" widgets
- any part of "weather report" and "hard disk space usage" widgets but their blue bars

Then I restart kwin and the cursor becomes correct (yellow) when I hover over the areas mentioned above.

But newly started apps Dolphin and Kinfocenter are still showing the previous red cursor when I hover over any part of them but their window decoration.

As we can see in my screen recording, restart kwin is not enough.
Relogin is the only way to apply another cursor theme to the whole system on X11.

If it's hard to solve this ancient and annoying bug, I think that Cursor kcm could definitely stop trying to apply the cursor theme without relogin and adopt the same behavior that already occurs on Wayland. On Wayland, Cursors kcm shows a warning saying that relogin is required for the cursor theme change to take effect, as we can see in the attached screenshot.

Operating System: Arch Linux 
KDE Plasma Version: 5.17.90
KDE Frameworks Version: 5.66.0
Qt Version: 5.14.1
Comment 12 inasprecali 2020-03-04 19:40:00 UTC
I can confirm the same bug on the same Plasma version.
This workaround: https://wiki.archlinux.org/index.php/KDE#Plasma_cursor_sometimes_shown_incorrectly solves the problem for me, but it's that, a workaround. An end user shouldn't be expected to do this.
Comment 13 Nate Graham 2020-06-19 00:33:43 UTC
*** Bug 423074 has been marked as a duplicate of this bug. ***
Comment 14 Nate Graham 2020-07-17 14:39:42 UTC
Can still reproduce. The Plasma desktop, panel, and applets seem to not notice the new cursor until plasmashell is restarted.
Comment 15 Patrick Silva 2020-08-17 14:12:03 UTC
*** Bug 425451 has been marked as a duplicate of this bug. ***
Comment 16 Nate Graham 2020-09-09 03:37:18 UTC
*** Bug 404383 has been marked as a duplicate of this bug. ***
Comment 17 Colin Griffith 2020-10-08 21:00:32 UTC
I think I figured out what causes this!

According to wbauer on this page:

The 'startkde' (which is now 'startplasma-x11' or 'startplasma-wayland') program sets the XCURSOR_THEME environment variable, and applications will always use the value of that environment variable until they're told otherwise. When you switch themes while logged in, you're telling existing applications to use another theme on the fly, and most will do so! But launch a new application, and it'll use the old original theme!

The XCURSOR_THEME environment variable is meant to be used to override all other settings temporarily, when starting an application. The fix should simply be to remove the line(s) of code from 'startplasma-x11' that sets that environment variable.
Comment 18 Colin Griffith 2020-10-08 23:07:21 UTC
It looks like the code was ported to C++ from a bash script. The relevant code is here:

This was done in this commit:

And the code was just copied mostly without changing what it actually did, which is why the behavior didn't only start happening in 2019.

For that, I had to dig REALLY far back... And eventually found this in the old SVN repository:

And in particular, here:

Way back on March 10th, 2005. It looks like the reason the environment variable was set back then was for kded and ksmserver.

Is this still the case today? It seems like code that old working around problems in other packages (albeit other KDE packages) might not even be relevant anymore, and so safe to pull out.

Additionally, I don't have KDE's source code installed on my drive, so I can't actually try changing this, compiling, and testing... Hence just talking on this bug report instead. It could be that this isn't at all related to the bug we're experiencing, and I just went on a wild goose chase for nothing.

Still, it would explain the current behavior for the most part.
Comment 19 Nate Graham 2020-10-29 19:53:58 UTC
Interesting observations, Colin.

Please feel free to try compiling and testing your proposed fix. You don't need all KDE repos, just plasma-workspace. Here's the documentation: https://community.kde.org/Get_Involved/development
Comment 20 Nate Graham 2020-12-03 20:59:39 UTC
*** Bug 429947 has been marked as a duplicate of this bug. ***
Comment 21 Nate Graham 2021-04-13 17:42:52 UTC
Can still reproduce for the desktop and empty areas of the panel too--though not actual panel applets, interestingly enough. Since restarting plasmashell seems to fix it, this appears to be a matter of the panel and desktop only checking for cursor size on launch, not watching for size changes in real time.
Comment 22 Nate Graham 2021-04-13 17:43:38 UTC
*** Bug 435682 has been marked as a duplicate of this bug. ***
Comment 23 Nate Graham 2021-08-03 04:11:46 UTC
*** Bug 439126 has been marked as a duplicate of this bug. ***
Comment 24 Nate Graham 2021-08-04 22:24:06 UTC
*** Bug 439439 has been marked as a duplicate of this bug. ***
Comment 25 groot 2022-02-22 13:19:10 UTC
How to reproduce on X11:
- log in to KDE Plasma (I happen to have 5.23.5 with Frameworks 5.90)
- alt-space, type "cursor", pick from the "System Settings" category "Cursors"
- click on, say, "Oxygen Blue" and then from the size drop-down, pick 48.
- click "Apply"
- mouse cursor is now big and blue over every application window, but not the background wallpaper. Cursor is also big and blue over **nearly** all of the Plasma panel, but there's a strip about 2px tall (I have a vertically-arranged panel) between the system-tray part and the clock. Perhaps that is an "empty area" on the panel and the rest of my panel is occupied with "things".

There's a much simpler way to reproduce, though, using the `plasma-apply-cursortheme` executable (I don't know if that is installed everywhere though),

- `plasma-apply-cursortheme  redglass` (applies redglass, notice that everything gets it except the wallpaper and bits of the panel)
- `plasma-apply-cursortheme breeze_cursors` (applies the standard Breeze theme)
Comment 26 groot 2022-02-22 14:24:21 UTC
Related MR (it adds some things to the CLI tool, doesn't fix any of the actual issues): https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/1483

Workaround to get plasma to set new cursors on the wallpaper (but not on the "occupied" areas of the panel, which now get a plain cursor not related to any of my recent cursor-theme-selections):
 - `plasma-apply-cursortheme redglass`
 - `qdbus org.kde.plasmashell /PlasmaShell refreshCurrentShell`
This is a very "heavyweight" way to tell Plasma to reload things.

Related to XCURSOR_THEME: if I alt-space "xterm" to run Xterm, it has XCURSOR_THEME set to "KDE_Classic", which was true when I logged in.  The CLI tool creates a `UpdateLaunchEnvJob` which is documented to update the launch environment, but doesn't seem to do anything.
Comment 27 groot 2022-02-22 17:10:05 UTC
Experimenting with environment variable XCURSOR_THEME.

- Log into KDE Plasma, start Konsole
- `echo $XCURSOR_THEME` shows me `KDE_Classic` (which was my cursor theme when I started)
- From that konsole, `konsole &` and in that (new) konsole, `echo $XCURSOR_THEME` shows `KDE_Classic` (this is expected, environment passed on from the shell in konsole). Notice that mousing over the new konsole shows the KDE Classic cursor theme.
- From that konsole, `XCURSOR_THEME=redglass konsole &` and in that konsole notice it shows redglass. Together this shows that starting Konsole from the command-line makes it obey the XCURSOR_THEME environment variable.
- Use dbus to get KLauncher to launch a new konsole: `qdbus-qt5 org.kde.klauncher5 /KLauncher exec_blind konsole ""` .. notice that Konsole has XCURSOR_THEME set to `KDE_Classic` (because that's what I had when I logged in)
- Use dbus to tell Klauncher to use a different environment: `qdbus-qt5 org.kde.klauncher5 /KLauncher setLaunchEnv XCURSOR_THEME Oxygen_Yellow`
- Then use dbus to launch a new konsole again (same command) and notice it comes up with Oxygen Yellow as cursor theme and has XCURSOR_THEME set as expected.
- Then use KRunner to start Konsole, e.g. alt-space, type "konsole". Notice it has KDE_Classic.
- Then use the K-Menu to start Konsole. It too has KDE_Classic.

So far, we've seen that Konsole follows the XCURSOR_THEME set in the environment when it is started. Also that KLauncher can modify the environment it uses to launch applications. Also that KRunner is not KLauncher, and uses some **other** notion of environment. (This can be similarly demonstrated by starting kwrite, changing the theme, then starting another kwrite which gets the old theme).
Comment 28 Nate Graham 2022-08-12 18:52:54 UTC
*** Bug 457771 has been marked as a duplicate of this bug. ***
Comment 29 Adrian 2022-09-21 14:01:01 UTC
For some time (2 weeks maybe, I'm not sure) I face similar issue. Sometimes displayed cursor is not the one I set in system settings. It happens in a few places:
- when I put mouse cursor on screen edge that has action defined,
- when I right click in Firefox,
- when I middle click in Firefox,
those are just from the top of my head.

It is not related to cursor theme change. I tried to change theme and it is stable until next start of plasma. After restart problem returns. It happens for both KDE-installed themes and 3rd parties.
Workaround from https://wiki.archlinux.org/index.php/KDE#Plasma_cursor_sometimes_shown_incorrectly helps.

If you consider this a separate bug just let me know and I'll create a new report.

I use fully updated Arch Linux which means plasma 5.25.5.
Comment 30 Bug Janitor Service 2023-02-25 08:01:52 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2671
Comment 31 Bug Janitor Service 2023-02-25 09:48:45 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2672
Comment 32 Nate Graham 2023-09-19 16:59:11 UTC
Still an issue in Plasma 6.
Comment 33 Nate Graham 2023-12-14 21:29:14 UTC
As of today's git master in Plasma 6, I can confirm that this is now fixed!