Bug 325763 - KWin::Cursor doesn't react to cursor theme changes
Summary: KWin::Cursor doesn't react to cursor theme changes
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: 4.11.2
Platform: openSUSE Linux
: NOR minor
Target Milestone: ---
Assignee: KWin default assignee
URL: https://git.reviewboard.kde.org/r/113...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-08 09:48 UTC by Wolfgang Bauer
Modified: 2015-01-14 12:56 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.2.0
Sentry Crash Report:
thomas.luebking: ReviewRequest+


Attachments
Output of qdbus org.kde.kwin /KWin supportInformation. (6.31 KB, text/plain)
2013-10-08 14:13 UTC, Wolfgang Bauer
Details
Screenshot showing the theme's cursors (138.19 KB, image/png)
2013-10-08 14:28 UTC, Wolfgang Bauer
Details
Screenshot showing wrong resize cursor after theme change (134.72 KB, image/png)
2013-10-09 06:50 UTC, Wolfgang Bauer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bauer 2013-10-08 09:48:52 UTC
I'm using the Crystal White mouse cursor theme on my system.
Since upgrading to KDE 4.11 (it was RC1 to be precise), the mouse cursor doesn't change it's shape anymore when I move a window.
When switching the theme to one of the Oxygen variants this works, but it doesn't work with any other theme I have installed.

Reproducible: Always

Steps to Reproduce:
1. Set a different mouse cursor theme than Oxygen in systemsettings
2. Click on a window's titlebar and move it

Actual Results:  
Mouse cursor stays the same while moving the window

Expected Results:  
Mouse cursor should change to the "move window" shape (normally arrows)

This is a regression in 4.11, this worked fine with the same themes up to 4.10.5.
It only happens with the "Window Move" shape, the other shapes (like "Window resize") work correctly.

Another glitch that may be related:
When I change the cursor theme in systemsettings and click on "Apply", the cursor theme changes immediately, but moving a window still shows the cursor from the previously selected theme (this also happens with the Oxygen themes). The other shapes work correctly though (window size f.e.).
After logging out and in again this "fixes" itself and shows the correct "move" cursor for the Oxygen themes and the standard (i.e. not changed to the "move window" shape) cursor for other themes.
Comment 1 Thomas Lübking 2013-10-08 10:00:18 UTC
please attach the output of "qdbus org.kde.kwin /KWin supportInformation"
Comment 2 Thomas Lübking 2013-10-08 12:38:17 UTC
Theme doesn't change because the KWin Cursor implementation does not hook onto KGlobalSettings::cursorChanged() to wipe the m_cursors hash.

This *might* cause the issue with the other themes not using the proper shape, but can't say (nor reproduce)
Can you try a patch?
Comment 3 Thomas Lübking 2013-10-08 13:03:25 UTC
*some* cursor themes do not apply the cross - some don't even have in the "kcmshell4 cursortheme" list (eg. i use neutral++ which like the oxygen themes shows the corss cursor - though it's more like a hand there ;-)

There's maybe an ambigious name convention / case sensitivity issue with those themes?

I also installed a "crystal xcursors" theme, but it doesn't show up in the theme list at all....

Altering the bug to what can be confirmed being a kwin issue.
Comment 4 Wolfgang Bauer 2013-10-08 14:13:52 UTC
Created attachment 82720 [details]
Output of qdbus org.kde.kwin /KWin supportInformation.
Comment 5 Wolfgang Bauer 2013-10-08 14:28:31 UTC
Created attachment 82721 [details]
Screenshot showing the theme's cursors

