Bug 396770 - Jagged Edges on Latte Dock when scaling
Summary: Jagged Edges on Latte Dock when scaling
Status: RESOLVED FIXED
Alias: None
Product: lattedock
Classification: Plasma
Component: plasmoid (show other bugs)
Version: unspecified
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: Michail Vourlakos
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-22 23:03 UTC by elman
Modified: 2021-03-26 11:07 UTC (History)
3 users (show)

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


Attachments
Wrong scaling (108.87 KB, image/png)
2018-07-22 23:03 UTC, elman
Details
Scaling of desktop right click menu (315.11 KB, image/png)
2018-07-23 05:18 UTC, elman
Details
latte-wayland-jagged (63.58 KB, image/png)
2018-08-03 13:12 UTC, elman
Details
latte-x11-smooth (133.69 KB, image/png)
2018-08-03 13:13 UTC, elman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description elman 2018-07-22 23:03:12 UTC
Created attachment 114073 [details]
Wrong scaling

After update to 0.8.0 all icons in task manager have wrong scaling. Version 0.7.x was fine. Previously I used size 96px, now I have 48px. See screenshot attached.

I use PLASMA_USE_QT_SCALING=1, because other apps do not scale correctly without it (like original plasma panel). Font DPI is set correctly to 192 DPI. Scaling factor is 2.
Comment 1 Michail Vourlakos 2018-07-22 23:20:14 UTC
> I use PLASMA_USE_QT_SCALING=1, because other apps do not scale correctly without it (like original plasma panel).

I suppose you must contact plasma devs and find out how to setup your environment correctly without PLASMA_USE_QT_SCALING=1
Comment 2 elman 2018-07-22 23:30:47 UTC
Let's say I use icons with size 32px and scale 1. Then I switch scale to 2, I still should be using icons with size 32px, right? Or is pixel always considered physical pixel and then I should use 64px?

I'm coming from web world where pixel is considered as virtual pixel and screen density manages how many physical pixels are mapped to virtual pixel.
Comment 3 elman 2018-07-22 23:47:54 UTC
And when I say plasma panel, I mean System Tray icons which are quite small without PLASMA_USE_QT_SCALING=1. Also right click menu uses small icons which look like 16px icons on HiDPI display.

And to make things more confusing, Wayland session seems to do this differently. System Tray icons have correct size and Latte Dock icons have double size. So this actually behaves like I would expect it to.
Comment 4 David Edmundson 2018-07-23 04:51:29 UTC
> PLASMA_USE_QT_SCALING=1, 

You can't randomly set hidden internal environment variables. Lots of things will be broke.

Can you clarify if the Wayland behavior is correct? You used the term double size.
Comment 5 elman 2018-07-23 05:16:48 UTC
I would like to have latte dock of size 48px. With various settings it works like this:

X11 + scale factor 1 + dock size 48px = OK
X11 + scale factor 2 + dock size 48px = small icons
X11 + scale factor 2 + dock size 96px = OK
X11 + scale factor 2 + dock size 48px + PLASMA_USE_QT_SCALING=1 = size OK, but icons have jagged edges
Wayland + scale factor 2 + dock size 48px = OK
Wayland + scale factor 2 + dock size 96px = large icons

I believe that scaling should be done on background and front end application should be using same size of 48px regardless of scale factor. Of course front end application must be aware of scale factor when displaying high resolution content like images or bitmap icons.

I'm also attaching another picture. It shows desktop right click menu. In front is my actual desktop and in the background is VirtualBox which basically doubles the size of display without scaling. However as you can see font size about the same (I have font DPI set to 192). But icons on real desktop are only half the size as they should be. When I set PLASMA_USE_QT_SCALING=1, icons are scaled as expected and font size remains the same.
Comment 6 elman 2018-07-23 05:18:21 UTC
Created attachment 114078 [details]
Scaling of desktop right click menu
Comment 7 elman 2018-07-23 05:34:53 UTC
Update to my previous observations:

Wayland + scale factor 2 + dock size 48px = OK, but icons have jagged edges
Wayland + scale factor 2 + dock size 96px = large icons, but no jagged edges
Wayland + scale factor 2 + dock size 48px + PLASMA_USE_QT_SCALING=1= OK, but icons have jagged edges

So it seems that PLASMA_USE_QT_SCALING has no effect in Wayland session.
Comment 8 David Edmundson 2018-07-23 06:22:24 UTC
Things are complex:

 - plasma does it's own scaling thing making things just bigger based on font size. It was first, but it has a limited scope and is somewhat rubbish (hence context menu being wrong)

 - Qt has a thing to have a separate physical and virtual pixels within the client app. Mostly fantastic. Used in all apps.
