From 176ae6e6927f15f28c992b58366c4dd05fcc274a Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 17 Jan 2024 01:39:04 +0200 Subject: [PATCH] Drop window type rule Practically all code assumes that the window type is static and fixing it would bring extra complexity, which may not be worth given that there are window rules to control position, focus, layer, etc. BUG: 466016 --- src/inputpanelv1window.cpp | 2 +- src/inputpanelv1window.h | 2 +- src/internalwindow.cpp | 2 +- src/internalwindow.h | 2 +- src/kcms/rules/rulesmodel.cpp | 7 ------- src/layershellv1window.cpp | 2 +- src/layershellv1window.h | 2 +- src/rules.cpp | 12 +----------- src/rules.h | 4 ---- src/rulesettings.kcfg | 11 ----------- src/window.h | 2 +- src/x11window.cpp | 10 +--------- src/x11window.h | 2 +- src/xdgshellwindow.cpp | 2 +- src/xdgshellwindow.h | 2 +- 15 files changed, 12 insertions(+), 52 deletions(-) diff --git a/src/inputpanelv1window.cpp b/src/inputpanelv1window.cpp index 783bfb7d92..79d4c8eeb9 100644 --- a/src/inputpanelv1window.cpp +++ b/src/inputpanelv1window.cpp @@ -171,7 +171,7 @@ void InputPanelV1Window::destroyWindow() unref(); } -NET::WindowType InputPanelV1Window::windowType(bool direct) const +NET::WindowType InputPanelV1Window::windowType() const { return NET::Utility; } diff --git a/src/inputpanelv1window.h b/src/inputpanelv1window.h index f791fa911f..0c119fd20f 100644 --- a/src/inputpanelv1window.h +++ b/src/inputpanelv1window.h @@ -70,7 +70,7 @@ public: { return true; } - NET::WindowType windowType(bool direct = false) const override; + NET::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 da6e7e2ee3..20a7a4f27c 100644 --- a/src/internalwindow.cpp +++ b/src/internalwindow.cpp @@ -145,7 +145,7 @@ QSizeF InternalWindow::maxSize() const return m_handle->maximumSize(); } -NET::WindowType InternalWindow::windowType(bool direct) const +NET::WindowType InternalWindow::windowType() const { return NET::Normal; } diff --git a/src/internalwindow.h b/src/internalwindow.h index 2129797853..023f8586a5 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(bool direct = false) const override; + NET::WindowType windowType() const override; void killWindow() override; bool isClient() const override; bool isPopupWindow() const override; diff --git a/src/kcms/rules/rulesmodel.cpp b/src/kcms/rules/rulesmodel.cpp index 703ecb11c7..47f35bdadc 100644 --- a/src/kcms/rules/rulesmodel.cpp +++ b/src/kcms/rules/rulesmodel.cpp @@ -704,12 +704,6 @@ void RulesModel::populateRuleList() i18n("Closeable"), i18n("Appearance & Fixes"), QIcon::fromTheme("dialog-close"))); - auto type = addRule(new RuleItem(QLatin1String("type"), - RulePolicy::ForceRule, RuleItem::Option, - i18n("Set window type"), i18n("Appearance & Fixes"), - QIcon::fromTheme("window-duplicate"))); - type->setOptionsData(windowTypesModelData()); - addRule(new RuleItem(QLatin1String("desktopfile"), RulePolicy::SetRule, RuleItem::String, i18n("Desktop file name"), i18n("Appearance & Fixes"), @@ -744,7 +738,6 @@ const QHash RulesModel::x11PropertyHash() {"skipTaskbar", "skiptaskbar"}, {"skipPager", "skippager"}, {"skipSwitcher", "skipswitcher"}, - {"type", "type"}, {"desktopFile", "desktopfile"}, {"desktops", "desktops"}, {"layer", "layer"}, diff --git a/src/layershellv1window.cpp b/src/layershellv1window.cpp index 7d6dd0b90b..2c1d10d048 100644 --- a/src/layershellv1window.cpp +++ b/src/layershellv1window.cpp @@ -93,7 +93,7 @@ void LayerShellV1Window::scheduleRearrange() m_integration->scheduleRearrange(); } -NET::WindowType LayerShellV1Window::windowType(bool) const +NET::WindowType LayerShellV1Window::windowType() const { return m_windowType; } diff --git a/src/layershellv1window.h b/src/layershellv1window.h index 15d221e0ed..6a36a477c9 100644 --- a/src/layershellv1window.h +++ b/src/layershellv1window.h @@ -28,7 +28,7 @@ public: LayerSurfaceV1Interface *shellSurface() const; Output *desiredOutput() const; - NET::WindowType windowType(bool direct = false) const override; + NET::WindowType windowType() const override; bool isPlaceable() const override; bool isCloseable() const override; bool isMovable() const override; diff --git a/src/rules.cpp b/src/rules.cpp index c8fbcc40fe..3cb9a539c3 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -51,7 +51,6 @@ Rules::Rules() , desktopsrule(UnusedSetRule) , screenrule(UnusedSetRule) , activityrule(UnusedSetRule) - , typerule(UnusedForceRule) , maximizevertrule(UnusedSetRule) , maximizehorizrule(UnusedSetRule) , minimizerule(UnusedSetRule) @@ -128,10 +127,6 @@ void Rules::readFromSettings(const RuleSettings *settings) READ_SET_RULE(desktops); READ_SET_RULE(screen); READ_SET_RULE(activity); - READ_FORCE_RULE(type, static_cast); - if (type == NET::Unknown) { - typerule = UnusedForceRule; - } READ_SET_RULE(maximizevert); READ_SET_RULE(maximizehoriz); READ_SET_RULE(minimize); @@ -208,7 +203,6 @@ void Rules::write(RuleSettings *settings) const WRITE_SET_RULE(desktops, Desktops, ); WRITE_SET_RULE(screen, Screen, ); WRITE_SET_RULE(activity, Activity, ); - WRITE_FORCE_RULE(type, Type, ); WRITE_SET_RULE(maximizevert, Maximizevert, ); WRITE_SET_RULE(maximizehoriz, Maximizehoriz, ); WRITE_SET_RULE(minimize, Minimize, ); @@ -261,7 +255,6 @@ bool Rules::isEmpty() const && desktopsrule == UnusedSetRule && screenrule == UnusedSetRule && activityrule == UnusedSetRule - && typerule == UnusedForceRule && maximizevertrule == UnusedSetRule && maximizehorizrule == UnusedSetRule && minimizerule == UnusedSetRule @@ -399,7 +392,7 @@ bool Rules::matchClientMachine(const QString &match_machine, bool local) const #ifndef KCMRULES bool Rules::match(const Window *c) const { - if (!matchType(c->windowType(true))) { + if (!matchType(c->windowType())) { return false; } if (!matchWMClass(c->resourceClass(), c->resourceName())) { @@ -578,7 +571,6 @@ APPLY_RULE(ignoregeometry, IgnoreGeometry, bool) APPLY_RULE(screen, Screen, int) APPLY_RULE(activity, Activity, QStringList) -APPLY_FORCE_RULE(type, Type, NET::WindowType) APPLY_FORCE_RULE(layer, Layer, enum Layer) bool Rules::applyDesktops(QList &vds, bool init) const @@ -678,7 +670,6 @@ bool Rules::discardUsed(bool withdrawn) DISCARD_USED_SET_RULE(desktops); DISCARD_USED_SET_RULE(screen); DISCARD_USED_SET_RULE(activity); - DISCARD_USED_FORCE_RULE(type); DISCARD_USED_SET_RULE(maximizevert); DISCARD_USED_SET_RULE(maximizehoriz); DISCARD_USED_SET_RULE(minimize); @@ -803,7 +794,6 @@ CHECK_RULE(IgnoreGeometry, bool) CHECK_RULE(Desktops, QList) CHECK_RULE(Activity, QStringList) -CHECK_FORCE_RULE(Type, NET::WindowType) CHECK_RULE(MaximizeVert, MaximizeMode) CHECK_RULE(MaximizeHoriz, MaximizeMode) diff --git a/src/rules.h b/src/rules.h index 5d0cf2073b..d55f3da9f7 100644 --- a/src/rules.h +++ b/src/rules.h @@ -53,7 +53,6 @@ public: QList checkDesktops(QList desktops, bool init = false) const; Output *checkOutput(Output *output, bool init = false) const; QStringList checkActivity(QStringList activity, bool init = false) const; - NET::WindowType checkType(NET::WindowType type) const; MaximizeMode checkMaximize(MaximizeMode mode, bool init = false) const; bool checkMinimize(bool minimized, bool init = false) const; ShadeMode checkShade(ShadeMode shade, bool init = false) const; @@ -161,7 +160,6 @@ public: bool applyDesktops(QList &desktops, bool init) const; bool applyScreen(int &desktop, bool init) const; bool applyActivity(QStringList &activity, bool init) const; - bool applyType(NET::WindowType &type) const; bool applyMaximizeVert(MaximizeMode &mode, bool init) const; bool applyMaximizeHoriz(MaximizeMode &mode, bool init) const; bool applyMinimize(bool &minimized, bool init) const; @@ -242,8 +240,6 @@ private: SetRule screenrule; QStringList activity; SetRule activityrule; - NET::WindowType type; // type for setting - ForceRule typerule; bool maximizevert; SetRule maximizevertrule; bool maximizehoriz; diff --git a/src/rulesettings.kcfg b/src/rulesettings.kcfg index c29edd1665..585af0e126 100644 --- a/src/rulesettings.kcfg +++ b/src/rulesettings.kcfg @@ -179,17 +179,6 @@ Rules::UnusedSetRule - - - NET::Normal - NET::CriticalNotification - NET::Unknown - - - - Rules::UnusedForceRule - - false diff --git a/src/window.h b/src/window.h index 38200f7c23..57e32ad7f5 100644 --- a/src/window.h +++ b/src/window.h @@ -693,7 +693,7 @@ public: QRectF keepInArea(QRectF geometry, QRectF area, bool partial = false); // prefer isXXX() instead - virtual NET::WindowType windowType(bool direct = false) const = 0; + virtual NET::WindowType windowType() const = 0; bool hasNETSupport() const; bool isDesktop() const; bool isDock() const; diff --git a/src/x11window.cpp b/src/x11window.cpp index f4c6e166bd..190d9f3865 100644 --- a/src/x11window.cpp +++ b/src/x11window.cpp @@ -2758,21 +2758,13 @@ bool X11Window::isOutline() const return m_outline; } -NET::WindowType X11Window::windowType(bool direct) const +NET::WindowType X11Window::windowType() const { if (m_unmanaged) { return info->windowType(SUPPORTED_UNMANAGED_WINDOW_TYPES_MASK); } NET::WindowType wt = info->windowType(SUPPORTED_MANAGED_WINDOW_TYPES_MASK); - if (direct) { - return wt; - } - NET::WindowType wt2 = rules()->checkType(wt); - if (wt != wt2) { - wt = wt2; - info->setWindowType(wt); // force hint change - } // hacks here if (wt == NET::Unknown) { // this is more or less suggested in NETWM spec wt = isTransient() ? NET::Dialog : NET::Normal; diff --git a/src/x11window.h b/src/x11window.h index e8baac0a51..053f3b1364 100644 --- a/src/x11window.h +++ b/src/x11window.h @@ -131,7 +131,7 @@ public: } // Inside of geometry() bool windowEvent(xcb_generic_event_t *e); - NET::WindowType windowType(bool direct = false) const override; + NET::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 7fc041eb40..465ce72ad2 100644 --- a/src/xdgshellwindow.cpp +++ b/src/xdgshellwindow.cpp @@ -88,7 +88,7 @@ XdgSurfaceWindow::~XdgSurfaceWindow() { } -NET::WindowType XdgSurfaceWindow::windowType(bool direct) const +NET::WindowType XdgSurfaceWindow::windowType() const { return m_windowType; } diff --git a/src/xdgshellwindow.h b/src/xdgshellwindow.h index cd58f8c8aa..2f35832af7 100644 --- a/src/xdgshellwindow.h +++ b/src/xdgshellwindow.h @@ -56,7 +56,7 @@ public: explicit XdgSurfaceWindow(XdgSurfaceInterface *shellSurface); ~XdgSurfaceWindow() override; - NET::WindowType windowType(bool direct = false) const override; + NET::WindowType windowType() const override; QRectF frameRectToBufferRect(const QRectF &rect) const override; void destroyWindow() override;