warp cursor per virtual desktop wrap direction

if there's no desktop toLeft/Right above/below it's wrong
to warp the cursor, branch opens on corner edges

CCBUG: 333341

Forward port of eea4bb81105f2c289831cf1f682c3927a24fd831 from kde-workspace
This commit is contained in:
Thomas Lübking 2014-04-12 21:38:52 +02:00 committed by Martin Gräßlin
parent 5d8ae96a56
commit 35bfec1511

View file

@ -255,24 +255,30 @@ void Edge::switchDesktop(const QPoint &cursorPos)
{ {
QPoint pos(cursorPos); QPoint pos(cursorPos);
VirtualDesktopManager *vds = VirtualDesktopManager::self(); VirtualDesktopManager *vds = VirtualDesktopManager::self();
uint desktop = vds->current();
const uint oldDesktop = vds->current(); const uint oldDesktop = vds->current();
uint desktop = oldDesktop;
const int OFFSET = 2; const int OFFSET = 2;
if (isLeft()) { if (isLeft()) {
const uint interimDesktop = desktop;
desktop = vds->toLeft(desktop, vds->isNavigationWrappingAround()); desktop = vds->toLeft(desktop, vds->isNavigationWrappingAround());
pos.setX(displayWidth() - 1 - OFFSET); if (desktop != interimDesktop)
} pos.setX(displayWidth() - 1 - OFFSET);
if (isRight()) { } else if (isRight()) {
const uint interimDesktop = desktop;
desktop = vds->toRight(desktop, vds->isNavigationWrappingAround()); desktop = vds->toRight(desktop, vds->isNavigationWrappingAround());
pos.setX(OFFSET); if (desktop != interimDesktop)
pos.setX(OFFSET);
} }
if (isTop()) { if (isTop()) {
const uint interimDesktop = desktop;
desktop = vds->above(desktop, vds->isNavigationWrappingAround()); desktop = vds->above(desktop, vds->isNavigationWrappingAround());
pos.setY(displayHeight() - 1 - OFFSET); if (desktop != interimDesktop)
} pos.setY(displayHeight() - 1 - OFFSET);
if (isBottom()) { } else if (isBottom()) {
const uint interimDesktop = desktop;
desktop = vds->below(desktop, vds->isNavigationWrappingAround()); desktop = vds->below(desktop, vds->isNavigationWrappingAround());
pos.setY(OFFSET); if (desktop != interimDesktop)
pos.setY(OFFSET);
} }
if (Client *c = Workspace::self()->getMovingClient()) { if (Client *c = Workspace::self()->getMovingClient()) {
if (c->rules()->checkDesktop(desktop) != int(desktop)) { if (c->rules()->checkDesktop(desktop) != int(desktop)) {