Causes a mess for things like panels where we have to communicate between apps or the WM which don't use the same virtual pixels as the client sees.
Given we have above, it's disabled in Plasma.

 - wayland also understands scaling that has the separate virtual and physical pixels. It requires the "qt scaling" above to keep things high res but at least we now use the same virtual pixels between app communication.

On wayland we enabled Qt scaling, using the internal env I added. 

When enabled in general as your virtual font size is now scaled back to 96dpi,  Plasma's scaling cancels out. (even if it makes the code a mess)

Latte dock being plasma is mostly doing it the "plasma way" but it has a setting in "px" which doesn't fit in within the Plasma font approach and won't cancel out when we enable scaling. Your initial bug.
It also /might/ do it's own icon pixmap handling, which needs to be adapted for Qt scaling. (potential jaggedness)


-----

In any case, I shall look into fixing latte + wayland having jagged edges.  
If that happens to fix anything else, great. Otherwise, tough.
Comment 9 elman 2018-07-23 11:53:19 UTC
Thank you very much for that comprehensive explanation. It certainly made things clearer.

So I guess best thing for me will be to wait for Wayland session becoming stable enough to be used daily.
Comment 10 David Edmundson 2018-08-02 23:16:39 UTC
> Wayland + scale factor 2 + dock size 48px = OK, but icons have jagged edges

Couldn't reproduce. I turned on Qt's scaling and went up to 4x, it was all smooth.

Can you post a screenshot?
Comment 11 elman 2018-08-03 13:12:42 UTC
Created attachment 114284 [details]
latte-wayland-jagged
Comment 12 elman 2018-08-03 13:13:01 UTC
Created attachment 114285 [details]
latte-x11-smooth
Comment 13 elman 2018-08-03 13:19:16 UTC
Sure. I have added 2 screenshots. One from wayland (Wayland + scale factor 2 + dock size 48px) and one from X11 (X11 + scale factor 2 + dock size 96px). 

X11 screenshot is 4K, but wayland screenshot was for some unknown reason saved only as full HD. I used Spectacle. Anyway, worst looking icon is Thunderbird. Hopefully you will see what I mean.
Comment 14 David Edmundson 2018-08-03 13:37:34 UTC
Yeah, I can.

Can you provide your Plasma + frameworks version numbers please. They can be found in kinfocenter
Comment 15 elman 2018-08-04 00:22:51 UTC
I have:
KDE Plasma: 5.13.3
KDE Frameworks: 5.48.0
Qt: 5.11.1
Kernel: 4.17.9-1-MANJARO
OS Type: 64-bit
Comment 16 Michail Vourlakos 2018-08-25 14:40:26 UTC
(In reply to David Edmundson from comment #8)
> Latte dock being plasma is mostly doing it the "plasma way" but it has a
> setting in "px" which doesn't fit in within the Plasma font approach and
> won't cancel out when we enable scaling. Your initial bug.
> It also /might/ do it's own icon pixmap handling, which needs to be adapted
> for Qt scaling. (potential jaggedness)
>  
> -----
> 
> In any case, I shall look into fixing latte + wayland having jagged edges.  
> If that happens to fix anything else, great. Otherwise, tough.

I found the thread accidentally... The assumptions are correct, even though Latte is trying to use plasma code directly as much as possible the icons in the Latte taskmanager are painted by  Latte. The reason for this was that there was no other way to support the parabolic effect otherwise. The Plasma.IconItem will always paint the best fit icon based on the enabled icon theme. For icons with size lower than 64px. that breaks the smoothness of the parabolic effect. In the end the decision was to fork PlasmaCore.IconItem and follow its development closely in order to update the implementation of Latte.IconItem . The thing is that personally I dont understand very good the painting taking place in IconItem(s) and if something can be done better. 

The source code for Latte.IconItem can be found here: https://phabricator.kde.org/source/latte-dock/browse/master/liblattedock/iconitem.cpp$295
Comment 17 Michail Vourlakos 2021-03-10 06:22:20 UTC
Latte Tasks in latest git version is using Kirigami.Icons this should not be valid any more.
Comment 18 Bug Janitor Service 2021-03-25 04:33:48 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 19 Nate Graham 2021-03-25 17:32:16 UTC
Cool.
Comment 20 elman 2021-03-26 11:07:49 UTC
Checked it and icons look the same on X11 and Wayland. Thanks a lot.