File indexing completed on 2024-05-19 15:09:26
0001 /* 0002 SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #include "kwindowsystemproxy.h" 0008 0009 #include <QMetaMethod> 0010 #include <QWindow> 0011 0012 #include <kwindowsystem.h> 0013 0014 KWindowSystemProxy::KWindowSystemProxy(QObject *parent) 0015 : QObject(parent) 0016 , m_initialized(false) 0017 { 0018 } 0019 0020 KWindowSystemProxy::~KWindowSystemProxy() 0021 { 0022 } 0023 0024 void KWindowSystemProxy::connectNotify(const QMetaMethod &signal) 0025 { 0026 if (m_initialized) { 0027 return; 0028 } 0029 0030 if (signal == QMetaMethod::fromSignal(&KWindowSystemProxy::showingDesktopChanged)) { 0031 connect(KWindowSystem::self(), &KWindowSystem::showingDesktopChanged, this, &KWindowSystemProxy::showingDesktopChanged); 0032 m_initialized = true; 0033 } 0034 0035 #if KDECLARATIVE_BUILD_DEPRECATED_SINCE(5, 101) 0036 if (signal == QMetaMethod::fromSignal(&KWindowSystemProxy::currentDesktopChanged) 0037 || signal == QMetaMethod::fromSignal(&KWindowSystemProxy::desktopNamesChanged) 0038 || signal == QMetaMethod::fromSignal(&KWindowSystemProxy::numberOfDesktopsChanged) 0039 || signal == QMetaMethod::fromSignal(&KWindowSystemProxy::compositingActiveChanged)) { 0040 connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged, this, [this](int currentDesktop) { 0041 Q_EMIT currentDesktopChanged(currentDesktop); 0042 Q_EMIT currentDesktopNameChanged(); 0043 }); 0044 0045 connect(KWindowSystem::self(), &KWindowSystem::desktopNamesChanged, this, [this]() { 0046 Q_EMIT desktopNamesChanged(); 0047 Q_EMIT currentDesktopNameChanged(); 0048 }); 0049 0050 connect(KWindowSystem::self(), &KWindowSystem::numberOfDesktopsChanged, this, &KWindowSystemProxy::numberOfDesktopsChanged); 0051 connect(KWindowSystem::self(), &KWindowSystem::compositingChanged, this, &KWindowSystemProxy::compositingActiveChanged); 0052 0053 m_initialized = true; 0054 } 0055 #endif 0056 } 0057 0058 #if KDECLARATIVE_BUILD_DEPRECATED_SINCE(5, 101) 0059 int KWindowSystemProxy::currentDesktop() const 0060 { 0061 return KWindowSystem::currentDesktop(); 0062 } 0063 #endif 0064 0065 #if KDECLARATIVE_BUILD_DEPRECATED_SINCE(5, 101) 0066 void KWindowSystemProxy::setCurrentDesktop(int desktop) 0067 { 0068 KWindowSystem::setCurrentDesktop(desktop); 0069 } 0070 #endif 0071 0072 #if KDECLARATIVE_BUILD_DEPRECATED_SINCE(5, 101) 0073 QString KWindowSystemProxy::currentDesktopName() const 0074 { 0075 return KWindowSystem::desktopName(KWindowSystem::currentDesktop()); 0076 } 0077 #endif 0078 0079 #if KDECLARATIVE_BUILD_DEPRECATED_SINCE(5, 101) 0080 int KWindowSystemProxy::numberOfDesktops() const 0081 { 0082 return KWindowSystem::numberOfDesktops(); 0083 } 0084 #endif 0085 0086 bool KWindowSystemProxy::showingDesktop() const 0087 { 0088 return KWindowSystem::showingDesktop(); 0089 } 0090 0091 void KWindowSystemProxy::setShowingDesktop(bool showingDesktop) 0092 { 0093 KWindowSystem::setShowingDesktop(showingDesktop); 0094 } 0095 0096 bool KWindowSystemProxy::compositingActive() const 0097 { 0098 return KWindowSystem::compositingActive(); 0099 } 0100 0101 bool KWindowSystemProxy::isPlatformX11() const 0102 { 0103 return KWindowSystem::isPlatformX11(); 0104 } 0105 0106 bool KWindowSystemProxy::isPlatformWayland() const 0107 { 0108 return KWindowSystem::isPlatformWayland(); 0109 } 0110 0111 #if KDECLARATIVE_BUILD_DEPRECATED_SINCE(5, 101) 0112 bool KWindowSystemProxy::hasWindow(QWindow *window) const 0113 { 0114 if (!window) { 0115 return false; 0116 } 0117 0118 return KWindowSystem::hasWId(window->winId()); 0119 } 0120 #endif 0121 0122 void KWindowSystemProxy::forceActivateWindow(QWindow *window, long time) 0123 { 0124 if (window) { 0125 KWindowSystem::forceActiveWindow(window->winId(), time); 0126 } 0127 } 0128 0129 #if KDECLARATIVE_BUILD_DEPRECATED_SINCE(5, 101) 0130 void KWindowSystemProxy::setOnAllDesktops(QWindow *window, bool onAllDesktops) 0131 { 0132 if (window) { 0133 KWindowSystem::setOnAllDesktops(window->winId(), onAllDesktops); 0134 } 0135 } 0136 #endif 0137 0138 #if KDECLARATIVE_BUILD_DEPRECATED_SINCE(5, 101) 0139 void KWindowSystemProxy::setOnDesktop(QWindow *window, int desktop) 0140 { 0141 if (window) { 0142 KWindowSystem::setOnDesktop(window->winId(), desktop); 0143 } 0144 } 0145 #endif 0146 0147 #if KDECLARATIVE_BUILD_DEPRECATED_SINCE(5, 101) 0148 void KWindowSystemProxy::setOnActivities(QWindow *window, const QStringList &activities) 0149 { 0150 if (window) { 0151 KWindowSystem::setOnActivities(window->winId(), activities); 0152 } 0153 } 0154 #endif 0155 0156 #if KDECLARATIVE_BUILD_DEPRECATED_SINCE(5, 101) 0157 QString KWindowSystemProxy::desktopName(int desktop) const 0158 { 0159 return KWindowSystem::desktopName(desktop); 0160 } 0161 #endif 0162 0163 #if KDECLARATIVE_BUILD_DEPRECATED_SINCE(5, 101) 0164 void KWindowSystemProxy::setDesktopName(int desktop, const QString &name) 0165 { 0166 KWindowSystem::setDesktopName(desktop, name); 0167 } 0168 #endif 0169 0170 #include "moc_kwindowsystemproxy.cpp"