diff --git a/abstract_client.h b/abstract_client.h --- a/abstract_client.h +++ b/abstract_client.h @@ -805,6 +805,11 @@ **/ virtual Group *group(); + /** + * Whether window rules can be applied to this client. + **/ + 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 @@ -2030,4 +2030,9 @@ return nullptr; } +bool AbstractClient::supportsWindowRules() const +{ + return true; +} + } diff --git a/internal_client.h b/internal_client.h --- a/internal_client.h +++ b/internal_client.h @@ -59,6 +59,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 @@ -318,4 +318,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; @@ -291,6 +293,7 @@ QHash m_pingSerials; bool m_compositingSetup = false; + bool m_initialized = false; }; } diff --git a/shell_client.cpp b/shell_client.cpp --- a/shell_client.cpp +++ b/shell_client.cpp @@ -78,6 +78,7 @@ { setSurface(surface->surface()); init(); + m_initialized = true; } ShellClient::ShellClient(XdgShellSurfaceInterface *surface) @@ -142,10 +143,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_initialized && supportsWindowRules()) { setupWindowRules(true); applyWindowRules(); } @@ -203,11 +205,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() @@ -337,17 +334,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(); @@ -361,19 +348,33 @@ 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); + 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 (m_xdgShellPopup) { QRect area = workspace()->clientArea(PlacementArea, Screens::self()->current(), desktop()); placeIn(area); @@ -383,6 +384,8 @@ if (m_requestGeometryBlockCounter == 0) { requestGeometry(m_blockedRequestGeometry); } + + m_initialized = true; } void ShellClient::destroyClient() @@ -1872,4 +1875,9 @@ return nullptr; } +bool ShellClient::supportsWindowRules() const +{ + 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(); }