commit:     c6e84ad8f64c774e0a5bb9889bf6b91298ab0bed
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 10 18:58:33 2025 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Fri Oct 10 18:59:42 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c6e84ad8

media-gfx/flameshot: Fix IUSE wayland runtime issues

Bug: https://bugs.gentoo.org/954005
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 .../files/flameshot-13.1.0-fix-wayland.patch       | 190 +++++++++++++++++++++
 media-gfx/flameshot/flameshot-13.1.0-r1.ebuild     |  63 +++++++
 2 files changed, 253 insertions(+)

diff --git a/media-gfx/flameshot/files/flameshot-13.1.0-fix-wayland.patch 
b/media-gfx/flameshot/files/flameshot-13.1.0-fix-wayland.patch
new file mode 100644
index 000000000000..216306e02dc0
--- /dev/null
+++ b/media-gfx/flameshot/files/flameshot-13.1.0-fix-wayland.patch
@@ -0,0 +1,190 @@
+Source: https://github.com/flameshot-org/flameshot/pull/4169
+
+From 06f41a86cc91d53d68871fcdc67053239ff1e87b Mon Sep 17 00:00:00 2001
+From: Yurii Puchkov <[email protected]>
+Date: Sat, 30 Aug 2025 16:36:17 +0300
+Subject: [PATCH] fix: Screen positions in multi-monitor configuration when
+ devicePixelRatio is other than one (#4169)
+
+* fix: screen positions in multi-monitor configuration when devicePixelRatio 
is other than one (Xorg and probably Windows, Wayland is not fixed)
+
+* fix: poor screenshot quality with the scale > 1.0
+
+* fix(win): tool-buttons location
+
+(cherry picked from commit 52be77f401b107b6c8d06dc2b5485f3b00b18d40)
+
+---------
+
+Co-authored-by: Yuriy Puchkov <[email protected]>
+---
+ src/utils/screengrabber.cpp           | 28 +++++++++++--------------
+ src/widgets/capture/buttonhandler.cpp |  6 +++---
+ src/widgets/capture/capturewidget.cpp | 30 ++++++++++++++++++++-------
+ 3 files changed, 38 insertions(+), 26 deletions(-)
+
+diff --git a/src/utils/screengrabber.cpp b/src/utils/screengrabber.cpp
+index cdbc598497..d787ace48b 100644
+--- a/src/utils/screengrabber.cpp
++++ b/src/utils/screengrabber.cpp
+@@ -137,6 +137,7 @@ void ScreenGrabber::freeDesktopPortal(bool& ok, QPixmap& 
res)
+     }
+ #endif
+ }
++
+ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
+ {
+     ok = true;
+@@ -210,24 +211,16 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
+     // multi-monitor setups where screens have different positions/heights.
+     // This fixes the dual monitor offset bug and handles edge cases where
+     // the desktop bounding box includes virtual space.
++    QScreen* primaryScreen = QGuiApplication::primaryScreen();
++    QRect r = primaryScreen->geometry();
+     QPixmap desktop(geometry.size());
+     desktop.fill(Qt::black); // Fill with black background
+-
+-    QPainter painter(&desktop);
+-    for (QScreen* screen : QGuiApplication::screens()) {
+-        QRect screenGeom = screen->geometry();
+-        QPixmap screenCapture = screen->grabWindow(
+-          wid, 0, 0, screenGeom.width(), screenGeom.height());
+-
+-        // Calculate position relative to desktop top-left
+-        QPoint relativePos = screenGeom.topLeft() - geometry.topLeft();
+-        painter.drawPixmap(relativePos, screenCapture);
+-    }
+-    painter.end();
+-
+-    // Set device pixel ratio based on the primary screen
+-    desktop.setDevicePixelRatio(
+-      QApplication::primaryScreen()->devicePixelRatio());
++    desktop =
++      primaryScreen->grabWindow(wid,
++                                -r.x() / primaryScreen->devicePixelRatio(),
++                                -r.y() / primaryScreen->devicePixelRatio(),
++                                geometry.width(),
++                                geometry.height());
+     return desktop;
+ #endif
+ }
+@@ -281,6 +274,9 @@ QRect ScreenGrabber::desktopGeometry()
+         // Qt6 fix: Don't divide by devicePixelRatio for multi-monitor setups
+         // This was causing coordinate offset issues in dual monitor
+         // configurations
++        // But it still has a screen position in real pixels, not logical ones
++        qreal dpr = screen->devicePixelRatio();
++        scrRect.moveTo(QPointF(scrRect.x() / dpr, scrRect.y() / 
dpr).toPoint());
+         geometry = geometry.united(scrRect);
+     }
+     return geometry;
+diff --git a/src/widgets/capture/buttonhandler.cpp 
b/src/widgets/capture/buttonhandler.cpp
+index 4a003714c1..4624fdcfad 100644
+--- a/src/widgets/capture/buttonhandler.cpp
++++ b/src/widgets/capture/buttonhandler.cpp
+@@ -64,7 +64,7 @@ size_t ButtonHandler::size() const
+ 
+ // updatePosition updates the position of the buttons around the
+ // selection area. Ignores the sides blocked by the end of the screen.
+-// When the selection is too small it works on a virtual selection with
++// When the selection is too small, it works on a virtual selection with
+ // the original in the center.
+ void ButtonHandler::updatePosition(const QRect& selection)
+ {
+@@ -122,7 +122,7 @@ void ButtonHandler::updatePosition(const QRect& selection)
+               horizontalPoints(center, addCounter, true);
+             moveButtonsToPoints(positions, elemIndicator);
+         }
+-        // Add buttons at the right side of the selection
++        // Add buttons to the right side of the selection
+         if (!m_blockedRight && elemIndicator < vecLength) {
+             int addCounter = buttonsPerCol;
+             addCounter = qBound(0, addCounter, vecLength - elemIndicator);
+@@ -146,7 +146,7 @@ void ButtonHandler::updatePosition(const QRect& selection)
+               horizontalPoints(center, addCounter, false);
+             moveButtonsToPoints(positions, elemIndicator);
+         }
+-        // Add buttons at the left side of the selection
++        // Add buttons to the left side of the selection
+         if (!m_blockedLeft && elemIndicator < vecLength) {
+             int addCounter = buttonsPerCol;
+             addCounter = qBound(0, addCounter, vecLength - elemIndicator);
+diff --git a/src/widgets/capture/capturewidget.cpp 
b/src/widgets/capture/capturewidget.cpp
+index 4cb3b2c6e7..a152bb352c 100644
+--- a/src/widgets/capture/capturewidget.cpp
++++ b/src/widgets/capture/capturewidget.cpp
+@@ -13,11 +13,8 @@
+ #include "abstractlogger.h"
+ #include "copytool.h"
+ #include "src/config/cacheutils.h"
+-#include "src/config/generalconf.h"
+ #include "src/core/flameshot.h"
+ #include "src/core/qguiappcurrentscreen.h"
+-#include "src/tools/toolfactory.h"
+-#include "src/utils/colorutils.h"
+ #include "src/utils/screengrabber.h"
+ #include "src/utils/screenshotsaver.h"
+ #include "src/utils/systemnotification.h"
+@@ -32,9 +29,7 @@
+ #include <QApplication>
+ #include <QCheckBox>
+ #include <QDateTime>
+-#include <QDebug>
+ #include <QFontMetrics>
+-#include <QLabel>
+ #include <QMessageBox>
+ #include <QPaintEvent>
+ #include <QPainter>
+@@ -150,6 +145,7 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req,
+         QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
+         move(currentScreen->geometry().x(), currentScreen->geometry().y());
+         resize(currentScreen->size());
++// LINUX
+ #else
+ // Call cmake with -DFLAMESHOT_DEBUG_CAPTURE=ON to enable easier debugging
+ #if !defined(FLAMESHOT_DEBUG_CAPTURE)
+@@ -161,6 +157,18 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req,
+         move(desktopGeom.topLeft());
+         resize(desktopGeom.size());
+ #endif
++        // Need to move to the top left screen
++        QPoint topLeft(0, INT_MAX);
++        for (QScreen* const screen : QGuiApplication::screens()) {
++            qreal dpr = screen->devicePixelRatio();
++            QPoint topLeftScreen = screen->geometry().topLeft() / dpr;
++            if (topLeftScreen.x() == 0) {
++                if (topLeftScreen.y() < topLeft.y()) {
++                    topLeft.setY(topLeftScreen.y());
++                }
++            }
++        }
++        move(topLeft);
+ #endif
+     }
+     QVector<QRect> areas;
+@@ -182,6 +190,7 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req,
+         r.moveTo(0, 0);
+         areas.append(r);
+ #else
++        // LINUX & WINDOWS
+         for (QScreen* const screen : QGuiApplication::screens()) {
+             QRect r = screen->geometry();
+             r.moveTo(r.x() / screen->devicePixelRatio(),
+@@ -259,8 +268,15 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req,
+                 OverlayMessage::instance()->update();
+             });
+ 
+-    OverlayMessage::init(this,
+-                         QGuiAppCurrentScreen().currentScreen()->geometry());
++    // Qt6 has only sizes in logical values, position is in physical values.
++    // Move Help message to the logical pixel with devicePixelRatio.
++    QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
++    QRect currentScreenGeometry = currentScreen->geometry();
++    qreal currentScreenDpr = currentScreen->devicePixelRatio();
++    currentScreenGeometry.moveTo(
++      int(currentScreenGeometry.x() / currentScreenDpr),
++      int(currentScreenGeometry.y() / currentScreenDpr));
++    OverlayMessage::init(this, currentScreenGeometry);
+ 
+     if (m_config.showHelp()) {
+         initHelpMessage();

diff --git a/media-gfx/flameshot/flameshot-13.1.0-r1.ebuild 
b/media-gfx/flameshot/flameshot-13.1.0-r1.ebuild
new file mode 100644
index 000000000000..f217f2e0fead
--- /dev/null
+++ b/media-gfx/flameshot/flameshot-13.1.0-r1.ebuild
@@ -0,0 +1,63 @@
+# Copyright 2021-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+QTCW_COMMIT=8491078434b24cba295b5e41cc0d2a94c7049a5b # why ...
+inherit cmake flag-o-matic xdg
+
+DESCRIPTION="Powerful yet simple to use screenshot software"
+HOMEPAGE="https://flameshot.org https://github.com/flameshot-org/flameshot";
+SRC_URI="https://github.com/flameshot-org/flameshot/archive/v${PV}.tar.gz -> 
${P}.tar.gz
+https://gitlab.com/mattbas/Qt-Color-Widgets/-/archive/${QTCW_COMMIT}/${PN}-qtcolorwidgets-${QTCW_COMMIT:0:8}.tar.bz2";
+
+LICENSE="Apache-2.0 Free-Art-1.3 GPL-3+"
+SLOT="0"
+KEYWORDS="~amd64 ~arm64 ~x86"
+IUSE="wayland"
+
+DEPEND="
+       dev-libs/kdsingleapplication
+       dev-qt/qtbase:6[dbus,gui,network,widgets]
+       dev-qt/qtsvg:6
+       sys-apps/dbus
+       wayland? ( kde-frameworks/kguiaddons:6 )
+"
+RDEPEND="${DEPEND}"
+BDEPEND="
+       dev-qt/qttools:6[linguist]
+"
+
+PATCHES=( "${FILESDIR}/${P}-fix-wayland.patch" ) # bug #954005
+
+src_prepare() {
+       # bundles https://gitlab.com/mattbas/Qt-Color-Widgets ...
+       mkdir external || die
+       mv "${WORKDIR}"/Qt-Color-Widgets-${QTCW_COMMIT} 
external/Qt-Color-Widgets || die
+
+       # safety
+       sed -e "s/include(FetchContent)/# & # no we don't/" -i CMakeLists.txt 
|| die
+
+       cmake_src_prepare
+}
+
+src_configure() {
+       # -Werror=strict-aliasing
+       # https://bugs.gentoo.org/859613
+       # https://github.com/flameshot-org/flameshot/issues/3531
+       #
+       # Do not trust with LTO either
+       append-flags -fno-strict-aliasing
+       filter-lto
+
+       local mycmakeargs=(
+               -DENABLE_CACHE=0
+               -DDISABLE_UPDATE_CHECKER=ON
+               -DUSE_KDSINGLEAPPLICATION=ON
+               -DUSE_BUNDLED_KDSINGLEAPPLICATION=OFF
+               -DQTCOLORWIDGETS_BUILD_STATIC_LIBS=ON
+               -DUSE_WAYLAND_CLIPBOARD=$(usex wayland)
+       )
+
+       cmake_src_configure
+}

Reply via email to