Do not rely on NETWM for the main Window class

NETWM forces a weird X11 dependency on KWin that doesn't necessarily
match what we want to do. Instead we decouple such a central class in
KWin like it's Window from KWindowSystem X11 support.

Signed-off-by: Falko Becker <falko.becker@mbition.io>
This commit is contained in:
Aleix Pol Gonzalez 2024-02-20 18:04:06 +00:00 committed by Vlad Zahorodnii
parent afa450b97a
commit 79dd34b3f9
26 changed files with 291 additions and 129 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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

View file

@ -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);

View file

@ -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()},

View file

@ -27,10 +27,10 @@
#include <QLoggingCategory>
#include <QStack>
#include <netwm.h>
#include <functional>
#include <xcb/xcb.h>
class KConfigGroup;
class QFont;
class QKeyEvent;

View file

@ -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();
}

View file

@ -11,7 +11,7 @@
#include "kwin_export.h"
#include <NETWM>
#include "globals.h"
#include <QObject>
@ -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).

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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()

View file

@ -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;

View file

@ -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<NET::WindowType>(info.value("type").toInt());
const WindowType type = static_cast<WindowType>(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();

View file

@ -18,20 +18,20 @@
namespace KWin
{
static NET::WindowType scopeToType(const QString &scope)
static WindowType scopeToType(const QString &scope)
{
static const QHash<QString, NET::WindowType> 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<QString, WindowType> 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;
}

View file

@ -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<AutoHideScreenEdgeV1Interface> m_screenEdge;
bool m_screenEdgeActive = false;
NET::WindowType m_windowType;
WindowType m_windowType;
};
} // namespace KWin

View file

@ -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;
}
if (!NET::typeMatchesMask(match_type, types)) {
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 (!typeMatchesMask(match_type, types)) {
return false;
}
}

View file

@ -11,7 +11,6 @@
#include <QList>
#include <QRectF>
#include <netwm_def.h>
#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;

View file

@ -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<NET::WindowType>(i);
return static_cast<WindowType>(i);
}
}
return static_cast<NET::WindowType>(-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<QByteArray> 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();
}

View file

@ -19,7 +19,6 @@
#include <KConfigGroup>
#include "effect/globals.h"
#include <netwm_def.h>
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;

View file

@ -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 <functional>
#include <memory>
#include <NETWM>
#include <QElapsedTimer>
#include <QIcon>
#include <QKeySequence>
@ -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<T *> &list, std::function<bool(const U
inline bool Window::isPopupWindow() const
{
switch (windowType()) {
case NET::ComboBox:
case NET::DropdownMenu:
case NET::PopupMenu:
case NET::Tooltip:
case WindowType::ComboBox:
case WindowType::DropdownMenu:
case WindowType::PopupMenu:
case WindowType::Tooltip:
return true;
default:

View file

@ -17,6 +17,8 @@
#include "options.h"
#include "sm.h"
#include "utils/common.h"
// KF
#include <netwm_def.h>
// Qt
#include <QList>
#include <QStringList>

View file

@ -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;
}

View file

@ -21,6 +21,7 @@
#include <QPointer>
#include <QWindow>
// X
#include <NETWM>
#include <xcb/sync.h>
// 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);

View file

@ -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);

View file

@ -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<PlasmaShellSurfaceInterface> m_plasmaShellSurface;
NET::WindowType m_windowType = NET::Normal;
WindowType m_windowType = WindowType::Normal;
Gravity m_nextGravity = Gravity::None;
private: