diff --git a/abstract_client.h b/abstract_client.h --- a/abstract_client.h +++ b/abstract_client.h @@ -866,6 +866,13 @@ **/ virtual bool isInternal() const; + /** + * Returns whether window rules can be applied to this client. + * + * Default implementation returns @c true. + **/ + virtual bool supportsWindowRules() const; + public Q_SLOTS: virtual void closeWindow() = 0; diff --git a/abstract_client.cpp b/abstract_client.cpp --- a/abstract_client.cpp +++ b/abstract_client.cpp @@ -2087,4 +2087,9 @@ return false; } +bool AbstractClient::supportsWindowRules() const +{ + return true; +} + } diff --git a/internal_client.h b/internal_client.h --- a/internal_client.h +++ b/internal_client.h @@ -60,6 +60,7 @@ using AbstractClient::resizeWithChecks; void resizeWithChecks(int w, int h, ForceGeometry_t force = NormalGeometrySet) override; QWindow *internalWindow() const override; + bool supportsWindowRules() const override; protected: bool acceptsFocus() const override; diff --git a/internal_client.cpp b/internal_client.cpp --- a/internal_client.cpp +++ b/internal_client.cpp @@ -328,4 +328,9 @@ return m_internalWindow; } +bool InternalClient::supportsWindowRules() const +{ + return false; +} + } diff --git a/shell_client.h b/shell_client.h --- a/shell_client.h +++ b/shell_client.h @@ -163,6 +163,8 @@ return true; } + bool supportsWindowRules() const override; + protected: void addDamage(const QRegion &damage) override; bool belongsToSameApplication(const AbstractClient *other, SameApplicationChecks checks) const override; @@ -297,6 +299,7 @@ QMargins m_windowMargins; bool m_compositingSetup = false; + bool m_isInitialized = false; }; } diff --git a/shell_client.cpp b/shell_client.cpp --- a/shell_client.cpp +++ b/shell_client.cpp @@ -76,6 +76,7 @@ { setSurface(surface->surface()); init(); + m_isInitialized = true; } ShellClient::ShellClient(XdgShellSurfaceInterface *surface) @@ -140,10 +141,11 @@ resourceName = info.fileName().toUtf8(); } setResourceClass(resourceName, shellSurface->windowClass()); + setDesktopFileName(shellSurface->windowClass()); connect(shellSurface, &T::windowClassChanged, this, [this, resourceName] (const QByteArray &windowClass) { setResourceClass(resourceName, windowClass); - if (!m_internal) { + if (m_isInitialized && supportsWindowRules()) { setupWindowRules(true); applyWindowRules(); } @@ -201,11 +203,6 @@ connect(this, &ShellClient::geometryChanged, this, &ShellClient::updateClientOutputs); connect(screens(), &Screens::changed, this, &ShellClient::updateClientOutputs); - - if (!m_internal) { - setupWindowRules(false); - } - setDesktopFileName(rules()->checkDesktopFile(shellSurface->windowClass(), true).toUtf8()); } void ShellClient::init() @@ -335,17 +332,7 @@ } // set initial desktop - setDesktop(rules()->checkDesktop(m_internal ? int(NET::OnAllDesktops) : VirtualDesktopManager::self()->current(), true)); - // TODO: merge in checks from Client::manage? - if (rules()->checkMinimize(false, true)) { - minimize(true); // No animation - } - setSkipTaskbar(rules()->checkSkipTaskbar(m_plasmaShellSurface ? m_plasmaShellSurface->skipTaskbar() : false, true)); - setSkipPager(rules()->checkSkipPager(false, true)); - setSkipSwitcher(rules()->checkSkipSwitcher(false, true)); - setKeepAbove(rules()->checkKeepAbove(false, true)); - setKeepBelow(rules()->checkKeepBelow(false, true)); - setShortcut(rules()->checkShortcut(QString(), true)); + setDesktop(m_internal ? int(NET::OnAllDesktops) : VirtualDesktopManager::self()->current()); // setup shadow integration getShadow(); @@ -359,20 +346,35 @@ setTransient(); AbstractClient::updateColorScheme(QString()); - - if (!m_internal) { - discardTemporaryRules(); - applyWindowRules(); // Just in case - RuleBook::self()->discardUsed(this, false); // Remove ApplyNow rules - updateWindowRules(Rules::All); // Was blocked while !isManaged() - } } void ShellClient::finishInit() { SurfaceInterface *s = surface(); disconnect(s, &SurfaceInterface::committed, this, &ShellClient::finishInit); updateWindowMargins(); + + if (supportsWindowRules()) { + setupWindowRules(false); + + setDesktop(rules()->checkDesktop(desktop(), true)); + setDesktopFileName(rules()->checkDesktopFile(desktopFileName(), true).toUtf8()); + if (rules()->checkMinimize(isMinimized(), true)) { + minimize(true); // No animation. + } + setSkipTaskbar(rules()->checkSkipTaskbar(skipTaskbar(), true)); + setSkipPager(rules()->checkSkipPager(skipPager(), true)); + setSkipSwitcher(rules()->checkSkipSwitcher(skipSwitcher(), true)); + setKeepAbove(rules()->checkKeepAbove(keepAbove(), true)); + setKeepBelow(rules()->checkKeepBelow(keepBelow(), true)); + setShortcut(rules()->checkShortcut(shortcut().toString(), true)); + updateColorScheme(); + + discardTemporaryRules(); + RuleBook::self()->discardUsed(this, false); // Remove Apply Now rules. + updateWindowRules(Rules::All); + } + if (!isInitialPositionSet()) { QRect area = workspace()->clientArea(PlacementArea, Screens::self()->current(), desktop()); placeIn(area); @@ -382,6 +384,8 @@ if (m_requestGeometryBlockCounter == 0) { requestGeometry(m_blockedRequestGeometry); } + + m_isInitialized = true; } void ShellClient::destroyClient() @@ -1945,4 +1949,12 @@ return nullptr; } +bool ShellClient::supportsWindowRules() const +{ + if (m_plasmaShellSurface) { + return false; + } + return m_xdgShellSurface; +} + } diff --git a/useractions.cpp b/useractions.cpp --- a/useractions.cpp +++ b/useractions.cpp @@ -471,8 +471,8 @@ action->setText(i18n("&Extensions")); } - m_rulesOperation->setEnabled(true); - m_applicationRulesOperation->setEnabled(true); + m_rulesOperation->setEnabled(m_client.data()->supportsWindowRules()); + m_applicationRulesOperation->setEnabled(m_client.data()->supportsWindowRules()); showHideActivityMenu(); }