diff --git a/autotests/integration/desktop_window_x11_test.cpp b/autotests/integration/desktop_window_x11_test.cpp index 5eec15d123..047b96e1cf 100644 --- a/autotests/integration/desktop_window_x11_test.cpp +++ b/autotests/integration/desktop_window_x11_test.cpp @@ -131,7 +131,7 @@ void X11DesktopWindowTest::testDesktopWindow() QVERIFY(window); QCOMPARE(window->window(), windowId); QVERIFY(!window->isDecorated()); - QCOMPARE(window->windowType(), NET::Desktop); + QCOMPARE(window->windowType(), WindowType::Desktop); QCOMPARE(window->frameGeometry(), windowGeometry); QVERIFY(window->isDesktop()); QCOMPARE(window->depth(), 24); diff --git a/autotests/integration/plasma_surface_test.cpp b/autotests/integration/plasma_surface_test.cpp index 10f242da82..f0f4c24e9d 100644 --- a/autotests/integration/plasma_surface_test.cpp +++ b/autotests/integration/plasma_surface_test.cpp @@ -185,7 +185,7 @@ void PlasmaSurfaceTest::testOSDPlacement() auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue); QVERIFY(window); - QCOMPARE(window->windowType(), NET::OnScreenDisplay); + QCOMPARE(window->windowType(), WindowType::OnScreenDisplay); QVERIFY(window->isOnScreenDisplay()); QCOMPARE(window->frameGeometry(), QRect(1280 / 2 - 100 / 2, 2 * 1024 / 3 - 50 / 2, 100, 50)); @@ -224,7 +224,7 @@ void PlasmaSurfaceTest::testOSDPlacementManualPosition() QVERIFY(window); QVERIFY(!window->isPlaceable()); - QCOMPARE(window->windowType(), NET::OnScreenDisplay); + QCOMPARE(window->windowType(), WindowType::OnScreenDisplay); QVERIFY(window->isOnScreenDisplay()); QCOMPARE(window->frameGeometry(), QRect(50, 70, 100, 50)); } @@ -253,7 +253,7 @@ void PlasmaSurfaceTest::testPanelActivate() auto panel = Test::renderAndWaitForShown(surface.get(), QSize(100, 200), Qt::blue); QVERIFY(panel); - QCOMPARE(panel->windowType(), NET::Dock); + QCOMPARE(panel->windowType(), WindowType::Dock); QVERIFY(panel->isDock()); QFETCH(bool, active); QCOMPARE(panel->dockWantsInput(), active); diff --git a/autotests/integration/struts_test.cpp b/autotests/integration/struts_test.cpp index fc558eca9a..9eb58fcbfb 100644 --- a/autotests/integration/struts_test.cpp +++ b/autotests/integration/struts_test.cpp @@ -367,7 +367,7 @@ void StrutsTest::testX11Struts() QVERIFY(window); QCOMPARE(window->window(), windowId); QVERIFY(!window->isDecorated()); - QCOMPARE(window->windowType(), NET::Dock); + QCOMPARE(window->windowType(), WindowType::Dock); QCOMPARE(window->frameGeometry(), windowGeometry); // this should have affected the client area @@ -479,7 +479,7 @@ void StrutsTest::test363804() QVERIFY(window); QCOMPARE(window->window(), windowId); QVERIFY(!window->isDecorated()); - QCOMPARE(window->windowType(), NET::Dock); + QCOMPARE(window->windowType(), WindowType::Dock); QCOMPARE(window->frameGeometry(), windowGeometry); // now verify the actual updated client areas @@ -557,7 +557,7 @@ void StrutsTest::testLeftScreenSmallerBottomAligned() QVERIFY(window); QCOMPARE(window->window(), windowId); QVERIFY(!window->isDecorated()); - QCOMPARE(window->windowType(), NET::Dock); + QCOMPARE(window->windowType(), WindowType::Dock); QCOMPARE(window->frameGeometry(), windowGeometry); // now verify the actual updated client areas @@ -638,7 +638,7 @@ void StrutsTest::testWindowMoveWithPanelBetweenScreens() QVERIFY(window); QCOMPARE(window->window(), windowId); QVERIFY(!window->isDecorated()); - QCOMPARE(window->windowType(), NET::Dock); + QCOMPARE(window->windowType(), WindowType::Dock); QCOMPARE(window->frameGeometry(), windowGeometry); // now verify the actual updated client areas diff --git a/autotests/integration/transient_placement.cpp b/autotests/integration/transient_placement.cpp index 4787d0b8ea..18764b1847 100644 --- a/autotests/integration/transient_placement.cpp +++ b/autotests/integration/transient_placement.cpp @@ -480,7 +480,7 @@ void TransientPlacementTest::testXdgPopupWithPanel() QVERIFY(dockConfigureRequestedSpy.wait()); auto dock = Test::renderAndWaitForShown(dockSurface.get(), dockConfigureRequestedSpy.last().at(1).toSize(), Qt::blue); QVERIFY(dock); - QCOMPARE(dock->windowType(), NET::Dock); + QCOMPARE(dock->windowType(), WindowType::Dock); QVERIFY(dock->isDock()); QCOMPARE(dock->frameGeometry(), QRect(0, output->geometry().height() - 50, 1280, 50)); QCOMPARE(dock->hasStrut(), true); diff --git a/src/dbusinterface.cpp b/src/dbusinterface.cpp index 8545c63100..06aa8252e8 100644 --- a/src/dbusinterface.cpp +++ b/src/dbusinterface.cpp @@ -159,7 +159,7 @@ QVariantMap clientToVariantMap(const Window *c) {QStringLiteral("caption"), c->captionNormal()}, {QStringLiteral("clientMachine"), c->wmClientMachine(true)}, {QStringLiteral("localhost"), c->isLocalhost()}, - {QStringLiteral("type"), c->windowType()}, + {QStringLiteral("type"), int(c->windowType())}, {QStringLiteral("x"), c->x()}, {QStringLiteral("y"), c->y()}, {QStringLiteral("width"), c->width()}, diff --git a/src/effect/effecthandler.h b/src/effect/effecthandler.h index f3a2c1ef14..dc7a4483aa 100644 --- a/src/effect/effecthandler.h +++ b/src/effect/effecthandler.h @@ -27,10 +27,10 @@ #include #include -#include - #include +#include + class KConfigGroup; class QFont; class QKeyEvent; diff --git a/src/effect/effectwindow.cpp b/src/effect/effectwindow.cpp index e6a57629ca..78425b2bc2 100644 --- a/src/effect/effectwindow.cpp +++ b/src/effect/effectwindow.cpp @@ -321,7 +321,7 @@ QRectF EffectWindow::contentsRect() const return d->m_window->clientGeometry().translated(-d->m_window->bufferGeometry().topLeft()); } -NET::WindowType EffectWindow::windowType() const +WindowType EffectWindow::windowType() const { return d->m_window->windowType(); } diff --git a/src/effect/effectwindow.h b/src/effect/effectwindow.h index 12878f1388..a61a221574 100644 --- a/src/effect/effectwindow.h +++ b/src/effect/effectwindow.h @@ -11,7 +11,7 @@ #include "kwin_export.h" -#include +#include "globals.h" #include @@ -146,7 +146,7 @@ class KWIN_EXPORT EffectWindow : public QObject * Returns the NETWM window type * See https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - Q_PROPERTY(int windowType READ windowType) + Q_PROPERTY(int windowType READ windowTypeInt) /** * Whether this EffectWindow is managed by KWin (it has control over its placement and other * aspects, as opposed to override-redirect windows that are entirely handled by the application). @@ -540,7 +540,11 @@ public: * Returns the NETWM window type * See https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - NET::WindowType windowType() const; + WindowType windowType() const; + int windowTypeInt() const + { + return int(windowType()); + } /** * Returns whether the window is managed by KWin (it has control over its placement and other * aspects, as opposed to override-redirect windows that are entirely handled by the application). diff --git a/src/effect/globals.h b/src/effect/globals.h index 6edf691945..30c5bd993b 100644 --- a/src/effect/globals.h +++ b/src/effect/globals.h @@ -302,6 +302,130 @@ enum class PresentationModeHint { }; Q_ENUM_NS(PresentationModeHint); +// For now, keep in sync with NETWM::WindowType from KWindowSystem +enum class WindowType { + /** + * intermediate value, do not use + */ + Undefined = -2, + /** + * indicates that the window did not define a window type. + */ + Unknown = -1, + /** + * indicates that this is a normal, top-level window + */ + Normal = 0, + /** + * indicates a desktop feature. This can include a single window + * containing desktop icons with the same dimensions as the screen, allowing + * the desktop environment to have full control of the desktop, without the + * need for proxying root window clicks. + */ + Desktop = 1, + /** + * indicates a dock or panel feature + */ + Dock = 2, + /** + * indicates a toolbar window + */ + Toolbar = 3, + /** + * indicates a pinnable (torn-off) menu window + */ + Menu = 4, + /** + * indicates that this is a dialog window + */ + Dialog = 5, + // cannot deprecate to compiler: used both by clients & manager, later needs to keep supporting it for now + // KF6: remove + /** + * @deprecated has unclear meaning and is KDE-only + */ + Override = 6, // NON STANDARD + /** + * indicates a toplevel menu (AKA macmenu). This is a KDE extension to the + * _NET_WM_WINDOW_TYPE mechanism. + */ + TopMenu = 7, // NON STANDARD + /** + * indicates a utility window + */ + Utility = 8, + /** + * indicates that this window is a splash screen window. + */ + Splash = 9, + /** + * indicates a dropdown menu (from a menubar typically) + */ + DropdownMenu = 10, + /** + * indicates a popup menu (a context menu typically) + */ + PopupMenu = 11, + /** + * indicates a tooltip window + */ + Tooltip = 12, + /** + * indicates a notification window + */ + Notification = 13, + /** + * indicates that the window is a list for a combobox + */ + ComboBox = 14, + /** + * indicates a window that represents the dragged object during DND operation + */ + DNDIcon = 15, + /** + * indicates an On Screen Display window (such as volume feedback) + */ + OnScreenDisplay = 16, // NON STANDARD + /** + * indicates a critical notification (such as battery is running out) + */ + CriticalNotification = 17, // NON STANDARD + /** + * indicates that this window is an applet. + */ + AppletPopup = 18, // NON STANDARD +}; +Q_ENUM_NS(WindowType); + +/** + * Values for WindowType when they should be OR'ed together, e.g. + * for the properties argument of the NETRootInfo constructor. + * @see WindowTypes + */ +enum WindowTypeMask { + NormalMask = 1u << 0, ///< @see Normal + DesktopMask = 1u << 1, ///< @see Desktop + DockMask = 1u << 2, ///< @see Dock + ToolbarMask = 1u << 3, ///< @see Toolbar + MenuMask = 1u << 4, ///< @see Menu + DialogMask = 1u << 5, ///< @see Dialog + OverrideMask = 1u << 6, ///< @see Override + TopMenuMask = 1u << 7, ///< @see TopMenu + UtilityMask = 1u << 8, ///< @see Utility + SplashMask = 1u << 9, ///< @see Splash + DropdownMenuMask = 1u << 10, ///< @see DropdownMenu + PopupMenuMask = 1u << 11, ///< @see PopupMenu + TooltipMask = 1u << 12, ///< @see Tooltip + NotificationMask = 1u << 13, ///< @see Notification + ComboBoxMask = 1u << 14, ///< @see ComboBox + DNDIconMask = 1u << 15, ///< @see DNDIcon + OnScreenDisplayMask = 1u << 16, ///< NON STANDARD @see OnScreenDisplay @since 5.6 + CriticalNotificationMask = 1u << 17, ///< NON STANDARD @see CriticalNotification @since 5.58 + AppletPopupMask = 1u << 18, ///< NON STANDARD @see AppletPopup + AllTypesMask = 0U - 1, ///< All window types. +}; +Q_DECLARE_FLAGS(WindowTypes, WindowTypeMask) + } // namespace Q_DECLARE_METATYPE(std::chrono::nanoseconds) diff --git a/src/inputpanelv1window.cpp b/src/inputpanelv1window.cpp index 79d4c8eeb9..b7b4d42f1b 100644 --- a/src/inputpanelv1window.cpp +++ b/src/inputpanelv1window.cpp @@ -171,9 +171,9 @@ void InputPanelV1Window::destroyWindow() unref(); } -NET::WindowType InputPanelV1Window::windowType() const +WindowType InputPanelV1Window::windowType() const { - return NET::Utility; + return WindowType::Utility; } QRectF InputPanelV1Window::frameRectToBufferRect(const QRectF &rect) const diff --git a/src/inputpanelv1window.h b/src/inputpanelv1window.h index 0c119fd20f..40c795323f 100644 --- a/src/inputpanelv1window.h +++ b/src/inputpanelv1window.h @@ -70,7 +70,7 @@ public: { return true; } - NET::WindowType windowType() const override; + WindowType windowType() const override; QRectF frameRectToBufferRect(const QRectF &rect) const override; Mode mode() const diff --git a/src/internalwindow.cpp b/src/internalwindow.cpp index 8159c4086b..f19334db49 100644 --- a/src/internalwindow.cpp +++ b/src/internalwindow.cpp @@ -145,9 +145,9 @@ QSizeF InternalWindow::maxSize() const return m_handle->maximumSize(); } -NET::WindowType InternalWindow::windowType() const +WindowType InternalWindow::windowType() const { - return NET::Normal; + return WindowType::Normal; } void InternalWindow::killWindow() diff --git a/src/internalwindow.h b/src/internalwindow.h index 023f8586a5..cec372e650 100644 --- a/src/internalwindow.h +++ b/src/internalwindow.h @@ -36,7 +36,7 @@ public: QString captionSuffix() const override; QSizeF minSize() const override; QSizeF maxSize() const override; - NET::WindowType windowType() const override; + WindowType windowType() const override; void killWindow() override; bool isClient() const override; bool isPopupWindow() const override; diff --git a/src/kcms/rules/kcmrules.cpp b/src/kcms/rules/kcmrules.cpp index b794a06a9f..51624784f8 100644 --- a/src/kcms/rules/kcmrules.cpp +++ b/src/kcms/rules/kcmrules.cpp @@ -312,7 +312,7 @@ QModelIndex KCMKWinRules::findRuleWithProperties(const QVariantMap &info, bool w const QString wmclass_class = info.value("resourceClass").toString(); const QString wmclass_name = info.value("resourceName").toString(); const QString role = info.value("role").toString(); - const NET::WindowType type = static_cast(info.value("type").toInt()); + const WindowType type = static_cast(info.value("type").toInt()); const QString title = info.value("caption").toString(); const QString machine = info.value("clientMachine").toString(); const bool isLocalHost = info.value("localhost").toBool(); diff --git a/src/layershellv1window.cpp b/src/layershellv1window.cpp index 80378e9122..c628b1ccac 100644 --- a/src/layershellv1window.cpp +++ b/src/layershellv1window.cpp @@ -18,20 +18,20 @@ namespace KWin { -static NET::WindowType scopeToType(const QString &scope) +static WindowType scopeToType(const QString &scope) { - static const QHash scopeToType{ - {QStringLiteral("desktop"), NET::Desktop}, - {QStringLiteral("dock"), NET::Dock}, - {QStringLiteral("crititical-notification"), NET::CriticalNotification}, - {QStringLiteral("notification"), NET::Notification}, - {QStringLiteral("tooltip"), NET::Tooltip}, - {QStringLiteral("on-screen-display"), NET::OnScreenDisplay}, - {QStringLiteral("dialog"), NET::Dialog}, - {QStringLiteral("splash"), NET::Splash}, - {QStringLiteral("utility"), NET::Utility}, + static const QHash scopeToType{ + {QStringLiteral("desktop"), WindowType::Desktop}, + {QStringLiteral("dock"), WindowType::Dock}, + {QStringLiteral("crititical-notification"), WindowType::CriticalNotification}, + {QStringLiteral("notification"), WindowType::Notification}, + {QStringLiteral("tooltip"), WindowType::Tooltip}, + {QStringLiteral("on-screen-display"), WindowType::OnScreenDisplay}, + {QStringLiteral("dialog"), WindowType::Dialog}, + {QStringLiteral("splash"), WindowType::Splash}, + {QStringLiteral("utility"), WindowType::Utility}, }; - return scopeToType.value(scope.toLower(), NET::Normal); + return scopeToType.value(scope.toLower(), WindowType::Normal); } LayerShellV1Window::LayerShellV1Window(LayerSurfaceV1Interface *shellSurface, @@ -93,7 +93,7 @@ void LayerShellV1Window::scheduleRearrange() m_integration->scheduleRearrange(); } -NET::WindowType LayerShellV1Window::windowType() const +WindowType LayerShellV1Window::windowType() const { return m_windowType; } diff --git a/src/layershellv1window.h b/src/layershellv1window.h index 6a36a477c9..37620b7c4e 100644 --- a/src/layershellv1window.h +++ b/src/layershellv1window.h @@ -28,7 +28,7 @@ public: LayerSurfaceV1Interface *shellSurface() const; Output *desiredOutput() const; - NET::WindowType windowType() const override; + WindowType windowType() const override; bool isPlaceable() const override; bool isCloseable() const override; bool isMovable() const override; @@ -68,7 +68,7 @@ private: LayerSurfaceV1Interface *m_shellSurface; QPointer m_screenEdge; bool m_screenEdgeActive = false; - NET::WindowType m_windowType; + WindowType m_windowType; }; } // namespace KWin diff --git a/src/rules.cpp b/src/rules.cpp index d58689a1ce..c94fbb507c 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -107,7 +107,7 @@ void Rules::readFromSettings(const RuleSettings *settings) READ_MATCH_STRING(windowrole, ); READ_MATCH_STRING(title, ); READ_MATCH_STRING(clientmachine, .toLower()); - types = NET::WindowTypeMask(settings->types()); + types = WindowTypes(settings->types()); READ_FORCE_RULE(placement, ); READ_SET_RULE(position); READ_SET_RULE(size); @@ -304,13 +304,49 @@ QString Rules::getDecoColor(const QString &themeName) QLatin1String("color-schemes/") + themeName + QLatin1String(".colors")); } -bool Rules::matchType(NET::WindowType match_type) const +bool typeMatchesMask(WindowType type, WindowTypes mask) { - if (types != NET::AllTypesMask) { - if (match_type == NET::Unknown) { - match_type = NET::Normal; // NET::Unknown->NET::Normal is only here for matching + switch (type) { + // clang-format off +#define CHECK_TYPE_MASK( type ) \ +case WindowType:: type: \ + if( int(mask) & int(type##Mask) ) \ + return true; \ + break; + // clang-format on + CHECK_TYPE_MASK(Normal) + CHECK_TYPE_MASK(Desktop) + CHECK_TYPE_MASK(Dock) + CHECK_TYPE_MASK(Toolbar) + CHECK_TYPE_MASK(Menu) + CHECK_TYPE_MASK(Dialog) + CHECK_TYPE_MASK(Override) + CHECK_TYPE_MASK(TopMenu) + CHECK_TYPE_MASK(Utility) + CHECK_TYPE_MASK(Splash) + CHECK_TYPE_MASK(DropdownMenu) + CHECK_TYPE_MASK(PopupMenu) + CHECK_TYPE_MASK(Tooltip) + CHECK_TYPE_MASK(Notification) + CHECK_TYPE_MASK(ComboBox) + CHECK_TYPE_MASK(DNDIcon) + CHECK_TYPE_MASK(OnScreenDisplay) + CHECK_TYPE_MASK(CriticalNotification) + CHECK_TYPE_MASK(AppletPopup) +#undef CHECK_TYPE_MASK + default: + break; + } + return false; +} + +bool Rules::matchType(WindowType match_type) const +{ + if (types != AllTypesMask) { + if (match_type == WindowType::Unknown) { + match_type = WindowType::Normal; // WindowType::Unknown->WindowType::Normal is only here for matching } - if (!NET::typeMatchesMask(match_type, types)) { + if (!typeMatchesMask(match_type, types)) { return false; } } diff --git a/src/rules.h b/src/rules.h index c18c8701d0..9e86f71bee 100644 --- a/src/rules.h +++ b/src/rules.h @@ -11,7 +11,6 @@ #include #include -#include #include "options.h" #include "utils/common.h" @@ -190,7 +189,7 @@ public: private: #endif - bool matchType(NET::WindowType match_type) const; + bool matchType(WindowType match_type) const; bool matchWMClass(const QString &match_class, const QString &match_name) const; bool matchRole(const QString &match_role) const; bool matchTitle(const QString &match_title) const; @@ -219,7 +218,7 @@ private: StringMatch titlematch; QString clientmachine; StringMatch clientmachinematch; - NET::WindowTypes types; // types for matching + WindowTypes types; // types for matching PlacementPolicy placement; ForceRule placementrule; QPoint position; diff --git a/src/sm.cpp b/src/sm.cpp index 9c7da6323f..22ce33e0eb 100644 --- a/src/sm.cpp +++ b/src/sm.cpp @@ -59,28 +59,26 @@ static const char *const window_type_names[] = { "Override", "TopMenu", "Utility", "Splash"}; // change also the two functions below when adding new entries -static const char *windowTypeToTxt(NET::WindowType type) +static const char *windowTypeToTxt(WindowType type) { - if (type >= NET::Unknown && type <= NET::Splash) { - return window_type_names[type + 1]; // +1 (unknown==-1) + if (type >= WindowType::Unknown && type <= WindowType::Splash) { + return window_type_names[int(type) + 1]; // +1 (unknown==-1) } - if (type == -2) { // undefined (not really part of NET::WindowType) + if (type == WindowType::Undefined) { // undefined (not really part of WindowType) return "Undefined"; } qFatal("Unknown Window Type"); return nullptr; } -static NET::WindowType txtToWindowType(const char *txt) +static WindowType txtToWindowType(const char *txt) { - for (int i = NET::Unknown; - i <= NET::Splash; - ++i) { + for (int i = int(WindowType::Unknown); i <= int(WindowType::Splash); ++i) { if (qstrcmp(txt, window_type_names[i + 1]) == 0) { // +1 - return static_cast(i); + return static_cast(i); } } - return static_cast(-2); // undefined + return WindowType::Undefined; } /** @@ -103,7 +101,7 @@ void SessionManager::storeSession(const QString &sessionName, SMSavePhase phase) if (!c || c->isUnmanaged()) { continue; } - if (c->windowType() > NET::Splash) { + if (c->windowType() > WindowType::Splash) { // window types outside this are not tooltips/menus/OSDs // typically these will be unmanaged and not in this list anyway, but that is not enforced continue; @@ -192,7 +190,7 @@ void SessionManager::storeSubSession(const QString &name, QSet sessi if (!c || c->isUnmanaged()) { continue; } - if (c->windowType() > NET::Splash) { + if (c->windowType() > WindowType::Splash) { continue; } QByteArray sessionId = c->sessionId(); @@ -279,7 +277,7 @@ void SessionManager::loadSubSessionInfo(const QString &name) static bool sessionInfoWindowTypeMatch(X11Window *c, SessionInfo *info) { - if (info->windowType == -2) { + if (int(info->windowType) == -2) { // undefined (not really part of NET::WindowType) return !c->isSpecialWindow(); } diff --git a/src/sm.h b/src/sm.h index 16a2e7c3c4..d37e706e08 100644 --- a/src/sm.h +++ b/src/sm.h @@ -19,7 +19,6 @@ #include #include "effect/globals.h" -#include namespace KWin { @@ -106,7 +105,7 @@ struct SessionInfo bool skipPager; bool skipSwitcher; bool noBorder; - NET::WindowType windowType; + WindowType windowType; QString shortcut; bool active; // means 'was active in the saved session' int stackingOrder; diff --git a/src/window.h b/src/window.h index 40f10ce9ee..f0bad44547 100644 --- a/src/window.h +++ b/src/window.h @@ -10,6 +10,7 @@ #pragma once #include "cursor.h" +#include "effect/globals.h" #include "options.h" #include "rules.h" #include "utils/common.h" @@ -17,8 +18,6 @@ #include #include -#include - #include #include #include @@ -221,7 +220,7 @@ class KWIN_EXPORT Window : public QObject * Returns the NETWM window type * See https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . */ - Q_PROPERTY(int windowType READ windowType CONSTANT) + Q_PROPERTY(WindowType windowType READ windowType CONSTANT) /** * Whether this Window is managed by KWin (it has control over its placement and other @@ -689,7 +688,7 @@ public: QRectF keepInArea(QRectF geometry, QRectF area, bool partial = false); // prefer isXXX() instead - virtual NET::WindowType windowType() const = 0; + virtual WindowType windowType() const = 0; bool hasNETSupport() const; bool isDesktop() const; bool isDock() const; @@ -1923,87 +1922,87 @@ inline bool Window::readyForPainting() const inline bool Window::isDesktop() const { - return windowType() == NET::Desktop; + return windowType() == WindowType::Desktop; } inline bool Window::isDock() const { - return windowType() == NET::Dock; + return windowType() == WindowType::Dock; } inline bool Window::isMenu() const { - return windowType() == NET::Menu; + return windowType() == WindowType::Menu; } inline bool Window::isToolbar() const { - return windowType() == NET::Toolbar; + return windowType() == WindowType::Toolbar; } inline bool Window::isSplash() const { - return windowType() == NET::Splash; + return windowType() == WindowType::Splash; } inline bool Window::isUtility() const { - return windowType() == NET::Utility; + return windowType() == WindowType::Utility; } inline bool Window::isDialog() const { - return windowType() == NET::Dialog; + return windowType() == WindowType::Dialog; } inline bool Window::isNormalWindow() const { - return windowType() == NET::Normal; + return windowType() == WindowType::Normal; } inline bool Window::isDropdownMenu() const { - return windowType() == NET::DropdownMenu; + return windowType() == WindowType::DropdownMenu; } inline bool Window::isPopupMenu() const { - return windowType() == NET::PopupMenu; + return windowType() == WindowType::PopupMenu; } inline bool Window::isTooltip() const { - return windowType() == NET::Tooltip; + return windowType() == WindowType::Tooltip; } inline bool Window::isNotification() const { - return windowType() == NET::Notification; + return windowType() == WindowType::Notification; } inline bool Window::isCriticalNotification() const { - return windowType() == NET::CriticalNotification; + return windowType() == WindowType::CriticalNotification; } inline bool Window::isAppletPopup() const { - return windowType() == NET::AppletPopup; + return windowType() == WindowType::AppletPopup; } inline bool Window::isOnScreenDisplay() const { - return windowType() == NET::OnScreenDisplay; + return windowType() == WindowType::OnScreenDisplay; } inline bool Window::isComboBox() const { - return windowType() == NET::ComboBox; + return windowType() == WindowType::ComboBox; } inline bool Window::isDNDIcon() const { - return windowType() == NET::DNDIcon; + return windowType() == WindowType::DNDIcon; } inline bool Window::isLockScreen() const @@ -2076,10 +2075,10 @@ inline T *Window::findInList(const QList &list, std::function // Qt #include #include diff --git a/src/x11window.cpp b/src/x11window.cpp index 88be492023..3642b21b49 100644 --- a/src/x11window.cpp +++ b/src/x11window.cpp @@ -1403,32 +1403,32 @@ void X11Window::detectNoBorder() return; } switch (windowType()) { - case NET::Desktop: - case NET::Dock: - case NET::TopMenu: - case NET::Splash: - case NET::Notification: - case NET::OnScreenDisplay: - case NET::CriticalNotification: - case NET::AppletPopup: + case WindowType::Desktop: + case WindowType::Dock: + case WindowType::TopMenu: + case WindowType::Splash: + case WindowType::Notification: + case WindowType::OnScreenDisplay: + case WindowType::CriticalNotification: + case WindowType::AppletPopup: noborder = true; app_noborder = true; break; - case NET::Unknown: - case NET::Normal: - case NET::Toolbar: - case NET::Menu: - case NET::Dialog: - case NET::Utility: + case WindowType::Unknown: + case WindowType::Normal: + case WindowType::Toolbar: + case WindowType::Menu: + case WindowType::Dialog: + case WindowType::Utility: noborder = false; break; default: Q_UNREACHABLE(); } - // NET::Override is some strange beast without clear definition, usually + // WindowType::Override is some strange beast without clear definition, usually // just meaning "noborder", so let's treat it only as such flag, and ignore it as // a window type otherwise (SUPPORTED_WINDOW_TYPES_MASK doesn't include it) - if (info->windowType(NET::OverrideMask) == NET::Override) { + if (WindowType(info->windowType(NET::OverrideMask)) == WindowType::Override) { noborder = true; app_noborder = true; } @@ -2768,16 +2768,16 @@ bool X11Window::isOutline() const return m_outline; } -NET::WindowType X11Window::windowType() const +WindowType X11Window::windowType() const { if (m_unmanaged) { - return info->windowType(SUPPORTED_UNMANAGED_WINDOW_TYPES_MASK); + return WindowType(info->windowType(SUPPORTED_UNMANAGED_WINDOW_TYPES_MASK)); } - NET::WindowType wt = info->windowType(SUPPORTED_MANAGED_WINDOW_TYPES_MASK); + WindowType wt = WindowType(info->windowType(SUPPORTED_MANAGED_WINDOW_TYPES_MASK)); // hacks here - if (wt == NET::Unknown) { // this is more or less suggested in NETWM spec - wt = isTransient() ? NET::Dialog : NET::Normal; + if (wt == WindowType::Unknown) { // this is more or less suggested in NETWM spec + wt = isTransient() ? WindowType::Dialog : WindowType::Normal; } return wt; } diff --git a/src/x11window.h b/src/x11window.h index ad8e12236f..1365f36048 100644 --- a/src/x11window.h +++ b/src/x11window.h @@ -21,6 +21,7 @@ #include #include // X +#include #include // TODO: Cleanup the order of things in this .h file @@ -132,7 +133,7 @@ public: } // Inside of geometry() bool windowEvent(xcb_generic_event_t *e); - NET::WindowType windowType() const override; + WindowType windowType() const override; bool track(xcb_window_t w); bool manage(xcb_window_t w, bool isMapped); diff --git a/src/xdgshellwindow.cpp b/src/xdgshellwindow.cpp index b4179800e0..5260fd8239 100644 --- a/src/xdgshellwindow.cpp +++ b/src/xdgshellwindow.cpp @@ -90,7 +90,7 @@ XdgSurfaceWindow::~XdgSurfaceWindow() { } -NET::WindowType XdgSurfaceWindow::windowType() const +WindowType XdgSurfaceWindow::windowType() const { return m_windowType; } @@ -325,32 +325,32 @@ void XdgSurfaceWindow::installPlasmaShellSurface(PlasmaShellSurfaceInterface *sh connect(this, &Window::windowShown, this, moveUnderCursor, Qt::SingleShotConnection); }; auto updateRole = [this, shellSurface] { - NET::WindowType type = NET::Unknown; + WindowType type = WindowType::Unknown; switch (shellSurface->role()) { case PlasmaShellSurfaceInterface::Role::Desktop: - type = NET::Desktop; + type = WindowType::Desktop; break; case PlasmaShellSurfaceInterface::Role::Panel: - type = NET::Dock; + type = WindowType::Dock; break; case PlasmaShellSurfaceInterface::Role::OnScreenDisplay: - type = NET::OnScreenDisplay; + type = WindowType::OnScreenDisplay; break; case PlasmaShellSurfaceInterface::Role::Notification: - type = NET::Notification; + type = WindowType::Notification; break; case PlasmaShellSurfaceInterface::Role::ToolTip: - type = NET::Tooltip; + type = WindowType::Tooltip; break; case PlasmaShellSurfaceInterface::Role::CriticalNotification: - type = NET::CriticalNotification; + type = WindowType::CriticalNotification; break; case PlasmaShellSurfaceInterface::Role::AppletPopup: - type = NET::AppletPopup; + type = WindowType::AppletPopup; break; case PlasmaShellSurfaceInterface::Role::Normal: default: - type = NET::Normal; + type = WindowType::Normal; break; } if (m_windowType == type) { @@ -358,13 +358,13 @@ void XdgSurfaceWindow::installPlasmaShellSurface(PlasmaShellSurfaceInterface *sh } m_windowType = type; switch (m_windowType) { - case NET::Desktop: - case NET::Dock: - case NET::OnScreenDisplay: - case NET::Notification: - case NET::CriticalNotification: - case NET::Tooltip: - case NET::AppletPopup: + case WindowType::Desktop: + case WindowType::Dock: + case WindowType::OnScreenDisplay: + case WindowType::Notification: + case WindowType::CriticalNotification: + case WindowType::Tooltip: + case WindowType::AppletPopup: setOnAllDesktops(true); #if KWIN_BUILD_ACTIVITIES setOnAllActivities(true); @@ -1584,7 +1584,7 @@ XdgPopupWindow::XdgPopupWindow(XdgPopupInterface *shellSurface) : XdgSurfaceWindow(shellSurface->xdgSurface()) , m_shellSurface(shellSurface) { - m_windowType = NET::Unknown; + m_windowType = WindowType::Unknown; connect(shellSurface, &XdgPopupInterface::grabRequested, this, &XdgPopupWindow::handleGrabRequested); diff --git a/src/xdgshellwindow.h b/src/xdgshellwindow.h index 2f35832af7..a0e5ad7fe2 100644 --- a/src/xdgshellwindow.h +++ b/src/xdgshellwindow.h @@ -56,7 +56,7 @@ public: explicit XdgSurfaceWindow(XdgSurfaceInterface *shellSurface); ~XdgSurfaceWindow() override; - NET::WindowType windowType() const override; + WindowType windowType() const override; QRectF frameRectToBufferRect(const QRectF &rect) const override; void destroyWindow() override; @@ -76,7 +76,7 @@ protected: QPointer m_plasmaShellSurface; - NET::WindowType m_windowType = NET::Normal; + WindowType m_windowType = WindowType::Normal; Gravity m_nextGravity = Gravity::None; private: