Bug 144302 - Load cursor from PNG on kf5
Summary: Load cursor from PNG on kf5
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
7.3.0.0 alpha0+
Hardware: All Linux (All)
: medium enhancement
Assignee: Michael Weghorn
URL:
Whiteboard: target:7.6.0 target:7.5.2
Keywords: difficultyMedium, easyHack, skillCpp
Depends on:
Blocks: KDE, KF5 Icon-Themes-Code
  Show dependency treegraph
 
Reported: 2021-09-04 22:47 UTC by Rizal Muttaqin
Modified: 2023-02-24 09:14 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Sukapura icon theme extension with custom cross cursor (vcl/res/fatcursor.png) (17.60 MB, application/vnd.openofficeorg.extension)
2021-09-04 22:47 UTC, Rizal Muttaqin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rizal Muttaqin 2021-09-04 22:47:30 UTC
Created attachment 174781 [details]
Sukapura icon theme extension with custom cross cursor (vcl/res/fatcursor.png)

With the introduction of cross cursor (tdf#104169) and the available option to switch between old normal pointer cursor and new cross cursor (tdf#142499), I expect the cross cursor now theme-able based on icon theme. But in fact, I have found that this is just applicable to GTK3 environment only, gen and kf5 has no effect at all.

Step to reproduce:

1. Install Sukapura icon theme extension
2. Run Calc in different environment (GTK3, gen, KF5), see the result

Expected result: 

- The cross cursor changes following icon theme in all environments

Observer 

- The cross cursor did not changed following icon theme just in GTK3 environment

Version: 7.3.0.0.alpha0+ / LibreOffice Community
Build ID: 9b8a4171c5ef9f2b88b73007e394774b4ab84a66
CPU threads: 4; OS: Linux 5.11; UI render: default; VCL: kf5 (cairo+xcb)
Locale: id-ID (id_ID.UTF-8); UI: en-US
TinderBox: Linux-rpm_deb-x86_64@86-TDF, Branch:master, Time: 2021-08-30_13:20:16
Calc: threaded
Comment 1 Rizal Muttaqin 2021-09-04 22:48:24 UTC
(In reply to Rizal Muttaqin from comment #0)
> Created attachment 174781 [details]
> Sukapura icon theme extension with custom cross cursor
> (vcl/res/fatcursor.png)
> 

Edit, this should be vcl/res/fatcross.png
Comment 2 Heiko Tietze 2021-09-05 07:15:01 UTC
Confirming, works only with gtk3

Version: 7.3.0.0.alpha0+ / LibreOffice Community
Build ID: 7d0d07ed0f572c99c70d7f4384dfce644cbbf939
CPU threads: 8; OS: Linux 5.13; UI render: default; VCL: kf5 (cairo+xcb)
Locale: de-DE (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 3 Caolán McNamara 2021-09-05 19:54:41 UTC
Reading the getCursor implementations I would expect that the theme is usable for osx as well which also has the option for fancy cursors loaded from fairly arbitrary external data, while the gen/kf5 cursors are limited to the built-in xbm fallbacks (and win limited to equivalent built-in .cur ones).

I imagine it could be possible for at least the kf5 backend to change MAKE_CURSOR in vcl/qt5/Qt5Data.cxx away from using the built-in xbms to loading the theme icon instead. QCursor seems to take a QPixmap argument and QPixmap has a loadFromData member which I imagine could be used similarly to how in the gtk3 version the theme icon can be loaded to a GdkPixmap via load_icon_by_name and that passed to gdk_cursor_new_from_pixbuf. So there could be a medium level easy hack there to change kf5 to load the cursors from icon-theme and not keep using the old-school built-in xbms. Changing gen to do anything except handle xbms is probably futile, and I don't know what options exist under windows.

This isn't really a bug in the sense of something broken, just a consequence that the "built-in" icons are the original/default way to implement icons but those old apis and formats are archaic in gtk and osx so another way had to be found there and the simplest thing to do was to load cursors from the usual place icons come from which then has the side effect of making them themeable (though not the hot-spot of the cursor which remains hardcoded in all cases).

FWIW it's not (currently) expected that all backends can use cursors from the icon-theme, or even from our built-in old-school xbms/curs. Many of the cursors are explicitly mapped to built-in cursors provided by the host operating system or toolkit so a gtk PointerStyle::Help icon will always use the gtk3 built-in GDK_QUESTION_ARROW cursor.
Comment 4 Michael Weghorn 2023-02-21 07:36:45 UTC
Implementing this also helps avoid running into a Qt bug that makes custom cursors not show at all on Wayland, s. tdf#153333/QTBUG-95434.

Pending Gerrit change: https://gerrit.libreoffice.org/c/core/+/147379
Comment 5 Commit Notification 2023-02-21 08:33:16 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/db6ed07f4c1a086e4962ff16d3ede9aea9e60952

tdf#144302 tdf#153333 qt: Load cursor from icon theme

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2023-02-24 09:14:34 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/091f56e50748e3fd807b9bae88652b68834aac3a

tdf#144302 tdf#153333 qt: Load cursor from icon theme

It will be available in 7.5.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.