summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-02-12 14:09:45 +0100
committerAndras Timar <andras.timar@collabora.com>2024-02-16 22:42:20 +0100
commit35cbf1154021f4cb7fa30ae57030672ca57e47e3 (patch)
treeecaba9bae74a3b246f738e6050a36450b4457c7c /vcl
parentc9a575481d7a973ac55b12fff978dee42b28aca3 (diff)
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 <m.weghorn@posteo.de> (cherry picked from commit 413138c9178d4def463c4844297832b75dcea689) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163273 Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qt5/QtFrame.cxx14
1 files changed, 14 insertions, 0 deletions
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*) {}