(In reply to comment #2)
> Theme doesn't change because the KWin Cursor implementation does not hook
> onto KGlobalSettings::cursorChanged() to wipe the m_cursors hash.
I think you misunderstood. The theme _does_ change, just not the "Cross" shape.
And the "Cross" shape doesn't work at all with themes other than Oxygen.
 
> This *might* cause the issue with the other themes not using the proper
> shape, but can't say (nor reproduce)
But all the other shapes work. It's just the "cross" cursor that doesn't work.

(In reply to comment #3)
> *some* cursor themes do not apply the cross - some don't even have in the
> "kcmshell4 cursortheme" list (eg. i use neutral++ which like the oxygen
> themes shows the corss cursor - though it's more like a hand there ;-)
> 
> There's maybe an ambigious name convention / case sensitivity issue with
> those themes?

The theme does contain it, see attached screenshot. The mouse cursor does change to that shape if I hover over it (see the screenshot for proof).
And as I wrote, the same themes work fine in 4.10.5.

Here's a file listing:
ls -l /usr/share/icons/crystalwhite/cursors/
insgesamt 272
lrwxrwxrwx 1 root root    14 11. Mär 2013  00008160000006810000408080010102 -> v_double_arrow
lrwxrwxrwx 1 root root    14 11. Mär 2013  028006030e0e7ebffc7f7070c0600140 -> h_double_arrow
lrwxrwxrwx 1 root root    14 11. Mär 2013  03b6e0fcb3499374a867c041f52298f0 -> crossed_circle
lrwxrwxrwx 1 root root    14 11. Mär 2013  08e8e1c95fe2fc01f976f1e063a24ccd -> left_ptr_watch
lrwxrwxrwx 1 root root     4 11. Mär 2013  1081e37283d90000800003c07f3ef6bf -> copy
lrwxrwxrwx 1 root root    17 11. Mär 2013  14fef782d02440884392942c11205230 -> sb_h_double_arrow
lrwxrwxrwx 1 root root    17 11. Mär 2013  2870a09082c103050810ffdffffe0204 -> sb_v_double_arrow
lrwxrwxrwx 1 root root     4 11. Mär 2013  3085a0e285430894940527032f8b26df -> link
lrwxrwxrwx 1 root root    14 11. Mär 2013  3ecb610c1bf2410f44200f48c40d3599 -> left_ptr_watch
lrwxrwxrwx 1 root root     4 11. Mär 2013  4498f0e0c1937ffe01fd06f973665830 -> move
lrwxrwxrwx 1 root root     4 11. Mär 2013  6407b0e94181790501fd1e167b474872 -> copy
lrwxrwxrwx 1 root root     4 11. Mär 2013  640fb0e74195791501fd1ed57b41487f -> link
lrwxrwxrwx 1 root root     4 11. Mär 2013  9081237383d90e509aa00f00170e968f -> move
lrwxrwxrwx 1 root root     5 11. Mär 2013  9d800788f1b08800ae810202380a0822 -> hand1
lrwxrwxrwx 1 root root     9 11. Mär 2013  arrow -> right_ptr
-rw-r--r-- 1 root root  1344 27. Jän 2013  base_arrow_down
-rw-r--r-- 1 root root  1344 27. Jän 2013  base_arrow_up
lrwxrwxrwx 1 root root    15 11. Mär 2013  based_arrow_down -> base_arrow_down
lrwxrwxrwx 1 root root    13 11. Mär 2013  based_arrow_up -> base_arrow_up
-rw-r--r-- 1 root root  1288 27. Jän 2013  bd_double_arrow
-rw-r--r-- 1 root root  1288 27. Jän 2013  bottom_left_corner
-rw-r--r-- 1 root root  1288 27. Jän 2013  bottom_right_corner
-rw-r--r-- 1 root root  1352 27. Jän 2013  bottom_side
lrwxrwxrwx 1 root root    15 11. Mär 2013  c7088f0f3e6c8088236ef8e1e3e70000 -> bd_double_arrow
-rw-r--r-- 1 root root  1472 27. Jän 2013  center_ptr
-rw-r--r-- 1 root root  2664 27. Jän 2013  circle
-rw-r--r-- 1 root root  2560 27. Jän 2013  copy
-rw-r--r-- 1 root root  2564 27. Jän 2013  cross
-rw-r--r-- 1 root root  2368 27. Jän 2013  crossed_circle
lrwxrwxrwx 1 root root     5 11. Mär 2013  crosshair -> cross
lrwxrwxrwx 1 root root     5 11. Mär 2013  cross_reverse -> cross
lrwxrwxrwx 1 root root    14 11. Mär 2013  d9ce0ab605698f320427677b458ad60b -> question_arrow
-rw-r--r-- 1 root root  2664 27. Jän 2013  dot
-rw-r--r-- 1 root root  2368 27. Jän 2013  dotbox
lrwxrwxrwx 1 root root    14 11. Mär 2013  double_arrow -> v_double_arrow
lrwxrwxrwx 1 root root     9 11. Mär 2013  draft_large -> right_ptr
lrwxrwxrwx 1 root root     9 11. Mär 2013  draft_small -> right_ptr
-rw-r--r-- 1 root root  2368 27. Jän 2013  draped_box
lrwxrwxrwx 1 root root     5 11. Mär 2013  e29285e634086352946a0e7090d73106 -> hand2
lrwxrwxrwx 1 root root    15 11. Mär 2013  fcf1c3c7cd4491d801f1e1c78f100000 -> fd_double_arrow
-rw-r--r-- 1 root root  1288 27. Jän 2013  fd_double_arrow
-rw-r--r-- 1 root root  2368 27. Jän 2013  fleur
-rw-r--r-- 1 root root  2172 27. Jän 2013  hand
lrwxrwxrwx 1 root root     4 11. Mär 2013  hand1 -> hand
lrwxrwxrwx 1 root root     4 11. Mär 2013  hand2 -> hand
-rw-r--r-- 1 root root  1504 27. Jän 2013  h_double_arrow
-rw-r--r-- 1 root root  1628 27. Jän 2013  left_ptr
-rw-r--r-- 1 root root 54608 27. Jän 2013  left_ptr_watch
-rw-r--r-- 1 root root  1504 27. Jän 2013  left_side
-rw-r--r-- 1 root root  2560 27. Jän 2013  link
lrwxrwxrwx 1 root root    15 11. Mär 2013  ll_angle -> fd_double_arrow
lrwxrwxrwx 1 root root    15 11. Mär 2013  lr_angle -> bd_double_arrow
-rw-r--r-- 1 root root  2768 27. Jän 2013  move
-rw-r--r-- 1 root root  2368 27. Jän 2013  pencil
-rw-r--r-- 1 root root  3200 27. Jän 2013  pirate
lrwxrwxrwx 1 root root     5 11. Mär 2013  plus -> cross
-rw-r--r-- 1 root root  2368 27. Jän 2013  question_arrow
-rw-r--r-- 1 root root  1312 27. Jän 2013  right_ptr
-rw-r--r-- 1 root root  1504 27. Jän 2013  right_side
-rw-r--r-- 1 root root  2332 27. Jän 2013  sb_h_double_arrow
-rw-r--r-- 1 root root  1408 27. Jän 2013  sb_right_arrow
-rw-r--r-- 1 root root  1472 27. Jän 2013  sb_up_arrow
-rw-r--r-- 1 root root  2040 27. Jän 2013  sb_v_double_arrow
lrwxrwxrwx 1 root root     5 11. Mär 2013  tcross -> cross
lrwxrwxrwx 1 root root     8 11. Mär 2013  top_left_arrow -> left_ptr
-rw-r--r-- 1 root root  1288 27. Jän 2013  top_left_corner
-rw-r--r-- 1 root root  1288 27. Jän 2013  top_right_corner
-rw-r--r-- 1 root root  1352 27. Jän 2013  top_side
-rw-r--r-- 1 root root  1352 27. Jän 2013  v_double_arrow
-rw-r--r-- 1 root root 66320 27. Jän 2013  watch
-rw-r--r-- 1 root root  1744 27. Jän 2013  X_cursor
-rw-r--r-- 1 root root  1312 27. Jän 2013  xterm


> I also installed a "crystal xcursors" theme, but it doesn't show up in the
> theme list at all....
According to the package description, it's this: http://digilander.iol.it/m4rt/crystalcursors.html
But it also happens with all other themes I have installed, except Oxygen.
That includes: DMZ, Adwaita, handhelds, redglass, whiteglass

> Can you try a patch?
Yes. I would be glad to.
Comment 6 Wolfgang Bauer 2013-10-08 14:40:01 UTC
Well, I wrote "cross" shape in my previous , but the theme's image file is actually called "fleur".
It's the shape that should be shown when you move a window.
Comment 7 Thomas Lübking 2013-10-08 16:52:44 UTC
Well, "cross" would be loaded and given the maaaaaaaaany sylinks and copies i got in ~/.icons/Neutral++/cursors i assume this is the issue: completely inconsistent naming between what's loaded and the themes provide, eg. "EntisCursors" has "fleur" as well, but no "cross" (though "crossed_circle")

I've no idea about fdo cursor specification, but hope there's at least one.
I'll check it. Either this is a bug in KWin/KDE (for the icons should be "fleur") or in the cursor theme (for it should be "cross")
Comment 8 Wolfgang Bauer 2013-10-08 17:14:32 UTC
I found out the reason why the mouse cursor doesn't change while moving a window:
Those themes don't contain a file "size_all". If I manually create a symlink named "size_all" to "fleur" (as included in the Oxygen themes), it works.
But I still don't understand why that shape shows up in systemsettings->Workspace Appearance->Cursor Theme then.
And those themes fully worked (without "size_all") in 4.10.5.
Comment 9 Thomas Lübking 2013-10-08 17:18:52 UTC
The cursor theme kcm loads "size_all" and resorts to "fleur" as failsafe - "cross" is something entirely different.
The kwin cursor abstraction just loads size_all.
I've not yet found any half-wise official naming convention (and am far more confused than before ;-)
Comment 10 Thomas Lübking 2013-10-08 17:25:43 UTC
Next second i found http://www.freedesktop.org/wiki/Specifications/cursor-spec/ after http://lists.freedesktop.org/archives/xdg/2003-October/001021.html

It mentions neither ... =)

Luckily, there's a familiar name in the document...
Fredrik, what's the correct name here? "fleur" or "size_all"?
Comment 11 Martin Flöser 2013-10-08 18:47:52 UTC
> The kwin cursor abstraction just loads size_all.
ftr: the kwin cursor abstraction uses the same names as QCursor (Qt 4.8) does.
Comment 12 Wolfgang Bauer 2013-10-08 19:03:52 UTC
(In reply to comment #10)
> Next second i found
> http://www.freedesktop.org/wiki/Specifications/cursor-spec/ after
> http://lists.freedesktop.org/archives/xdg/2003-October/001021.html
> 
> It mentions neither ... =)
Well, the mailinglist post does mention the "fleur cursor". ;)
And since _all_ my themes have "fleur" (even Oxygen, they additionally provide the "size_all" symlink to "fleur") I would prefer that.

(In reply to comment #9)
> The cursor theme kcm loads "size_all" and resorts to "fleur" as failsafe -
> "cross" is something entirely different.
> The kwin cursor abstraction just loads size_all.
Thanks, that explains it. But shouldn't those two behave the same for consistency? This can cause confusion for the user.

And btw. I have tested your review request now. It seems to fix the issue that the fleur cursor (why only this one?) was still taken from the previous theme after a theme change.
But I discovered another glitch that's still there with your patch, not sure if I should open another bug report for this:
After changing the theme and clicking on "Apply" it happens that there's either no cursor change anymore for window sizing, or the cursors are swapped (the wrong arrows are used). All other shapes seem to work though.
I then killed and restarted kwin and now the mouse cursor changes the theme when moved over the window decorations??? (I think that's bug#324120 though) Logout/Login again fixes those glitches.
Comment 13 Thomas Lübking 2013-10-08 19:27:51 UTC
(In reply to comment #12)

> Well, the mailinglist post does mention the "fleur cursor". ;)
> And since _all_ my themes have "fleur" (even Oxygen, they additionally
> provide the "size_all" symlink to "fleur") I would prefer that.
> [...]
> Thanks, that explains it. But shouldn't those two behave the same for
> consistency? This can cause confusion for the user.
See Martins comment on either. (Code is apparently copied from Qt - happened indepently and later)

I'd prefer the name that is somehow specified somewhere. What icon themes do doesn't matter - they're most likely all created by the same conversion script ...

> And btw. I have tested your review request now. It seems to fix the issue
> that the fleur cursor (why only this one?) was still taken from the previous
> theme after a theme change.
Yes, that's the idea.

> After changing the theme and clicking on "Apply" it happens that there's
> either no cursor change anymore for window sizing, or the cursors are
> swapped (the wrong arrows are used).
I get no size arrows as hints, but on resizing - but only after trying a "broken" theme.
These (hinting, not dragging/resizing) cursors are however set via QWidget::setCursor(enum Qt::CursorShape)

> I then killed and restarted kwin and now the mouse cursor changes the theme
> when moved over the window decorations??? (I think that's bug#324120 though)
I get the same for every new appliaction (and previously used shape?)
Maybe the kcm forgets to delete some on disk cache.
Comment 14 Martin Flöser 2013-10-09 06:17:42 UTC
> See Martins comment on either. (Code is apparently copied from Qt - happened
> indepently and later)
I thought about it more and remembered that I did not look into the code, but 
followed the documentation: https://qt-project.org/doc/qt-4.8/qcursor.html

But it's the same in the code, only size_all: 
http://code.woboq.org/kde/qt4/src/gui/kernel/qcursor_x11.cpp.html#262
Comment 15 Wolfgang Bauer 2013-10-09 06:50:44 UTC
Created attachment 82738 [details]
Screenshot showing wrong resize cursor after theme change

(In reply to comment #13)
> See Martins comment on either. (Code is apparently copied from Qt - happened
> indepently and later)
> 
> I'd prefer the name that is somehow specified somewhere. What icon themes do
> doesn't matter - they're most likely all created by the same conversion
> script ...
> 
OK, so that was apparently changed on purpose for 4.11.
I agree with you of course that the name used should be part of a specification.
It's just that I have been using that Crystal White theme for about 10 years, and suddenly that fleur/size_all cursor stopped working, so I thought this must be a regression in kwin.

But I really think the kcm and kwin should use exactly the same files for consistency. But this can be seen as bug in the kcm as well, of course.

> > After changing the theme and clicking on "Apply" it happens that there's
> > either no cursor change anymore for window sizing, or the cursors are
> > swapped (the wrong arrows are used).
> I get no size arrows as hints, but on resizing - but only after trying a
> "broken" theme.
> These (hinting, not dragging/resizing) cursors are however set via
> QWidget::setCursor(enum Qt::CursorShape)
>
What do you mean with "hinting"?

If I switch _to_ the Crystal White theme and press "Apply", I get the wrong sizing cursor when moving the mouse to a window's corner (see the newly attached screenshot for clarification). The same happens with those other mentioned themes that provide a resize cursor. (redglass f.e. doesn't, so if I switch to that, the cursor doesn't change its shape on resizing, and I don't have a different cursor shape for resizing even if I change to another theme _with_ those cursors then)

When I logout and login again, all this is fixed and the correct shapes are shown (and redglass f.e. shows X's? default one).

I think this has to do with the theme's filenames as well, since those themes don't include "size_bdiag" and "size_fdiag" as Oxygen does (they are called "fd_double_arrow" and "bd_double_arrow" in Crystal White). If I create a link it seems to work correctly even after a theme change.
But IMHO there's a bug in kwin here: apparently different filenames are used as fallback by kwin when starting up, as opposed to loading a new theme when already running. (I could be wrong of course, and something completely different happens... ;) )

> I get the same for every new appliaction (and previously used shape?)
> Maybe the kcm forgets to delete some on disk cache.
Hm, but why does it get fixed when you logout and login again? If it's a stale disk cache, the problem should persist then, shouldn't it?
Comment 16 Wolfgang Bauer 2013-10-09 07:05:05 UTC
I just want to add that the thing about the wrong resize cursor already happens in 4.10.5. The rest works fine there, though, as far as I can tell (including the resize cursor for a theme that doesn't provide one).
Comment 17 Thomas Lübking 2013-10-09 13:09:36 UTC
(In reply to comment #15)
> What do you mean with "hinting"?
There's a cursor set when you hover the edge of the decoration/titlebar, "hinting" the action that is gonna take place.
That one's set by QWidget.

Then there's a cursor set when actually performing the action (also with alt+rmb)
That one's set by KWin directly.
 
> But IMHO there's a bug in kwin here: apparently different filenames are used
> as fallback by kwin when starting up, as opposed to loading a new theme when
> already running. (I could be wrong of course, and something completely
> different happens... ;) )
The hovering cursors are set by Qt, not kwin - could be due to Qt internal cursor image caching.

> Hm, but why does it get fixed when you logout and login again? If it's a
> stale disk cache, the problem should persist then, shouldn't it?
Unless Qt deletes it - or the caching happens on the X11 server (what's actually more reasonable), ie. Qt keeps a "private" cache as root property or whatnot.

I'd have to look that up ;-)
Comment 18 Fredrik Höglund 2013-10-09 15:59:54 UTC
(In reply to comment #10)
> Next second i found
> http://www.freedesktop.org/wiki/Specifications/cursor-spec/ after
> http://lists.freedesktop.org/archives/xdg/2003-October/001021.html
> 
> It mentions neither ... =)
> 
> Luckily, there's a familiar name in the document...
> Fredrik, what's the correct name here? "fleur" or "size_all"?

"fleur" is the name of the crossed double-arrow cursor in the X11 cursor font,
but QCursor expects this cursor to be named "size_all". I assume the Qt developer
who added it wasn't aware that the cursor already existed under a different name.

The proposed freedesktop standard is not implemented by anyone AFAIK,
including us.
Comment 19 Thomas Lübking 2013-10-09 18:22:00 UTC
head -> table

Seems wayland just recycles X11 cursor themes.
Qt5.2 as the same names, so i guess we'll have to follow the alternatives approach from xcursortheme (instead of resorting to XCB_CURSOR_NONE)

OTOH, a theme that does not include the cursors which Qt expects is just broken with any Qt client anyway - so why should it work with only KWin... *sigh*

In the meantime:
http://kde-look.org/content/show.php?content=161037
Comment 20 Wolfgang Bauer 2013-10-09 18:24:45 UTC
(In reply to comment #17)
> (In reply to comment #15)
> > What do you mean with "hinting"?
> There's a cursor set when you hover the edge of the decoration/titlebar,
> "hinting" the action that is gonna take place.
> That one's set by QWidget.
> 
> Then there's a cursor set when actually performing the action (also with
> alt+rmb)
> That one's set by KWin directly.
>  
Aha.
So then, "hinting" shows the wrong shape as can be seen in the screenshot.
The actual resize showed the shape from the previous set theme. With your patch added, it does not change the mouse cursor at all.
I somehow have the impression that this is actually caused by the kcm. It shows the wrong "resize" shape in the preview for those themes ("size_fdiag", whereas for Oxygen "size_bdiag" is shown). Maybe this wrong shape gets added to that cache you mentioned because of that preview?
Anyway, this is all down to the theme's filenames now it seems as it works correctly when I add symlinks, so that maybe should be fixed in the themes themselves.

The only thing left then is the discrepancy between the kcm's preview and kwin regarding the shapes I think.
Comment 21 Wolfgang Bauer 2013-10-10 08:14:10 UTC
I had a look at the kcm's sources now to find out why the wrong resize pointer is shown for those themes that don't provide "size_bdiag".

Apparently in XCursorTheme::findAlternative() (file kcontrol/input/xcursor/xcursortheme.cpp) the alternatives for "size_bdiag" and "size_fdiag" are swapped.

I have created a separate bug report for this: bug#325837

I just want to point to that function here, maybe something similar should be used in kwin as well?

And FTR, there's this comment in there:
 // Qt uses non-standard names for some core cursors.
 // If Xcursor fails to load the cursor, Qt creates it with the correct name using the
 // core protcol instead (which in turn calls Xcursor). We emulate that process here.
 // Note that there's a core cursor called cross, but it's not the one Qt expects.
Comment 22 Martin Flöser 2015-01-14 12:56:02 UTC
Git commit 7dc2baf74d67761ecee579af26a1b80ba7daa92c by Martin Gräßlin.
Committed on 08/01/2015 at 16:03.
Pushed by graesslin into branch 'Plasma/5.2'.

Update cursor theme when it changes at runtime

Connecting to the DBus signal emitted on KGlobalAccels by the
cursor kcm and forcing a reload of all cursors. For runtime
config change we need to take the config value and need to ignore
the now outdated environment variables.

REVIEW: 121928
FIXED-IN: 5.2.0

M  +24   -6    cursor.cpp
M  +2    -0    cursor.h

http://commits.kde.org/kwin/7dc2baf74d67761ecee579af26a1b80ba7daa92c