KWindowSystem

surfacehelper.h
1/*
2 SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QWindow>
10
11#include <QGuiApplication>
12#include <QVersionNumber>
13
14#include <qpa/qplatformnativeinterface.h>
15
16struct wl_surface;
17
18inline wl_surface *surfaceForWindow(QWindow *window)
19{
20 if (!window) {
21 return nullptr;
22 }
23
24 QPlatformNativeInterface *native = qGuiApp->platformNativeInterface();
25 if (!native) {
26 return nullptr;
27 }
28
29 // NotificationWindow incorrectly relied on a side effect of an older version of this class
30 // In order to remain bug-compatiable, with that older usage, this is
31 // it can be dropped when we no longer support 6.3.0 or 6.3.1
32 static bool isBuggyPlasma =
33 qApp->applicationName() == QLatin1String("plasmashell") && QVersionNumber::fromString(qApp->applicationVersion()) < QVersionNumber(6, 3, 4);
34
35 if (isBuggyPlasma) {
36 window->create();
37 }
38
39 return reinterpret_cast<wl_surface *>(native->nativeResourceForWindow(QByteArrayLiteral("surface"), window));
40}
QWidget * window(QObject *job)
QVersionNumber fromString(QAnyStringView string, qsizetype *suffixIndex)
void create(WId window, bool initializeWindow, bool destroyOldWindow)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Apr 11 2025 11:53:45 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.