diff --git a/src/abstract_client.cpp b/src/abstract_client.cpp index 0b480f229b..44d2dea4aa 100644 --- a/src/abstract_client.cpp +++ b/src/abstract_client.cpp @@ -3826,6 +3826,83 @@ bool AbstractClient::wantsShadowToBeRendered() const return !isFullScreen() && maximizeMode() != MaximizeFull; } +void AbstractClient::setupWindowRules(bool ignore_temporary) +{ + disconnect(this, &AbstractClient::captionChanged, this, &AbstractClient::evaluateWindowRules); + m_rules = RuleBook::self()->find(this, ignore_temporary); + // check only after getting the rules, because there may be a rule forcing window type } +void AbstractClient::updateWindowRules(Rules::Types selection) +{ + if (RuleBook::self()->areUpdatesDisabled()) { + return; + } + m_rules.update(this, selection); +} + +void AbstractClient::finishWindowRules() +{ + updateWindowRules(Rules::All); + m_rules = WindowRules(); +} + +// Applies Force, ForceTemporarily and ApplyNow rules +// Used e.g. after the rules have been modified using the kcm. +void AbstractClient::applyWindowRules() +{ + // apply force rules + // Placement - does need explicit update, just like some others below + // Geometry : setGeometry() doesn't check rules + auto client_rules = rules(); + const QRect oldGeometry = moveResizeGeometry(); + const QRect geometry = client_rules->checkGeometry(oldGeometry); + if (geometry != oldGeometry) { + moveResize(geometry); + } + // MinSize, MaxSize handled by Geometry + // IgnoreGeometry + setDesktops(desktops()); + workspace()->sendClientToOutput(this, output()); + setOnActivities(activities()); + // Type + maximize(maximizeMode()); + // Minimize : functions don't check, and there are two functions + if (client_rules->checkMinimize(isMinimized())) { + minimize(); + } else { + unminimize(); + } + setShade(shadeMode()); + setOriginalSkipTaskbar(skipTaskbar()); + setSkipPager(skipPager()); + setSkipSwitcher(skipSwitcher()); + setKeepAbove(keepAbove()); + setKeepBelow(keepBelow()); + setFullScreen(isFullScreen(), true); + setNoBorder(noBorder()); + updateColorScheme(); + // FSP + // AcceptFocus : + if (workspace()->mostRecentlyActivatedClient() == this + && !client_rules->checkAcceptFocus(true)) { + workspace()->activateNextClient(this); + } + // Autogrouping : Only checked on window manage + // AutogroupInForeground : Only checked on window manage + // AutogroupById : Only checked on window manage + // StrictGeometry + setShortcut(rules()->checkShortcut(shortcut().toString())); + // see also X11Client::setActive() + if (isActive()) { + setOpacity(rules()->checkOpacityActive(qRound(opacity() * 100.0)) / 100.0); + workspace()->disableGlobalShortcutsForClient(rules()->checkDisableGlobalShortcuts(false)); + } else { + setOpacity(rules()->checkOpacityInactive(qRound(opacity() * 100.0)) / 100.0); + } + setDesktopFileName(rules()->checkDesktopFile(desktopFileName()).toUtf8()); +} + +} // namespace KWin + #include "moc_abstract_client.cpp" diff --git a/src/kcmkwin/kwinrules/CMakeLists.txt b/src/kcmkwin/kwinrules/CMakeLists.txt index 1a82ad018d..b199804493 100644 --- a/src/kcmkwin/kwinrules/CMakeLists.txt +++ b/src/kcmkwin/kwinrules/CMakeLists.txt @@ -6,10 +6,7 @@ include_directories(../../) set(kwinrules_SRCS ../../rulebooksettings.cpp - ../../cursor.cpp - ../../backends/x11/standalone/x11cursor.cpp ../../rules.cpp - ../../placement.cpp ../../utils/common.cpp ../../virtualdesktopsdbustypes.cpp kwinsrc.cpp diff --git a/src/rules.cpp b/src/rules.cpp index 4e56b9f58c..02a2a30351 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -19,13 +19,12 @@ #include #ifndef KCMRULES +#include "abstract_client.h" #include "client_machine.h" #include "main.h" #include "platform.h" -#include "screens.h" #include "virtualdesktops.h" #include "workspace.h" -#include "x11client.h" #endif #include "rulebooksettings.h" @@ -880,94 +879,6 @@ CHECK_RULE(DesktopFile, QString) #undef CHECK_RULE #undef CHECK_FORCE_RULE -// Client - -void AbstractClient::setupWindowRules(bool ignore_temporary) -{ - disconnect(this, &AbstractClient::captionChanged, this, &AbstractClient::evaluateWindowRules); - m_rules = RuleBook::self()->find(this, ignore_temporary); - // check only after getting the rules, because there may be a rule forcing window type -} - -// Applies Force, ForceTemporarily and ApplyNow rules -// Used e.g. after the rules have been modified using the kcm. -void AbstractClient::applyWindowRules() -{ - // apply force rules - // Placement - does need explicit update, just like some others below - // Geometry : setGeometry() doesn't check rules - auto client_rules = rules(); - const QRect oldGeometry = moveResizeGeometry(); - const QRect geometry = client_rules->checkGeometry(oldGeometry); - if (geometry != oldGeometry) { - moveResize(geometry); - } - // MinSize, MaxSize handled by Geometry - // IgnoreGeometry - setDesktops(desktops()); - workspace()->sendClientToOutput(this, output()); - setOnActivities(activities()); - // Type - maximize(maximizeMode()); - // Minimize : functions don't check, and there are two functions - if (client_rules->checkMinimize(isMinimized())) { - minimize(); - } else { - unminimize(); - } - setShade(shadeMode()); - setOriginalSkipTaskbar(skipTaskbar()); - setSkipPager(skipPager()); - setSkipSwitcher(skipSwitcher()); - setKeepAbove(keepAbove()); - setKeepBelow(keepBelow()); - setFullScreen(isFullScreen(), true); - setNoBorder(noBorder()); - updateColorScheme(); - // FSP - // AcceptFocus : - if (workspace()->mostRecentlyActivatedClient() == this - && !client_rules->checkAcceptFocus(true)) { - workspace()->activateNextClient(this); - } - // Autogrouping : Only checked on window manage - // AutogroupInForeground : Only checked on window manage - // AutogroupById : Only checked on window manage - // StrictGeometry - setShortcut(rules()->checkShortcut(shortcut().toString())); - // see also X11Client::setActive() - if (isActive()) { - setOpacity(rules()->checkOpacityActive(qRound(opacity() * 100.0)) / 100.0); - workspace()->disableGlobalShortcutsForClient(rules()->checkDisableGlobalShortcuts(false)); - } else { - setOpacity(rules()->checkOpacityInactive(qRound(opacity() * 100.0)) / 100.0); - } - setDesktopFileName(rules()->checkDesktopFile(desktopFileName()).toUtf8()); -} - -void X11Client::updateWindowRules(Rules::Types selection) -{ - if (!isManaged()) { // not fully setup yet - return; - } - AbstractClient::updateWindowRules(selection); -} - -void AbstractClient::updateWindowRules(Rules::Types selection) -{ - if (RuleBook::self()->areUpdatesDisabled()) { - return; - } - m_rules.update(this, selection); -} - -void AbstractClient::finishWindowRules() -{ - updateWindowRules(Rules::All); - m_rules = WindowRules(); -} - -// Workspace KWIN_SINGLETON_FACTORY(RuleBook) RuleBook::RuleBook(QObject *parent) diff --git a/src/x11client.cpp b/src/x11client.cpp index 780f581519..33b000350c 100644 --- a/src/x11client.cpp +++ b/src/x11client.cpp @@ -318,7 +318,7 @@ void X11Client::releaseWindow(bool on_shutdown) if (on_shutdown) { // Map the window, so it can be found after another WM is started m_client.map(); - // TODO: Preserve minimized, shaded etc. state? + // TODO: Preserve minimized, shaded etc. state? } else { // Make sure it's not mapped if the app unmapped it (#65279). The app // may do map+unmap before we initially map the window by calling rawShow() from manage(). m_client.unmap(); @@ -2222,8 +2222,8 @@ void X11Client::getMotifHints() // If we just got a hint telling us to hide decorations, we do so. if (m_motif.noBorder()) { noborder = rules()->checkNoBorder(true); - // If the Motif hint is now telling us to show decorations, we only do so if the app didn't - // instruct us to hide decorations in some other way, though. + // If the Motif hint is now telling us to show decorations, we only do so if the app didn't + // instruct us to hide decorations in some other way, though. } else if (!app_noborder) { noborder = rules()->checkNoBorder(false); } @@ -2877,7 +2877,7 @@ bool X11Client::belongToSameApplication(const X11Client *c1, const X11Client *c2 && c2->wmClientLeader() != c2->window()) { // don't use in this test then same_app = true; // same client leader - // tests that mean they most probably don't belong together + // tests that mean they most probably don't belong together } else if ((c1->pid() != c2->pid() && !checks.testFlag(SameApplicationCheck::AllowCrossProcesses)) || c1->wmClientMachine(false) != c2->wmClientMachine(false)) { ; // different processes @@ -2893,7 +2893,7 @@ bool X11Client::belongToSameApplication(const X11Client *c1, const X11Client *c2 ; // "different" apps } else if (c1->pid() == 0 || c2->pid() == 0) { ; // old apps that don't have _NET_WM_PID, consider them different - // if they weren't found to match above + // if they weren't found to match above } else { same_app = true; // looks like it's the same app } @@ -4831,6 +4831,14 @@ bool X11Client::supportsWindowRules() const return true; } +void X11Client::updateWindowRules(Rules::Types selection) +{ + if (!isManaged()) { // not fully setup yet + return; + } + AbstractClient::updateWindowRules(selection); +} + void X11Client::damageNotifyEvent() { Q_ASSERT(kwinApp()->operationMode() == Application::OperationModeX11);