vcl/qt5/QtFrame.cxx |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

New commits:
commit eb9db0cd2f25a20e0efd756af3e34d4fb09b8e39
Author:     Michael Weghorn <[email protected]>
AuthorDate: Mon Feb 12 14:09:45 2024 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Thu Feb 15 18:33:04 2024 +0100

    tdf#125934 qt: Support module-specific window icons on Wayland
    
    As discussed in QTBUG-77182 [1], Qt currently doesn't provide
    API to directly set the app_id for a single window/toplevel on Wayland,
    but the one set for the application is used when the window gets shown.
    
    Make use of that by temporarily setting the app's desktop file
    name and doing a hide/show cycle in `QtFrame::SetIcon` on
    Wayland.
    
    A big thanks for David Redondo for mentioning that possibility
    in QTBUG-77182!
    
    An alternative would be to use private Qt API and low-level wayland API to
    set the app_id directly, s. discussion in QTBUG-77182.
    
    [1] https://bugreports.qt.io/browse/QTBUG-77182
    
    Change-Id: I2a93cd39756e2ebf55b91486927d73d3896245b3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163249
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>
    (cherry picked from commit 413138c9178d4def463c4844297832b75dcea689)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163273
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 24dcb5ff6f61..6aff814aacd2 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -376,6 +376,20 @@ void QtFrame::SetIcon(sal_uInt16 nIcon)
 
     QIcon aIcon = QIcon::fromTheme(appicon);
     m_pQWidget->window()->setWindowIcon(aIcon);
+
+    if (QGuiApplication::platformName() == "wayland" && 
m_pQWidget->window()->isVisible())
+    {
+        // Qt currently doesn't provide API to directly set the app_id for a 
single
+        // window/toplevel on Wayland, but the one set for the application is 
picked up
+        // on hide/show, so do that.
+        // An alternative would be to use private Qt API and low-level wayland 
API to set the
+        // app_id directly, s. discussion in QTBUG-77182.
+        const QString sOrigDesktopFileName = 
QGuiApplication::desktopFileName();
+        QGuiApplication::setDesktopFileName(appicon);
+        m_pQWidget->window()->hide();
+        m_pQWidget->window()->show();
+        QGuiApplication::setDesktopFileName(sOrigDesktopFileName);
+    }
 }
 
 void QtFrame::SetMenu(SalMenu*) {}

Reply via email to