Bug 506909

Summary: "Screenshot of Selection": White space with fractional scaling
Product: [Applications] kate Reporter: madness742
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: 25.04.3   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Showcase of the bug.

Description madness742 2025-07-11 12:25:41 UTC
Created attachment 183157 [details]
Showcase of the bug.

SUMMARY
When using fractional scaling, the saved screenshot will have a huge white space around the code.

STEPS TO REPRODUCE
1. Open System Settings -> Display & Monitor ->  Set scaling 125%.
2. Open a file in Kate.
3. Select a couple of lines.
4. Right click -> "Take Screenshot of Selection" -> Save.

OBSERVED RESULT
The image has a huge white space around it.

EXPECTED RESULT
The image should not show excessive white space around it.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora 42
KDE Plasma Version: 6.4.2
KDE Frameworks Version: 6.15.0
Qt Version: 6.9.1

ADDITIONAL INFORMATION
- It seems to have appeared with commit: https://invent.kde.org/frameworks/ktexteditor/-/commit/d5ef4a26cf5be5a0a0a22782db54e5627e8857d8
Comment 1 Bug Janitor Service 2025-07-14 19:30:33 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/822
Comment 2 Waqar Ahmed 2025-07-14 20:26:44 UTC
Git commit a8304647e3b76abf8be28308a01574e5caef4780 by Waqar Ahmed.
Committed on 14/07/2025 at 19:27.
Pushed by cullmann into branch 'master'.

Properly center the screenshot pixmap

Otherwise we have to do weird hacks because the pixmap occupies the
full width.

Use the m_screenshot->geometry() to get the grab rectangle.
QWidget::geometry() returns the correct dpr divided geometry which is
needed when calling QWidget::grab() as it scales the given rectangle's
size by dpr again.

M  +7    -10   src/view/screenshotdialog.cpp

https://invent.kde.org/frameworks/ktexteditor/-/commit/a8304647e3b76abf8be28308a01574e5caef4780