Merge WindowRules::checkScreen() and WindowRules::checkOutput()
This commit is contained in:
parent
a1f1039b58
commit
b80fbe6fb0
3 changed files with 26 additions and 22 deletions
|
@ -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
|
||||
{
|
||||
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 ))
|
||||
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));
|
||||
if (rules.isEmpty()) {
|
||||
return output;
|
||||
}
|
||||
int ret = kwinApp()->platform()->enabledOutputs().indexOf(output);
|
||||
for (Rules *rule : rules) {
|
||||
if (rule->applyScreen(ret, init)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
AbstractOutput *ruleOutput = kwinApp()->platform()->findOutput(ret);
|
||||
return ruleOutput ? ruleOutput : output;
|
||||
}
|
||||
|
||||
CHECK_RULE(Minimize, bool)
|
||||
|
|
|
@ -54,7 +54,6 @@ public:
|
|||
int checkOpacityInactive(int s) const;
|
||||
bool checkIgnoreGeometry(bool ignore, bool init = false) const;
|
||||
QVector<VirtualDesktop *> checkDesktops(QVector<VirtualDesktop *> 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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue