Warning, file /frameworks/kwindowsystem/src/kwindowinfo.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "kwindowinfo.h" 0008 #include "kwindowinfo_p.h" 0009 #include "kwindowsystem.h" 0010 #include "pluginwrapper_p.h" 0011 0012 #include <config-kwindowsystem.h> 0013 0014 #include "kwindowinfo_dummy_p.h" 0015 0016 #include <QRect> 0017 0018 #if KWINDOWSYSTEM_HAVE_X11 0019 #include "kx11extras.h" 0020 #endif 0021 0022 // private 0023 KWindowInfoPrivate *KWindowInfoPrivate::create(WId window, NET::Properties properties, NET::Properties2 properties2) 0024 { 0025 return KWindowSystemPluginWrapper::self().createWindowInfo(window, properties, properties2); 0026 } 0027 0028 KWindowInfoPrivateDesktopFileNameExtension::KWindowInfoPrivateDesktopFileNameExtension() = default; 0029 KWindowInfoPrivateDesktopFileNameExtension::~KWindowInfoPrivateDesktopFileNameExtension() = default; 0030 0031 KWindowInfoPrivateGtkApplicationIdExtension::KWindowInfoPrivateGtkApplicationIdExtension() = default; 0032 KWindowInfoPrivateGtkApplicationIdExtension::~KWindowInfoPrivateGtkApplicationIdExtension() = default; 0033 0034 KWindowInfoPrivatePidExtension::KWindowInfoPrivatePidExtension() = default; 0035 KWindowInfoPrivatePidExtension::~KWindowInfoPrivatePidExtension() = default; 0036 0037 KWindowInfoPrivateAppMenuExtension::KWindowInfoPrivateAppMenuExtension() = default; 0038 KWindowInfoPrivateAppMenuExtension::~KWindowInfoPrivateAppMenuExtension() = default; 0039 0040 class Q_DECL_HIDDEN KWindowInfoPrivate::Private 0041 { 0042 public: 0043 Private(WId window, NET::Properties properties, NET::Properties2 properties2); 0044 WId window; 0045 NET::Properties properties; 0046 NET::Properties2 properties2; 0047 KWindowInfoPrivateDesktopFileNameExtension *desktopFileNameExtension; 0048 KWindowInfoPrivateGtkApplicationIdExtension *gtkApplicationIdExtension; 0049 KWindowInfoPrivatePidExtension *pidExtension; 0050 KWindowInfoPrivateAppMenuExtension *appMenuExtension; 0051 }; 0052 0053 KWindowInfoPrivate::Private::Private(WId window, NET::Properties properties, NET::Properties2 properties2) 0054 : window(window) 0055 , properties(properties) 0056 , properties2(properties2) 0057 , desktopFileNameExtension(nullptr) 0058 , gtkApplicationIdExtension(nullptr) 0059 , pidExtension(nullptr) 0060 , appMenuExtension(nullptr) 0061 { 0062 } 0063 0064 KWindowInfoPrivate::KWindowInfoPrivate(WId window, NET::Properties properties, NET::Properties2 properties2) 0065 : d(new Private(window, properties, properties2)) 0066 { 0067 } 0068 0069 KWindowInfoPrivate::~KWindowInfoPrivate() 0070 { 0071 } 0072 0073 WId KWindowInfoPrivate::win() const 0074 { 0075 return d->window; 0076 } 0077 0078 KWindowInfoPrivateDesktopFileNameExtension *KWindowInfoPrivate::desktopFileNameExtension() const 0079 { 0080 return d->desktopFileNameExtension; 0081 } 0082 0083 void KWindowInfoPrivate::installDesktopFileNameExtension(KWindowInfoPrivateDesktopFileNameExtension *extension) 0084 { 0085 d->desktopFileNameExtension = extension; 0086 } 0087 0088 KWindowInfoPrivateGtkApplicationIdExtension *KWindowInfoPrivate::gtkApplicationIdExtension() const 0089 { 0090 return d->gtkApplicationIdExtension; 0091 } 0092 0093 void KWindowInfoPrivate::installGtkApplicationIdExtension(KWindowInfoPrivateGtkApplicationIdExtension *extension) 0094 { 0095 d->gtkApplicationIdExtension = extension; 0096 } 0097 0098 KWindowInfoPrivatePidExtension *KWindowInfoPrivate::pidExtension() const 0099 { 0100 return d->pidExtension; 0101 } 0102 0103 void KWindowInfoPrivate::installPidExtension(KWindowInfoPrivatePidExtension *extension) 0104 { 0105 d->pidExtension = extension; 0106 } 0107 0108 KWindowInfoPrivateAppMenuExtension *KWindowInfoPrivate::appMenuExtension() const 0109 { 0110 return d->appMenuExtension; 0111 } 0112 0113 void KWindowInfoPrivate::installAppMenuExtension(KWindowInfoPrivateAppMenuExtension *extension) 0114 { 0115 d->appMenuExtension = extension; 0116 } 0117 0118 KWindowInfoPrivateDummy::KWindowInfoPrivateDummy(WId window, NET::Properties properties, NET::Properties2 properties2) 0119 : KWindowInfoPrivate(window, properties, properties2) 0120 { 0121 } 0122 0123 KWindowInfoPrivateDummy::~KWindowInfoPrivateDummy() 0124 { 0125 } 0126 0127 bool KWindowInfoPrivateDummy::valid(bool withdrawn_is_valid) const 0128 { 0129 Q_UNUSED(withdrawn_is_valid) 0130 return false; 0131 } 0132 0133 NET::States KWindowInfoPrivateDummy::state() const 0134 { 0135 return NET::States(); 0136 } 0137 0138 bool KWindowInfoPrivateDummy::isMinimized() const 0139 { 0140 return false; 0141 } 0142 0143 NET::MappingState KWindowInfoPrivateDummy::mappingState() const 0144 { 0145 return NET::Visible; 0146 } 0147 0148 NETExtendedStrut KWindowInfoPrivateDummy::extendedStrut() const 0149 { 0150 return NETExtendedStrut(); 0151 } 0152 0153 NET::WindowType KWindowInfoPrivateDummy::windowType(NET::WindowTypes supported_types) const 0154 { 0155 Q_UNUSED(supported_types) 0156 return NET::Unknown; 0157 } 0158 0159 QString KWindowInfoPrivateDummy::visibleName() const 0160 { 0161 return QString(); 0162 } 0163 0164 QString KWindowInfoPrivateDummy::visibleNameWithState() const 0165 { 0166 return QString(); 0167 } 0168 0169 QString KWindowInfoPrivateDummy::name() const 0170 { 0171 return QString(); 0172 } 0173 0174 QString KWindowInfoPrivateDummy::visibleIconName() const 0175 { 0176 return QString(); 0177 } 0178 0179 QString KWindowInfoPrivateDummy::visibleIconNameWithState() const 0180 { 0181 return QString(); 0182 } 0183 0184 QString KWindowInfoPrivateDummy::iconName() const 0185 { 0186 return QString(); 0187 } 0188 0189 bool KWindowInfoPrivateDummy::onAllDesktops() const 0190 { 0191 return false; 0192 } 0193 0194 bool KWindowInfoPrivateDummy::isOnDesktop(int desktop) const 0195 { 0196 Q_UNUSED(desktop) 0197 return false; 0198 } 0199 0200 int KWindowInfoPrivateDummy::desktop() const 0201 { 0202 return 0; 0203 } 0204 0205 QStringList KWindowInfoPrivateDummy::activities() const 0206 { 0207 return QStringList(); 0208 } 0209 0210 QRect KWindowInfoPrivateDummy::geometry() const 0211 { 0212 return QRect(); 0213 } 0214 0215 QRect KWindowInfoPrivateDummy::frameGeometry() const 0216 { 0217 return QRect(); 0218 } 0219 0220 WId KWindowInfoPrivateDummy::transientFor() const 0221 { 0222 return 0; 0223 } 0224 0225 WId KWindowInfoPrivateDummy::groupLeader() const 0226 { 0227 return 0; 0228 } 0229 0230 QByteArray KWindowInfoPrivateDummy::windowClassClass() const 0231 { 0232 return QByteArray(); 0233 } 0234 0235 QByteArray KWindowInfoPrivateDummy::windowClassName() const 0236 { 0237 return QByteArray(); 0238 } 0239 0240 QByteArray KWindowInfoPrivateDummy::windowRole() const 0241 { 0242 return QByteArray(); 0243 } 0244 0245 QByteArray KWindowInfoPrivateDummy::clientMachine() const 0246 { 0247 return QByteArray(); 0248 } 0249 0250 bool KWindowInfoPrivateDummy::actionSupported(NET::Action action) const 0251 { 0252 Q_UNUSED(action) 0253 return false; 0254 } 0255 0256 // public 0257 KWindowInfo::KWindowInfo(WId window, NET::Properties properties, NET::Properties2 properties2) 0258 : d(KWindowInfoPrivate::create(window, properties, properties2)) 0259 { 0260 } 0261 0262 KWindowInfo::KWindowInfo(const KWindowInfo &other) 0263 : d(other.d) 0264 { 0265 } 0266 0267 KWindowInfo::~KWindowInfo() 0268 { 0269 } 0270 0271 KWindowInfo &KWindowInfo::operator=(const KWindowInfo &other) 0272 { 0273 if (d != other.d) { 0274 d = other.d; 0275 } 0276 return *this; 0277 } 0278 0279 // clang-format off 0280 0281 #define DELEGATE(name, args) \ 0282 return d->name(args); 0283 0284 bool KWindowInfo::valid(bool withdrawn_is_valid) const 0285 { 0286 DELEGATE(valid, withdrawn_is_valid) 0287 } 0288 0289 WId KWindowInfo::win() const 0290 { 0291 return d->win(); 0292 } 0293 0294 NET::States KWindowInfo::state() const 0295 { 0296 DELEGATE(state, ) 0297 } 0298 0299 bool KWindowInfo::hasState(NET::States s) const 0300 { 0301 return (state() & s) == s; 0302 } 0303 0304 bool KWindowInfo::isMinimized() const 0305 { 0306 DELEGATE(isMinimized, ) 0307 } 0308 0309 NET::MappingState KWindowInfo::mappingState() const 0310 { 0311 DELEGATE(mappingState, ) 0312 } 0313 0314 NETExtendedStrut KWindowInfo::extendedStrut() const 0315 { 0316 DELEGATE(extendedStrut, ) 0317 } 0318 0319 NET::WindowType KWindowInfo::windowType(NET::WindowTypes supported_types) const 0320 { 0321 DELEGATE(windowType, supported_types) 0322 } 0323 0324 QString KWindowInfo::visibleName() const 0325 { 0326 DELEGATE(visibleName, ) 0327 } 0328 0329 QString KWindowInfo::visibleNameWithState() const 0330 { 0331 DELEGATE(visibleNameWithState, ) 0332 } 0333 0334 QString KWindowInfo::name() const 0335 { 0336 DELEGATE(name, ) 0337 } 0338 0339 QString KWindowInfo::visibleIconName() const 0340 { 0341 DELEGATE(visibleIconName, ) 0342 } 0343 0344 QString KWindowInfo::visibleIconNameWithState() const 0345 { 0346 DELEGATE(visibleIconNameWithState, ) 0347 } 0348 0349 QString KWindowInfo::iconName() const 0350 { 0351 DELEGATE(iconName, ) 0352 } 0353 0354 bool KWindowInfo::isOnCurrentDesktop() const 0355 { 0356 #if KWINDOWSYSTEM_HAVE_X11 0357 return isOnDesktop(KX11Extras::currentDesktop()); 0358 #else 0359 return true; 0360 #endif 0361 } 0362 0363 bool KWindowInfo::isOnDesktop(int desktop) const 0364 { 0365 DELEGATE(isOnDesktop, desktop) 0366 } 0367 0368 bool KWindowInfo::onAllDesktops() const 0369 { 0370 DELEGATE(onAllDesktops, ) 0371 } 0372 0373 int KWindowInfo::desktop() const 0374 { 0375 DELEGATE(desktop, ) 0376 } 0377 0378 QStringList KWindowInfo::activities() const 0379 { 0380 DELEGATE(activities, ) 0381 } 0382 0383 QRect KWindowInfo::geometry() const 0384 { 0385 DELEGATE(geometry, ) 0386 } 0387 0388 QRect KWindowInfo::frameGeometry() const 0389 { 0390 DELEGATE(frameGeometry, ) 0391 } 0392 0393 WId KWindowInfo::transientFor() const 0394 { 0395 DELEGATE(transientFor, ) 0396 } 0397 0398 WId KWindowInfo::groupLeader() const 0399 { 0400 DELEGATE(groupLeader, ) 0401 } 0402 0403 QByteArray KWindowInfo::windowClassClass() const 0404 { 0405 DELEGATE(windowClassClass, ) 0406 } 0407 0408 QByteArray KWindowInfo::windowClassName() const 0409 { 0410 DELEGATE(windowClassName, ) 0411 } 0412 0413 QByteArray KWindowInfo::windowRole() const 0414 { 0415 DELEGATE(windowRole, ) 0416 } 0417 0418 QByteArray KWindowInfo::clientMachine() const 0419 { 0420 DELEGATE(clientMachine, ) 0421 } 0422 0423 bool KWindowInfo::actionSupported(NET::Action action) const 0424 { 0425 DELEGATE(actionSupported, action) 0426 } 0427 0428 QByteArray KWindowInfo::desktopFileName() const 0429 { 0430 if (auto extension = d->desktopFileNameExtension()) { 0431 return extension->desktopFileName(); 0432 } 0433 return QByteArray(); 0434 } 0435 0436 QByteArray KWindowInfo::gtkApplicationId() const 0437 { 0438 if (auto extension = d->gtkApplicationIdExtension()) { 0439 return extension->gtkApplicationId(); 0440 } 0441 return QByteArray(); 0442 } 0443 0444 QByteArray KWindowInfo::applicationMenuServiceName() const 0445 { 0446 if (auto extension = d->appMenuExtension()) { 0447 return extension->applicationMenuServiceName(); 0448 } 0449 return QByteArray(); 0450 } 0451 0452 QByteArray KWindowInfo::applicationMenuObjectPath() const 0453 { 0454 if (auto extension = d->appMenuExtension()) { 0455 return extension->applicationMenuObjectPath(); 0456 } 0457 return QByteArray(); 0458 } 0459 0460 int KWindowInfo::pid() const 0461 { 0462 if (auto extension = d->pidExtension()) { 0463 return extension->pid(); 0464 } 0465 return 0; 0466 } 0467 0468 #undef DELEGATE