Bug 492681

Summary: xdg-desktop-portal-kde breaks printing with Inkscape
Product: [Plasma] xdg-desktop-portal-kde Reporter: Tobias Leupold <tl>
Component: generalAssignee: Plasma Bugs List <plasma-bugs>
Status: REPORTED ---    
Severity: normal CC: aleixpol, jgrulich, kde, kdedev, nate, nicolas.fella, tl
Priority: NOR    
Version: 6.1.4   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Tobias Leupold 2024-09-05 14:48:07 UTC
Hi all,

when printing somehting with Inkscape and xdg-desktop-portal-kde is active, the printed output is way too small. This seems to be a regression, as everything worked okay using the Plasma 5 version.

Having exported GTK_USE_PORTAL=1 via ~/.config/plasma-workspace/env/exports.sh, when I try to print a 10x10cm square, the printed output is 48x48mm. When I do the same without the export, the printed output is the size it should be.

I see this both on my Gentoo desktop and my Artix notebook, both running Plasma 6.1.4, using Inkscape 1.3.2 – so I don't think this is a distribution-specific issue.

I'll gladly help to track this down! Thank for fixing this, so I can get native Firefox file dialogs back ;-)

Cheers, Tobias
Comment 1 Nate Graham 2024-09-16 19:26:23 UTC
Interesting, that is very strange.
Comment 2 TraceyC 2024-09-16 19:45:28 UTC
I can confirm this behavior on Plasma-dev, both Wayland and X11 sessions

Steps to reproduce:
- Installed Discord via repo package
- Installed DiscordCanary via flathub-beta

1. Launched Discord, checked icon in Icons-Only-Task-Manager
Icon is correct - the blue Discord icon
2. Pinned the Discord icon
3. Launched Discord Canary
Initially it showed a separate, yellow icon as expected.
The blue icon was highlighted, I clicked on it. This brought up the Discord Canary window. The yellow icon disappeared. Both windows were grouped under the blue icon now.
4. Closed both versions of Discord and started up Canary
During launch, the yellow icon was shown in the task bar. After it completed loading, the icon changed to the blue icon.


**Notes**
I can also reproduce this behavior with Firefox, on 6.1.5, using two different profiles with different .desktop files. This issue has persisted since 6.0 at least.

I have a pinned icon on the taskbar per profile.
Personal - regular Firefox icon
Work - all white Firefox icon

After launching Firefox with the Personal profile, it correctly shows the windows when interacting with its icon in the taskbar
After launching a new Firefox window with the Work profile:
- The icon for the Work profile is still correctly pinned to the task manager
- All windows from both profiles are grouped under the icon for the Personal profile
Comment 3 TraceyC 2024-09-16 20:33:40 UTC
Apologies, my last reply was for a different bug.

For this bug:
I am unable to reproduce this behavior on Plasma-dev (Wayland)
Inkscape 1.3.2

Steps to reproduce

1. Execute `export GTK_USE_PORTAL=1`
2. Launch Inkscape
3. Create a 10x10cm square and print
4. Execute `export GTK_USE_PORTAL=0`
5. Print the file again

The printout was the same for either. The printed square was 9.5cm square

I noticed that a 10x10mm square printed at about 48mm

Are there more specific steps you're following to enable xdg-desktop-portal-kde maybe?
Comment 4 Tobias Leupold 2024-09-17 07:21:37 UTC
I already wondered ;-)

I set the variables in .config/plasma-workspace/env/exports.sh, containing "export GTK_USE_PORTAL=1".

But it also works if started from the console, i.e running "GTK_USE_PORTAL=1 inkscape" vs. "inkscape". Notice the changed print dialog!

I can reliably reproduce this using Inkscape 1.3.2, xdg-desktop-portal 1.18.4 and xdg-desktop-portal-kde 6.1.4, running Plasma on X11.
Comment 5 TraceyC 2024-09-18 20:27:36 UTC
> But it also works if started from the console, i.e running "GTK_USE_PORTAL=1 inkscape" vs. "inkscape". Notice the changed print dialog!

Thanks for the additional information. I do notice the difference in the print dialog between the two commands, even on Wayland
I had tested previously  with Wayland. I tested again with X11.  I am still unable to reproduce either with git-master or Plasma 6.1.5

Running `GTK_USE_PORTAL=1 inkscape` and bringing up the print dialog with Ctrl P, printing
Inkscape 1.3.2, xdg-desktop-portal 1.18.4, xdg-desktop-portal-kde 6.1.5

Just to check these as possible variables:
- Is your file an .svg? (I was testing with an .svg file)
- What is your printer model? (I have an HP M479fdn color laserjet)
Comment 6 Tobias Leupold 2024-09-19 21:47:43 UTC
I think it doesn't matter what you print. I didn't use an SVG file. I just opened Inkscape and drew a 10x10 cm square. You can write something as well, or use whatever source you like. The result is always the same. It also does not seem to depend on the printer and/or driver.

I have three printers available:
- A (quite old) Brother HL-1230, using the Brother BrGenML1 vendor driver
- A (also quite old) Brother MFC-7440N, also using the BrGenML1 vendor driver
- A Brother HL-L2370DN, either using brlaser v6 or IP Everywhere (driverless)

I get the very same result on all three, and for the third also for both drivers:

If I print from Inkscape having GTK_USE_PORTAL not exported or GTK_USE_PORTAL=0 set (using GTK's native print dialog), the print output is as expected. Using GTK_USE_PORTAL=1 (seeing the Qt/KDE style print dialog), I get the printed output at ca. 1/2 of the expected size, as described. For each printer and each driver. Each time.
Comment 7 Tobias Leupold 2024-09-26 08:23:32 UTC
Interestingly, the behavior differs.

I just tried it on my office machine running Artix Linux, Inkscape 1.3.2, xdg-desktop-portal 1.18.4 and xdg-desktop-portal-kde 6.1.5.

Without GTK_USE_PORTAL being exported, a 100x100 mm square is printed with a side length of quite exactly 100 mm. With GTK_USE_PORTAL=1 being set, the same square is printed with ca. 91 mm side length.

Here, I used a Brother MFC 8880DN using the BrGenML1 driver.
Comment 8 Tobias Leupold 2024-09-28 07:56:03 UTC
Another addition: I now remembered that actually, Inkscape did not support using xdg-desktop-portal at all; ca. a year ago, I commented on a GitLab issue asking for adding it: https://gitlab.com/inkscape/inbox/-/issues/783#note_1642923028

Seems like they introduced this recently … maybe, this is actually an upstream issue?!

However, I now also filed an Inkscape bug about this: https://gitlab.com/inkscape/inbox/-/issues/11068