diff --git a/src/rules.cpp b/src/rules.cpp index 8e36397b0f..f501a7431d 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -807,24 +807,19 @@ MaximizeMode WindowRules::checkMaximize(MaximizeMode mode, bool init) const return static_cast< MaximizeMode >((vert ? MaximizeVertical : 0) | (horiz ? MaximizeHorizontal : 0)); } -int WindowRules::checkScreen(int screen, bool init) const +AbstractOutput *WindowRules::checkOutput(AbstractOutput *output, bool init) const { - if ( rules.count() == 0 ) - return screen; - int ret = screen; - for ( QVector< Rules* >::ConstIterator it = rules.constBegin(); it != rules.constEnd(); ++it ) { - if ( (*it)->applyScreen( ret, init )) + if (rules.isEmpty()) { + return output; + } + int ret = kwinApp()->platform()->enabledOutputs().indexOf(output); + for (Rules *rule : rules) { + if (rule->applyScreen(ret, init)) { break; + } } - if (ret >= Screens::self()->count()) - ret = screen; - return ret; -} - -AbstractOutput *WindowRules::checkOutput(AbstractOutput *output, bool init) const -{ - int screenId = kwinApp()->platform()->enabledOutputs().indexOf(output); - return kwinApp()->platform()->findOutput(checkScreen(screenId, init)); + AbstractOutput *ruleOutput = kwinApp()->platform()->findOutput(ret); + return ruleOutput ? ruleOutput : output; } CHECK_RULE(Minimize, bool) diff --git a/src/rules.h b/src/rules.h index fa5781d50f..bcc4204c79 100644 --- a/src/rules.h +++ b/src/rules.h @@ -54,7 +54,6 @@ public: int checkOpacityInactive(int s) const; bool checkIgnoreGeometry(bool ignore, bool init = false) const; QVector checkDesktops(QVector desktops, bool init = false) const; - int checkScreen(int screen, bool init = false) const; AbstractOutput *checkOutput(AbstractOutput *output, bool init = false) const; QStringList checkActivity(QStringList activity, bool init = false) const; NET::WindowType checkType(NET::WindowType type) const; diff --git a/src/x11client.cpp b/src/x11client.cpp index 86c8e3ddfb..f64efbdd9c 100644 --- a/src/x11client.cpp +++ b/src/x11client.cpp @@ -10,6 +10,7 @@ // own #include "x11client.h" // kwin +#include "abstract_output.h" #ifdef KWIN_BUILD_ACTIVITIES #include "activities.h" #endif @@ -23,6 +24,7 @@ #include "geometrytip.h" #include "group.h" #include "netinfo.h" +#include "platform.h" #include "screenedge.h" #include "screens.h" #include "shadow.h" @@ -607,9 +609,15 @@ bool X11Client::manage(xcb_window_t w, bool isMapped) area = workspace()->clientArea(FullArea, this, geom.center()); checkOffscreenPosition(&geom, area); } else { - int screen = asn_data.xinerama() == -1 ? screens()->current() : asn_data.xinerama(); - screen = rules()->checkScreen(screen, !isMapped); - area = workspace()->clientArea(PlacementArea, this, screens()->geometry(screen).center()); + AbstractOutput *output = nullptr; + if (asn_data.xinerama() != -1) { + output = kwinApp()->platform()->findOutput(asn_data.xinerama()); + } + if (!output) { + output = screens()->currentOutput(); + } + output = rules()->checkOutput(output, !isMapped); + area = workspace()->clientArea(PlacementArea, this, output->geometry().center()); } if (isDesktop()) @@ -3809,9 +3817,11 @@ void X11Client::configureRequest(int value_mask, int rx, int ry, int rw, int rh, QSize requestedFrameSize = clientSizeToFrameSize(requestedClientSize); requestedFrameSize = rules()->checkSize(requestedFrameSize); new_pos = rules()->checkPosition(new_pos); - int newScreen = screens()->number(QRect(new_pos, requestedFrameSize).center()); - if (newScreen != rules()->checkScreen(newScreen)) + + AbstractOutput *newOutput = kwinApp()->platform()->outputAt(QRect(new_pos, requestedFrameSize).center()); + if (newOutput != rules()->checkOutput(newOutput)) { return; // not allowed by rule + } QRect origClientGeometry = m_clientGeometry; GeometryUpdatesBlocker blocker(this);