| 701 | } |
| 702 | |
| 703 | void Server::avoidJumpZone(const BaseClientProxy *dst, Direction dir, int32_t &x, int32_t &y) const |
| 704 | { |
| 705 | // we only need to avoid jump zones on the primary screen |
| 706 | if (dst != m_primaryClient) { |
| 707 | return; |
| 708 | } |
| 709 | |
| 710 | const std::string dstName(getName(dst)); |
| 711 | int32_t dx; |
| 712 | int32_t dy; |
| 713 | int32_t dw; |
| 714 | int32_t dh; |
| 715 | dst->getShape(dx, dy, dw, dh); |
| 716 | float t = mapToFraction(dst, dir, x, y); |
| 717 | int32_t z = getJumpZoneSize(dst); |
| 718 | |
| 719 | // move in far enough to avoid the jump zone. if entering a side |
| 720 | // that doesn't have a neighbor (i.e. an asymmetrical side) then we |
| 721 | // don't need to move inwards because that side can't provoke a jump. |
| 722 | switch (dir) { |
| 723 | using enum Direction; |
| 724 | case Left: |
| 725 | if (!m_config->getNeighbor(dstName, Right, t, nullptr).empty() && x > dx + dw - 1 - z) |
| 726 | x = dx + dw - 1 - z; |
| 727 | break; |
| 728 | |
| 729 | case Right: |
| 730 | if (!m_config->getNeighbor(dstName, Left, t, nullptr).empty() && x < dx + z) |
| 731 | x = dx + z; |
| 732 | break; |
| 733 | |
| 734 | case Top: |
| 735 | if (!m_config->getNeighbor(dstName, Bottom, t, nullptr).empty() && y > dy + dh - 1 - z) |
| 736 | y = dy + dh - 1 - z; |
| 737 | break; |
| 738 | |
| 739 | case Bottom: |
| 740 | if (!m_config->getNeighbor(dstName, Top, t, nullptr).empty() && y < dy + z) |
| 741 | y = dy + z; |
| 742 | break; |
| 743 | |
| 744 | case NoDirection: |
| 745 | assert(0 && "bad direction"); |
| 746 | } |
| 747 | } |
| 748 | |
| 749 | bool Server::isSwitchOkay( |
| 750 | BaseClientProxy *newScreen, Direction dir, int32_t x, int32_t y, int32_t xActive, int32_t yActive |
nothing calls this directly
no test coverage detected