Port AbstractClient::setQuickTileMode() to output()
This commit is contained in:
parent
8a93a33b96
commit
2696030b00
1 changed files with 28 additions and 23 deletions
|
@ -9,6 +9,7 @@
|
||||||
*/
|
*/
|
||||||
#include "abstract_client.h"
|
#include "abstract_client.h"
|
||||||
|
|
||||||
|
#include "abstract_output.h"
|
||||||
#ifdef KWIN_BUILD_ACTIVITIES
|
#ifdef KWIN_BUILD_ACTIVITIES
|
||||||
#include "activities.h"
|
#include "activities.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -3149,38 +3150,42 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
|
||||||
// If trying to tile to the side that the window is already tiled to move the window to the next
|
// If trying to tile to the side that the window is already tiled to move the window to the next
|
||||||
// screen if it exists, otherwise toggle the mode (set QuickTileFlag::None)
|
// screen if it exists, otherwise toggle the mode (set QuickTileFlag::None)
|
||||||
if (quickTileMode() == mode) {
|
if (quickTileMode() == mode) {
|
||||||
const int numScreens = screens()->count();
|
const QVector<AbstractOutput *> outputs = kwinApp()->platform()->enabledOutputs();
|
||||||
const int curScreen = screen();
|
const AbstractOutput *currentOutput = output();
|
||||||
int nextScreen = curScreen;
|
const AbstractOutput *nextOutput = currentOutput;
|
||||||
QVarLengthArray<QRect> screens(numScreens);
|
|
||||||
for (int i = 0; i < numScreens; ++i) // Cache
|
|
||||||
screens[i] = Screens::self()->geometry(i);
|
|
||||||
for (int i = 0; i < numScreens; ++i) {
|
|
||||||
|
|
||||||
if (i == curScreen)
|
for (const AbstractOutput *output : outputs) {
|
||||||
|
if (output == currentOutput) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (screens[i].bottom() <= screens[curScreen].top() || screens[i].top() >= screens[curScreen].bottom())
|
|
||||||
continue; // not in horizontal line
|
|
||||||
|
|
||||||
const int x = screens[i].center().x();
|
|
||||||
if ((mode & QuickTileFlag::Horizontal) == QuickTileMode(QuickTileFlag::Left)) {
|
|
||||||
if (x >= screens[curScreen].center().x() || (curScreen != nextScreen && x <= screens[nextScreen].center().x()))
|
|
||||||
continue; // not left of current or more left then found next
|
|
||||||
} else if ((mode & QuickTileFlag::Horizontal) == QuickTileMode(QuickTileFlag::Right)) {
|
|
||||||
if (x <= screens[curScreen].center().x() || (curScreen != nextScreen && x >= screens[nextScreen].center().x()))
|
|
||||||
continue; // not right of current or more right then found next
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nextScreen = i;
|
if (output->geometry().bottom() <= currentOutput->geometry().top()
|
||||||
|
|| output->geometry().top() >= currentOutput->geometry().bottom()) {
|
||||||
|
continue; // not in horizontal line
|
||||||
|
}
|
||||||
|
|
||||||
|
const int x = output->geometry().center().x();
|
||||||
|
if ((mode & QuickTileFlag::Horizontal) == QuickTileMode(QuickTileFlag::Left)) {
|
||||||
|
if (x >= currentOutput->geometry().center().x()
|
||||||
|
|| (currentOutput != nextOutput && x <= nextOutput->geometry().center().x())) {
|
||||||
|
continue; // not left of current or more left then found next
|
||||||
|
}
|
||||||
|
} else if ((mode & QuickTileFlag::Horizontal) == QuickTileMode(QuickTileFlag::Right)) {
|
||||||
|
if (x <= currentOutput->geometry().center().x()
|
||||||
|
|| (currentOutput != nextOutput && x >= nextOutput->geometry().center().x())) {
|
||||||
|
continue; // not right of current or more right then found next
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nextOutput = output;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextScreen == curScreen) {
|
if (nextOutput == currentOutput) {
|
||||||
mode = QuickTileFlag::None; // No other screens, toggle tiling
|
mode = QuickTileFlag::None; // No other screens, toggle tiling
|
||||||
} else {
|
} else {
|
||||||
// Move to other screen
|
// Move to other screen
|
||||||
moveResize(geometryRestore().translated(screens[nextScreen].topLeft() - screens[curScreen].topLeft()));
|
moveResize(geometryRestore().translated(nextOutput->geometry().topLeft() - currentOutput->geometry().topLeft()));
|
||||||
whichScreen = screens[nextScreen].center();
|
whichScreen = nextOutput->geometry().center();
|
||||||
|
|
||||||
// Swap sides
|
// Swap sides
|
||||||
if (mode & QuickTileFlag::Horizontal) {
|
if (mode & QuickTileFlag::Horizontal) {
|
||||||
|
|
Loading…
Reference in a new issue