Update git submodules
[LibreOffice.git] / vcl / qt5 / QtX11Support.cxx
blob84036fb8a565953912ec5adced964484a9ee95d4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <QtX11Support.hxx>
12 #include <config_vclplug.h>
14 #include <QtCore/QVersionNumber>
16 #include <QtInstance.hxx>
17 #include <QtTools.hxx>
19 #if CHECK_QT5_USING_X11
20 #include <QtX11Extras/QX11Info>
21 #endif
23 #include <unx/gensys.h>
25 void QtX11Support::setApplicationID(const xcb_window_t nWinId, std::u16string_view rWMClass)
27 #if CHECK_QT5_USING_X11
28 OString aResClass = OUStringToOString(rWMClass, RTL_TEXTENCODING_ASCII_US);
29 const char* pResClass
30 = !aResClass.isEmpty() ? aResClass.getStr() : SalGenericSystem::getFrameClassName();
31 OString aResName = SalGenericSystem::getFrameResName();
33 // the WM_CLASS data consists of two concatenated cstrings, including the terminating '\0' chars
34 const uint32_t data_len = aResName.getLength() + 1 + strlen(pResClass) + 1;
35 char* data = new char[data_len];
36 memcpy(data, aResName.getStr(), aResName.getLength() + 1);
37 memcpy(data + aResName.getLength() + 1, pResClass, strlen(pResClass) + 1);
39 xcb_change_property(QX11Info::connection(), XCB_PROP_MODE_REPLACE, nWinId, XCB_ATOM_WM_CLASS,
40 XCB_ATOM_STRING, 8, data_len, data);
41 delete[] data;
42 #else
43 Q_UNUSED(nWinId);
44 Q_UNUSED(rWMClass);
45 #endif
48 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */