Changeset View
Changeset View
Standalone View
Standalone View
placement.cpp
Show First 20 Lines • Show All 837 Lines • ▼ Show 20 Line(s) | |||||
838 | { | 838 | { | ||
839 | if (!active_client) { | 839 | if (!active_client) { | ||
840 | return; | 840 | return; | ||
841 | } | 841 | } | ||
842 | 842 | | |||
843 | active_client->setQuickTileMode(mode, true); | 843 | active_client->setQuickTileMode(mode, true); | ||
844 | } | 844 | } | ||
845 | 845 | | |||
846 | int Workspace::packPositionLeft(const AbstractClient* cl, int oldx, bool left_edge) const | 846 | int Workspace::packPositionLeft(const AbstractClient *client, int oldX, bool leftEdge) const | ||
847 | { | 847 | { | ||
848 | int newx = clientArea(MaximizeArea, cl).left(); | 848 | int newX = clientArea(MaximizeArea, client).left(); | ||
849 | if (oldx <= newx) // try another Xinerama screen | 849 | if (oldX <= newX) { // try another Xinerama screen | ||
850 | newx = clientArea(MaximizeArea, | 850 | newX = clientArea(MaximizeArea, | ||
851 | QPoint(cl->frameGeometry().left() - 1, cl->frameGeometry().center().y()), cl->desktop()).left(); | 851 | QPoint(client->frameGeometry().left() - 1, client->frameGeometry().center().y()), client->desktop()).left(); | ||
852 | if (cl->titlebarPosition() != AbstractClient::PositionLeft) { | 852 | } | ||
853 | QRect geo = cl->frameGeometry(); | 853 | if (client->titlebarPosition() != AbstractClient::PositionLeft) { | ||
854 | int rgt = newx - cl->clientPos().x(); | 854 | const int right = newX - client->clientPos().x(); | ||
855 | geo.moveRight(rgt); | 855 | QRect frameGeometry = client->frameGeometry(); | ||
856 | if (screens()->intersecting(geo) < 2) | 856 | frameGeometry.moveRight(right); | ||
857 | newx = rgt; | 857 | if (screens()->intersecting(frameGeometry) < 2) { | ||
858 | } | 858 | newX = right; | ||
859 | if (oldx <= newx) | 859 | } | ||
860 | return oldx; | 860 | } | ||
861 | const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop(); | 861 | if (oldX <= newX) { | ||
862 | return oldX; | ||||
863 | } | ||||
864 | const int desktop = client->desktop() == 0 || client->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : client->desktop(); | ||||
862 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | 865 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | ||
863 | if (isIrrelevant(*it, cl, desktop)) | 866 | if (isIrrelevant(*it, client, desktop)) { | ||
864 | continue; | 867 | continue; | ||
865 | int x = left_edge ? (*it)->frameGeometry().right() + 1 : (*it)->frameGeometry().left() - 1; | 868 | } | ||
866 | if (x > newx && x < oldx | 869 | const int x = leftEdge ? (*it)->frameGeometry().right() + 1 : (*it)->frameGeometry().left() - 1; | ||
867 | && !(cl->frameGeometry().top() > (*it)->frameGeometry().bottom() // they overlap in Y direction | 870 | if (x > newX && x < oldX | ||
868 | || cl->frameGeometry().bottom() < (*it)->frameGeometry().top())) | 871 | && !(client->frameGeometry().top() > (*it)->frameGeometry().bottom() // they overlap in Y direction | ||
869 | newx = x; | 872 | || client->frameGeometry().bottom() < (*it)->frameGeometry().top())) { | ||
870 | } | 873 | newX = x; | ||
871 | return newx; | 874 | } | ||
872 | } | 875 | } | ||
873 | 876 | return newX; | |||
874 | int Workspace::packPositionRight(const AbstractClient* cl, int oldx, bool right_edge) const | 877 | } | ||
875 | { | 878 | | ||
876 | int newx = clientArea(MaximizeArea, cl).right(); | 879 | int Workspace::packPositionRight(const AbstractClient *client, int oldX, bool rightEdge) const | ||
877 | if (oldx >= newx) // try another Xinerama screen | 880 | { | ||
878 | newx = clientArea(MaximizeArea, | 881 | int newX = clientArea(MaximizeArea, client).right(); | ||
879 | QPoint(cl->frameGeometry().right() + 1, cl->frameGeometry().center().y()), cl->desktop()).right(); | 882 | if (oldX >= newX) { // try another Xinerama screen | ||
880 | if (cl->titlebarPosition() != AbstractClient::PositionRight) { | 883 | newX = clientArea(MaximizeArea, | ||
881 | QRect geo = cl->frameGeometry(); | 884 | QPoint(client->frameGeometry().right() + 1, client->frameGeometry().center().y()), client->desktop()).right(); | ||
882 | int rgt = newx + cl->width() - (cl->clientSize().width() + cl->clientPos().x()); | 885 | } | ||
883 | geo.moveRight(rgt); | 886 | if (client->titlebarPosition() != AbstractClient::PositionRight) { | ||
884 | if (screens()->intersecting(geo) < 2) | 887 | const int right = newX + client->width() - (client->clientSize().width() + client->clientPos().x()); | ||
885 | newx = rgt; | 888 | QRect frameGeometry = client->frameGeometry(); | ||
886 | } | 889 | frameGeometry.moveRight(right); | ||
887 | if (oldx >= newx) | 890 | if (screens()->intersecting(frameGeometry) < 2) { | ||
888 | return oldx; | 891 | newX = right; | ||
889 | const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop(); | 892 | } | ||
893 | } | ||||
894 | if (oldX >= newX) { | ||||
895 | return oldX; | ||||
896 | } | ||||
897 | const int desktop = client->desktop() == 0 || client->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : client->desktop(); | ||||
890 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | 898 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | ||
891 | if (isIrrelevant(*it, cl, desktop)) | 899 | if (isIrrelevant(*it, client, desktop)) { | ||
892 | continue; | 900 | continue; | ||
893 | int x = right_edge ? (*it)->frameGeometry().left() - 1 : (*it)->frameGeometry().right() + 1; | 901 | } | ||
894 | if (x < newx && x > oldx | 902 | const int x = rightEdge ? (*it)->frameGeometry().left() - 1 : (*it)->frameGeometry().right() + 1; | ||
895 | && !(cl->frameGeometry().top() > (*it)->frameGeometry().bottom() | 903 | if (x < newX && x > oldX | ||
896 | || cl->frameGeometry().bottom() < (*it)->frameGeometry().top())) | 904 | && !(client->frameGeometry().top() > (*it)->frameGeometry().bottom() | ||
897 | newx = x; | 905 | || client->frameGeometry().bottom() < (*it)->frameGeometry().top())) { | ||
898 | } | 906 | newX = x; | ||
899 | return newx; | 907 | } | ||
900 | } | 908 | } | ||
901 | 909 | return newX; | |||
902 | int Workspace::packPositionUp(const AbstractClient* cl, int oldy, bool top_edge) const | 910 | } | ||
903 | { | 911 | | ||
904 | int newy = clientArea(MaximizeArea, cl).top(); | 912 | int Workspace::packPositionUp(const AbstractClient *client, int oldY, bool topEdge) const | ||
905 | if (oldy <= newy) // try another Xinerama screen | 913 | { | ||
906 | newy = clientArea(MaximizeArea, | 914 | int newY = clientArea(MaximizeArea, client).top(); | ||
907 | QPoint(cl->frameGeometry().center().x(), cl->frameGeometry().top() - 1), cl->desktop()).top(); | 915 | if (oldY <= newY) { // try another Xinerama screen | ||
908 | if (cl->titlebarPosition() != AbstractClient::PositionTop) { | 916 | newY = clientArea(MaximizeArea, | ||
909 | QRect geo = cl->frameGeometry(); | 917 | QPoint(client->frameGeometry().center().x(), client->frameGeometry().top() - 1), client->desktop()).top(); | ||
910 | int top = newy - cl->clientPos().y(); | 918 | } | ||
911 | geo.moveTop(top); | 919 | if (client->titlebarPosition() != AbstractClient::PositionTop) { | ||
912 | if (screens()->intersecting(geo) < 2) | 920 | const int top = newY - client->clientPos().y(); | ||
913 | newy = top; | 921 | QRect frameGeometry = client->frameGeometry(); | ||
914 | } | 922 | frameGeometry.moveTop(top); | ||
915 | if (oldy <= newy) | 923 | if (screens()->intersecting(frameGeometry) < 2) { | ||
916 | return oldy; | 924 | newY = top; | ||
917 | const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop(); | 925 | } | ||
926 | } | ||||
927 | if (oldY <= newY) { | ||||
928 | return oldY; | ||||
929 | } | ||||
930 | const int desktop = client->desktop() == 0 || client->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : client->desktop(); | ||||
918 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | 931 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | ||
919 | if (isIrrelevant(*it, cl, desktop)) | 932 | if (isIrrelevant(*it, client, desktop)) { | ||
920 | continue; | 933 | continue; | ||
921 | int y = top_edge ? (*it)->frameGeometry().bottom() + 1 : (*it)->frameGeometry().top() - 1; | 934 | } | ||
922 | if (y > newy && y < oldy | 935 | const int y = topEdge ? (*it)->frameGeometry().bottom() + 1 : (*it)->frameGeometry().top() - 1; | ||
923 | && !(cl->frameGeometry().left() > (*it)->frameGeometry().right() // they overlap in X direction | 936 | if (y > newY && y < oldY | ||
924 | || cl->frameGeometry().right() < (*it)->frameGeometry().left())) | 937 | && !(client->frameGeometry().left() > (*it)->frameGeometry().right() // they overlap in X direction | ||
925 | newy = y; | 938 | || client->frameGeometry().right() < (*it)->frameGeometry().left())) { | ||
926 | } | 939 | newY = y; | ||
927 | return newy; | 940 | } | ||
928 | } | 941 | } | ||
929 | 942 | return newY; | |||
930 | int Workspace::packPositionDown(const AbstractClient* cl, int oldy, bool bottom_edge) const | 943 | } | ||
931 | { | 944 | | ||
932 | int newy = clientArea(MaximizeArea, cl).bottom(); | 945 | int Workspace::packPositionDown(const AbstractClient *client, int oldY, bool bottomEdge) const | ||
933 | if (oldy >= newy) // try another Xinerama screen | 946 | { | ||
934 | newy = clientArea(MaximizeArea, | 947 | int newY = clientArea(MaximizeArea, client).bottom(); | ||
935 | QPoint(cl->frameGeometry().center().x(), cl->frameGeometry().bottom() + 1), cl->desktop()).bottom(); | 948 | if (oldY >= newY) { // try another Xinerama screen | ||
936 | if (cl->titlebarPosition() != AbstractClient::PositionBottom) { | 949 | newY = clientArea(MaximizeArea, | ||
937 | QRect geo = cl->frameGeometry(); | 950 | QPoint(client->frameGeometry().center().x(), client->frameGeometry().bottom() + 1), client->desktop()).bottom(); | ||
938 | int btm = newy + cl->height() - (cl->clientSize().height() + cl->clientPos().y()); | 951 | } | ||
939 | geo.moveBottom(btm); | 952 | if (client->titlebarPosition() != AbstractClient::PositionBottom) { | ||
940 | if (screens()->intersecting(geo) < 2) | 953 | const int bottom = newY + client->height() - (client->clientSize().height() + client->clientPos().y()); | ||
941 | newy = btm; | 954 | QRect frameGeometry = client->frameGeometry(); | ||
942 | } | 955 | frameGeometry.moveBottom(bottom); | ||
943 | if (oldy >= newy) | 956 | if (screens()->intersecting(frameGeometry) < 2) { | ||
944 | return oldy; | 957 | newY = bottom; | ||
945 | const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop(); | 958 | } | ||
959 | } | ||||
960 | if (oldY >= newY) { | ||||
961 | return oldY; | ||||
962 | } | ||||
963 | const int desktop = client->desktop() == 0 || client->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : client->desktop(); | ||||
946 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | 964 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | ||
947 | if (isIrrelevant(*it, cl, desktop)) | 965 | if (isIrrelevant(*it, client, desktop)) { | ||
948 | continue; | 966 | continue; | ||
949 | int y = bottom_edge ? (*it)->frameGeometry().top() - 1 : (*it)->frameGeometry().bottom() + 1; | | |||
950 | if (y < newy && y > oldy | | |||
951 | && !(cl->frameGeometry().left() > (*it)->frameGeometry().right() | | |||
952 | || cl->frameGeometry().right() < (*it)->frameGeometry().left())) | | |||
953 | newy = y; | | |||
954 | } | 967 | } | ||
955 | return newy; | 968 | const int y = bottomEdge ? (*it)->frameGeometry().top() - 1 : (*it)->frameGeometry().bottom() + 1; | ||
969 | if (y < newY && y > oldY | ||||
970 | && !(client->frameGeometry().left() > (*it)->frameGeometry().right() | ||||
971 | || client->frameGeometry().right() < (*it)->frameGeometry().left())) { | ||||
972 | newY = y; | ||||
973 | } | ||||
974 | } | ||||
975 | return newY; | ||||
956 | } | 976 | } | ||
957 | 977 | | |||
958 | #endif | 978 | #endif | ||
959 | 979 | | |||
960 | } // namespace | 980 | } // namespace |