Changeset View
Changeset View
Standalone View
Standalone View
placement.cpp
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 99 | else if (policy == OnMainWindow) | |||
---|---|---|---|---|---|
100 | placeOnMainWindow(c, area, nextPlacement); | 100 | placeOnMainWindow(c, area, nextPlacement); | ||
101 | else if (policy == Maximizing) | 101 | else if (policy == Maximizing) | ||
102 | placeMaximizing(c, area, nextPlacement); | 102 | placeMaximizing(c, area, nextPlacement); | ||
103 | else | 103 | else | ||
104 | placeSmart(c, area, nextPlacement); | 104 | placeSmart(c, area, nextPlacement); | ||
105 | 105 | | |||
106 | if (options->borderSnapZone()) { | 106 | if (options->borderSnapZone()) { | ||
107 | // snap to titlebar / snap to window borders on inner screen edges | 107 | // snap to titlebar / snap to window borders on inner screen edges | ||
108 | const QRect geo(c->geometry()); | 108 | const QRect geo(c->frameGeometry()); | ||
109 | QPoint corner = geo.topLeft(); | 109 | QPoint corner = geo.topLeft(); | ||
110 | const QMargins frameMargins = c->frameMargins(); | 110 | const QMargins frameMargins = c->frameMargins(); | ||
111 | AbstractClient::Position titlePos = c->titlebarPosition(); | 111 | AbstractClient::Position titlePos = c->titlebarPosition(); | ||
112 | 112 | | |||
113 | const QRect fullRect = workspace()->clientArea(FullArea, c); | 113 | const QRect fullRect = workspace()->clientArea(FullArea, c); | ||
114 | if (!(c->maximizeMode() & MaximizeHorizontal)) { | 114 | if (!(c->maximizeMode() & MaximizeHorizontal)) { | ||
115 | if (titlePos != AbstractClient::PositionRight && geo.right() == fullRect.right()) { | 115 | if (titlePos != AbstractClient::PositionRight && geo.right() == fullRect.right()) { | ||
116 | corner.rx() += frameMargins.right(); | 116 | corner.rx() += frameMargins.right(); | ||
▲ Show 20 Lines • Show All 255 Lines • ▼ Show 20 Line(s) | 361 | { | |||
372 | } else { | 372 | } else { | ||
373 | cci[desktop - 1].pos = QPoint(-1, -1); | 373 | cci[desktop - 1].pos = QPoint(-1, -1); | ||
374 | cci[desktop - 1].col = cci[desktop - 1].row = 0; | 374 | cci[desktop - 1].col = cci[desktop - 1].row = 0; | ||
375 | } | 375 | } | ||
376 | } | 376 | } | ||
377 | 377 | | |||
378 | QPoint Workspace::cascadeOffset(const AbstractClient *c) const | 378 | QPoint Workspace::cascadeOffset(const AbstractClient *c) const | ||
379 | { | 379 | { | ||
380 | QRect area = clientArea(PlacementArea, c->geometry().center(), c->desktop()); | 380 | QRect area = clientArea(PlacementArea, c->frameGeometry().center(), c->desktop()); | ||
381 | return QPoint(area.width()/48, area.height()/48); | 381 | return QPoint(area.width()/48, area.height()/48); | ||
382 | } | 382 | } | ||
383 | 383 | | |||
384 | /** | 384 | /** | ||
385 | * Place windows in a cascading order, remembering positions for each desktop | 385 | * Place windows in a cascading order, remembering positions for each desktop | ||
386 | */ | 386 | */ | ||
387 | void Placement::placeCascaded(AbstractClient *c, const QRect &area, Policy nextPlacement) | 387 | void Placement::placeCascaded(AbstractClient *c, const QRect &area, Policy nextPlacement) | ||
388 | { | 388 | { | ||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Line(s) | 504 | { | |||
511 | c->move(QPoint(x, y)); | 511 | c->move(QPoint(x, y)); | ||
512 | } | 512 | } | ||
513 | 513 | | |||
514 | void Placement::placeTransient(AbstractClient *c) | 514 | void Placement::placeTransient(AbstractClient *c) | ||
515 | { | 515 | { | ||
516 | const auto parent = c->transientFor(); | 516 | const auto parent = c->transientFor(); | ||
517 | const QRect screen = Workspace::self()->clientArea(parent->isFullScreen() ? FullScreenArea : PlacementArea, parent); | 517 | const QRect screen = Workspace::self()->clientArea(parent->isFullScreen() ? FullScreenArea : PlacementArea, parent); | ||
518 | const QRect popupGeometry = c->transientPlacement(screen); | 518 | const QRect popupGeometry = c->transientPlacement(screen); | ||
519 | c->setGeometry(popupGeometry); | 519 | c->setFrameGeometry(popupGeometry); | ||
520 | 520 | | |||
521 | 521 | | |||
522 | // Potentially a client could set no constraint adjustments | 522 | // Potentially a client could set no constraint adjustments | ||
523 | // and we'll be offscreen. | 523 | // and we'll be offscreen. | ||
524 | 524 | | |||
525 | // The spec implies we should place window the offscreen. However, | 525 | // The spec implies we should place window the offscreen. However, | ||
526 | // practically Qt doesn't set any constraint adjustments yet so we can't. | 526 | // practically Qt doesn't set any constraint adjustments yet so we can't. | ||
527 | // Also kwin generally doesn't let clients do what they want | 527 | // Also kwin generally doesn't let clients do what they want | ||
528 | if (!screen.contains(c->geometry())) { | 528 | if (!screen.contains(c->frameGeometry())) { | ||
529 | c->keepInArea(screen); | 529 | c->keepInArea(screen); | ||
530 | } | 530 | } | ||
531 | } | 531 | } | ||
532 | 532 | | |||
533 | void Placement::placeDialog(AbstractClient *c, const QRect &area, Policy nextPlacement) | 533 | void Placement::placeDialog(AbstractClient *c, const QRect &area, Policy nextPlacement) | ||
534 | { | 534 | { | ||
535 | placeOnMainWindow(c, area, nextPlacement); | 535 | placeOnMainWindow(c, area, nextPlacement); | ||
536 | } | 536 | } | ||
537 | 537 | | |||
538 | void Placement::placeUnderMouse(AbstractClient *c, const QRect &area, Policy /*next*/) | 538 | void Placement::placeUnderMouse(AbstractClient *c, const QRect &area, Policy /*next*/) | ||
539 | { | 539 | { | ||
540 | Q_ASSERT(area.isValid()); | 540 | Q_ASSERT(area.isValid()); | ||
541 | 541 | | |||
542 | QRect geom = c->geometry(); | 542 | QRect geom = c->frameGeometry(); | ||
543 | geom.moveCenter(Cursor::pos()); | 543 | geom.moveCenter(Cursor::pos()); | ||
544 | c->move(geom.topLeft()); | 544 | c->move(geom.topLeft()); | ||
545 | c->keepInArea(area); // make sure it's kept inside workarea | 545 | c->keepInArea(area); // make sure it's kept inside workarea | ||
546 | } | 546 | } | ||
547 | 547 | | |||
548 | void Placement::placeOnMainWindow(AbstractClient *c, const QRect &area, Policy nextPlacement) | 548 | void Placement::placeOnMainWindow(AbstractClient *c, const QRect &area, Policy nextPlacement) | ||
549 | { | 549 | { | ||
550 | Q_ASSERT(area.isValid()); | 550 | Q_ASSERT(area.isValid()); | ||
Show All 35 Lines | 584 | if (mains_count != 1) { | |||
586 | return; | 586 | return; | ||
587 | } | 587 | } | ||
588 | place_on = place_on2; // use the only window filtered together with 'mains_count' | 588 | place_on = place_on2; // use the only window filtered together with 'mains_count' | ||
589 | } | 589 | } | ||
590 | if (place_on->isDesktop()) { | 590 | if (place_on->isDesktop()) { | ||
591 | place(c, area, Centered); | 591 | place(c, area, Centered); | ||
592 | return; | 592 | return; | ||
593 | } | 593 | } | ||
594 | QRect geom = c->geometry(); | 594 | QRect geom = c->frameGeometry(); | ||
595 | geom.moveCenter(place_on->geometry().center()); | 595 | geom.moveCenter(place_on->frameGeometry().center()); | ||
596 | c->move(geom.topLeft()); | 596 | c->move(geom.topLeft()); | ||
597 | // get area again, because the mainwindow may be on different xinerama screen | 597 | // get area again, because the mainwindow may be on different xinerama screen | ||
598 | const QRect placementArea = workspace()->clientArea(PlacementArea, c); | 598 | const QRect placementArea = workspace()->clientArea(PlacementArea, c); | ||
599 | c->keepInArea(placementArea); // make sure it's kept inside workarea | 599 | c->keepInArea(placementArea); // make sure it's kept inside workarea | ||
600 | } | 600 | } | ||
601 | 601 | | |||
602 | void Placement::placeMaximizing(AbstractClient *c, const QRect &area, Policy nextPlacement) | 602 | void Placement::placeMaximizing(AbstractClient *c, const QRect &area, Policy nextPlacement) | ||
603 | { | 603 | { | ||
604 | Q_ASSERT(area.isValid()); | 604 | Q_ASSERT(area.isValid()); | ||
605 | 605 | | |||
606 | if (nextPlacement == Unknown) | 606 | if (nextPlacement == Unknown) | ||
607 | nextPlacement = Smart; | 607 | nextPlacement = Smart; | ||
608 | if (c->isMaximizable() && c->maxSize().width() >= area.width() && c->maxSize().height() >= area.height()) { | 608 | if (c->isMaximizable() && c->maxSize().width() >= area.width() && c->maxSize().height() >= area.height()) { | ||
609 | if (workspace()->clientArea(MaximizeArea, c) == area) | 609 | if (workspace()->clientArea(MaximizeArea, c) == area) | ||
610 | c->maximize(MaximizeFull); | 610 | c->maximize(MaximizeFull); | ||
611 | else { // if the geometry doesn't match default maximize area (xinerama case?), | 611 | else { // if the geometry doesn't match default maximize area (xinerama case?), | ||
612 | // it's probably better to use the given area | 612 | // it's probably better to use the given area | ||
613 | c->setGeometry(area); | 613 | c->setFrameGeometry(area); | ||
614 | } | 614 | } | ||
615 | } else { | 615 | } else { | ||
616 | c->resizeWithChecks(c->maxSize().boundedTo(area.size())); | 616 | c->resizeWithChecks(c->maxSize().boundedTo(area.size())); | ||
617 | place(c, area, nextPlacement); | 617 | place(c, area, nextPlacement); | ||
618 | } | 618 | } | ||
619 | } | 619 | } | ||
620 | 620 | | |||
621 | void Placement::cascadeDesktop() | 621 | void Placement::cascadeDesktop() | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | |||||
709 | } | 709 | } | ||
710 | 710 | | |||
711 | /** | 711 | /** | ||
712 | * Moves active window left until in bumps into another window or workarea edge. | 712 | * Moves active window left until in bumps into another window or workarea edge. | ||
713 | */ | 713 | */ | ||
714 | void Workspace::slotWindowPackLeft() | 714 | void Workspace::slotWindowPackLeft() | ||
715 | { | 715 | { | ||
716 | if (active_client && active_client->isMovable()) | 716 | if (active_client && active_client->isMovable()) | ||
717 | active_client->packTo(packPositionLeft(active_client, active_client->geometry().left(), true), | 717 | active_client->packTo(packPositionLeft(active_client, active_client->frameGeometry().left(), true), | ||
718 | active_client->y()); | 718 | active_client->y()); | ||
719 | } | 719 | } | ||
720 | 720 | | |||
721 | void Workspace::slotWindowPackRight() | 721 | void Workspace::slotWindowPackRight() | ||
722 | { | 722 | { | ||
723 | if (active_client && active_client->isMovable()) | 723 | if (active_client && active_client->isMovable()) | ||
724 | active_client->packTo(packPositionRight(active_client, active_client->geometry().right(), true) | 724 | active_client->packTo(packPositionRight(active_client, active_client->frameGeometry().right(), true) | ||
725 | - active_client->width() + 1, active_client->y()); | 725 | - active_client->width() + 1, active_client->y()); | ||
726 | } | 726 | } | ||
727 | 727 | | |||
728 | void Workspace::slotWindowPackUp() | 728 | void Workspace::slotWindowPackUp() | ||
729 | { | 729 | { | ||
730 | if (active_client && active_client->isMovable()) | 730 | if (active_client && active_client->isMovable()) | ||
731 | active_client->packTo(active_client->x(), | 731 | active_client->packTo(active_client->x(), | ||
732 | packPositionUp(active_client, active_client->geometry().top(), true)); | 732 | packPositionUp(active_client, active_client->frameGeometry().top(), true)); | ||
733 | } | 733 | } | ||
734 | 734 | | |||
735 | void Workspace::slotWindowPackDown() | 735 | void Workspace::slotWindowPackDown() | ||
736 | { | 736 | { | ||
737 | if (active_client && active_client->isMovable()) | 737 | if (active_client && active_client->isMovable()) | ||
738 | active_client->packTo(active_client->x(), | 738 | active_client->packTo(active_client->x(), | ||
739 | packPositionDown(active_client, active_client->geometry().bottom(), true) - active_client->height() + 1); | 739 | packPositionDown(active_client, active_client->frameGeometry().bottom(), true) - active_client->height() + 1); | ||
740 | } | 740 | } | ||
741 | 741 | | |||
742 | void Workspace::slotWindowGrowHorizontal() | 742 | void Workspace::slotWindowGrowHorizontal() | ||
743 | { | 743 | { | ||
744 | if (active_client) | 744 | if (active_client) | ||
745 | active_client->growHorizontal(); | 745 | active_client->growHorizontal(); | ||
746 | } | 746 | } | ||
747 | 747 | | |||
748 | void AbstractClient::growHorizontal() | 748 | void AbstractClient::growHorizontal() | ||
749 | { | 749 | { | ||
750 | if (!isResizable() || isShade()) | 750 | if (!isResizable() || isShade()) | ||
751 | return; | 751 | return; | ||
752 | QRect geom = geometry(); | 752 | QRect geom = frameGeometry(); | ||
753 | geom.setRight(workspace()->packPositionRight(this, geom.right(), true)); | 753 | geom.setRight(workspace()->packPositionRight(this, geom.right(), true)); | ||
754 | QSize adjsize = adjustedSize(geom.size(), SizemodeFixedW); | 754 | QSize adjsize = adjustedSize(geom.size(), SizemodeFixedW); | ||
755 | if (geometry().size() == adjsize && geom.size() != adjsize && resizeIncrements().width() > 1) { // take care of size increments | 755 | if (frameGeometry().size() == adjsize && geom.size() != adjsize && resizeIncrements().width() > 1) { // take care of size increments | ||
756 | int newright = workspace()->packPositionRight(this, geom.right() + resizeIncrements().width() - 1, true); | 756 | int newright = workspace()->packPositionRight(this, geom.right() + resizeIncrements().width() - 1, true); | ||
757 | // check that it hasn't grown outside of the area, due to size increments | 757 | // check that it hasn't grown outside of the area, due to size increments | ||
758 | // TODO this may be wrong? | 758 | // TODO this may be wrong? | ||
759 | if (workspace()->clientArea(MovementArea, | 759 | if (workspace()->clientArea(MovementArea, | ||
760 | QPoint((x() + newright) / 2, geometry().center().y()), desktop()).right() >= newright) | 760 | QPoint((x() + newright) / 2, frameGeometry().center().y()), desktop()).right() >= newright) | ||
761 | geom.setRight(newright); | 761 | geom.setRight(newright); | ||
762 | } | 762 | } | ||
763 | geom.setSize(adjustedSize(geom.size(), SizemodeFixedW)); | 763 | geom.setSize(adjustedSize(geom.size(), SizemodeFixedW)); | ||
764 | geom.setSize(adjustedSize(geom.size(), SizemodeFixedH)); | 764 | geom.setSize(adjustedSize(geom.size(), SizemodeFixedH)); | ||
765 | workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event; | 765 | workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event; | ||
766 | setGeometry(geom); | 766 | setFrameGeometry(geom); | ||
767 | } | 767 | } | ||
768 | 768 | | |||
769 | void Workspace::slotWindowShrinkHorizontal() | 769 | void Workspace::slotWindowShrinkHorizontal() | ||
770 | { | 770 | { | ||
771 | if (active_client) | 771 | if (active_client) | ||
772 | active_client->shrinkHorizontal(); | 772 | active_client->shrinkHorizontal(); | ||
773 | } | 773 | } | ||
774 | 774 | | |||
775 | void AbstractClient::shrinkHorizontal() | 775 | void AbstractClient::shrinkHorizontal() | ||
776 | { | 776 | { | ||
777 | if (!isResizable() || isShade()) | 777 | if (!isResizable() || isShade()) | ||
778 | return; | 778 | return; | ||
779 | QRect geom = geometry(); | 779 | QRect geom = frameGeometry(); | ||
780 | geom.setRight(workspace()->packPositionLeft(this, geom.right(), false)); | 780 | geom.setRight(workspace()->packPositionLeft(this, geom.right(), false)); | ||
781 | if (geom.width() <= 1) | 781 | if (geom.width() <= 1) | ||
782 | return; | 782 | return; | ||
783 | geom.setSize(adjustedSize(geom.size(), SizemodeFixedW)); | 783 | geom.setSize(adjustedSize(geom.size(), SizemodeFixedW)); | ||
784 | if (geom.width() > 20) { | 784 | if (geom.width() > 20) { | ||
785 | workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event; | 785 | workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event; | ||
786 | setGeometry(geom); | 786 | setFrameGeometry(geom); | ||
787 | } | 787 | } | ||
788 | } | 788 | } | ||
789 | 789 | | |||
790 | void Workspace::slotWindowGrowVertical() | 790 | void Workspace::slotWindowGrowVertical() | ||
791 | { | 791 | { | ||
792 | if (active_client) | 792 | if (active_client) | ||
793 | active_client->growVertical(); | 793 | active_client->growVertical(); | ||
794 | } | 794 | } | ||
795 | 795 | | |||
796 | void AbstractClient::growVertical() | 796 | void AbstractClient::growVertical() | ||
797 | { | 797 | { | ||
798 | if (!isResizable() || isShade()) | 798 | if (!isResizable() || isShade()) | ||
799 | return; | 799 | return; | ||
800 | QRect geom = geometry(); | 800 | QRect geom = frameGeometry(); | ||
801 | geom.setBottom(workspace()->packPositionDown(this, geom.bottom(), true)); | 801 | geom.setBottom(workspace()->packPositionDown(this, geom.bottom(), true)); | ||
802 | QSize adjsize = adjustedSize(geom.size(), SizemodeFixedH); | 802 | QSize adjsize = adjustedSize(geom.size(), SizemodeFixedH); | ||
803 | if (geometry().size() == adjsize && geom.size() != adjsize && resizeIncrements().height() > 1) { // take care of size increments | 803 | if (frameGeometry().size() == adjsize && geom.size() != adjsize && resizeIncrements().height() > 1) { // take care of size increments | ||
804 | int newbottom = workspace()->packPositionDown(this, geom.bottom() + resizeIncrements().height() - 1, true); | 804 | int newbottom = workspace()->packPositionDown(this, geom.bottom() + resizeIncrements().height() - 1, true); | ||
805 | // check that it hasn't grown outside of the area, due to size increments | 805 | // check that it hasn't grown outside of the area, due to size increments | ||
806 | if (workspace()->clientArea(MovementArea, | 806 | if (workspace()->clientArea(MovementArea, | ||
807 | QPoint(geometry().center().x(), (y() + newbottom) / 2), desktop()).bottom() >= newbottom) | 807 | QPoint(frameGeometry().center().x(), (y() + newbottom) / 2), desktop()).bottom() >= newbottom) | ||
808 | geom.setBottom(newbottom); | 808 | geom.setBottom(newbottom); | ||
809 | } | 809 | } | ||
810 | geom.setSize(adjustedSize(geom.size(), SizemodeFixedH)); | 810 | geom.setSize(adjustedSize(geom.size(), SizemodeFixedH)); | ||
811 | workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event; | 811 | workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event; | ||
812 | setGeometry(geom); | 812 | setFrameGeometry(geom); | ||
813 | } | 813 | } | ||
814 | 814 | | |||
815 | 815 | | |||
816 | void Workspace::slotWindowShrinkVertical() | 816 | void Workspace::slotWindowShrinkVertical() | ||
817 | { | 817 | { | ||
818 | if (active_client) | 818 | if (active_client) | ||
819 | active_client->shrinkVertical(); | 819 | active_client->shrinkVertical(); | ||
820 | } | 820 | } | ||
821 | 821 | | |||
822 | void AbstractClient::shrinkVertical() | 822 | void AbstractClient::shrinkVertical() | ||
823 | { | 823 | { | ||
824 | if (!isResizable() || isShade()) | 824 | if (!isResizable() || isShade()) | ||
825 | return; | 825 | return; | ||
826 | QRect geom = geometry(); | 826 | QRect geom = frameGeometry(); | ||
827 | geom.setBottom(workspace()->packPositionUp(this, geom.bottom(), false)); | 827 | geom.setBottom(workspace()->packPositionUp(this, geom.bottom(), false)); | ||
828 | if (geom.height() <= 1) | 828 | if (geom.height() <= 1) | ||
829 | return; | 829 | return; | ||
830 | geom.setSize(adjustedSize(geom.size(), SizemodeFixedH)); | 830 | geom.setSize(adjustedSize(geom.size(), SizemodeFixedH)); | ||
831 | if (geom.height() > 20) { | 831 | if (geom.height() > 20) { | ||
832 | workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event; | 832 | workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event; | ||
833 | setGeometry(geom); | 833 | setFrameGeometry(geom); | ||
834 | } | 834 | } | ||
835 | } | 835 | } | ||
836 | 836 | | |||
837 | void Workspace::quickTileWindow(QuickTileMode mode) | 837 | void Workspace::quickTileWindow(QuickTileMode mode) | ||
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* cl, int oldx, bool left_edge) const | ||
847 | { | 847 | { | ||
848 | int newx = clientArea(MaximizeArea, cl).left(); | 848 | int newx = clientArea(MaximizeArea, cl).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->geometry().left() - 1, cl->geometry().center().y()), cl->desktop()).left(); | 851 | QPoint(cl->frameGeometry().left() - 1, cl->frameGeometry().center().y()), cl->desktop()).left(); | ||
852 | if (cl->titlebarPosition() != AbstractClient::PositionLeft) { | 852 | if (cl->titlebarPosition() != AbstractClient::PositionLeft) { | ||
853 | QRect geo = cl->geometry(); | 853 | QRect geo = cl->frameGeometry(); | ||
854 | int rgt = newx - cl->clientPos().x(); | 854 | int rgt = newx - cl->clientPos().x(); | ||
855 | geo.moveRight(rgt); | 855 | geo.moveRight(rgt); | ||
856 | if (screens()->intersecting(geo) < 2) | 856 | if (screens()->intersecting(geo) < 2) | ||
857 | newx = rgt; | 857 | newx = rgt; | ||
858 | } | 858 | } | ||
859 | if (oldx <= newx) | 859 | if (oldx <= newx) | ||
860 | return oldx; | 860 | return oldx; | ||
861 | const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop(); | 861 | const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop(); | ||
862 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | 862 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | ||
863 | if (isIrrelevant(*it, cl, desktop)) | 863 | if (isIrrelevant(*it, cl, desktop)) | ||
864 | continue; | 864 | continue; | ||
865 | int x = left_edge ? (*it)->geometry().right() + 1 : (*it)->geometry().left() - 1; | 865 | int x = left_edge ? (*it)->frameGeometry().right() + 1 : (*it)->frameGeometry().left() - 1; | ||
866 | if (x > newx && x < oldx | 866 | if (x > newx && x < oldx | ||
867 | && !(cl->geometry().top() > (*it)->geometry().bottom() // they overlap in Y direction | 867 | && !(cl->frameGeometry().top() > (*it)->frameGeometry().bottom() // they overlap in Y direction | ||
868 | || cl->geometry().bottom() < (*it)->geometry().top())) | 868 | || cl->frameGeometry().bottom() < (*it)->frameGeometry().top())) | ||
869 | newx = x; | 869 | newx = x; | ||
870 | } | 870 | } | ||
871 | return newx; | 871 | return newx; | ||
872 | } | 872 | } | ||
873 | 873 | | |||
874 | int Workspace::packPositionRight(const AbstractClient* cl, int oldx, bool right_edge) const | 874 | int Workspace::packPositionRight(const AbstractClient* cl, int oldx, bool right_edge) const | ||
875 | { | 875 | { | ||
876 | int newx = clientArea(MaximizeArea, cl).right(); | 876 | int newx = clientArea(MaximizeArea, cl).right(); | ||
877 | if (oldx >= newx) // try another Xinerama screen | 877 | if (oldx >= newx) // try another Xinerama screen | ||
878 | newx = clientArea(MaximizeArea, | 878 | newx = clientArea(MaximizeArea, | ||
879 | QPoint(cl->geometry().right() + 1, cl->geometry().center().y()), cl->desktop()).right(); | 879 | QPoint(cl->frameGeometry().right() + 1, cl->frameGeometry().center().y()), cl->desktop()).right(); | ||
880 | if (cl->titlebarPosition() != AbstractClient::PositionRight) { | 880 | if (cl->titlebarPosition() != AbstractClient::PositionRight) { | ||
881 | QRect geo = cl->geometry(); | 881 | QRect geo = cl->frameGeometry(); | ||
882 | int rgt = newx + cl->width() - (cl->clientSize().width() + cl->clientPos().x()); | 882 | int rgt = newx + cl->width() - (cl->clientSize().width() + cl->clientPos().x()); | ||
883 | geo.moveRight(rgt); | 883 | geo.moveRight(rgt); | ||
884 | if (screens()->intersecting(geo) < 2) | 884 | if (screens()->intersecting(geo) < 2) | ||
885 | newx = rgt; | 885 | newx = rgt; | ||
886 | } | 886 | } | ||
887 | if (oldx >= newx) | 887 | if (oldx >= newx) | ||
888 | return oldx; | 888 | return oldx; | ||
889 | const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop(); | 889 | const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop(); | ||
890 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | 890 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | ||
891 | if (isIrrelevant(*it, cl, desktop)) | 891 | if (isIrrelevant(*it, cl, desktop)) | ||
892 | continue; | 892 | continue; | ||
893 | int x = right_edge ? (*it)->geometry().left() - 1 : (*it)->geometry().right() + 1; | 893 | int x = right_edge ? (*it)->frameGeometry().left() - 1 : (*it)->frameGeometry().right() + 1; | ||
894 | if (x < newx && x > oldx | 894 | if (x < newx && x > oldx | ||
895 | && !(cl->geometry().top() > (*it)->geometry().bottom() | 895 | && !(cl->frameGeometry().top() > (*it)->frameGeometry().bottom() | ||
896 | || cl->geometry().bottom() < (*it)->geometry().top())) | 896 | || cl->frameGeometry().bottom() < (*it)->frameGeometry().top())) | ||
897 | newx = x; | 897 | newx = x; | ||
898 | } | 898 | } | ||
899 | return newx; | 899 | return newx; | ||
900 | } | 900 | } | ||
901 | 901 | | |||
902 | int Workspace::packPositionUp(const AbstractClient* cl, int oldy, bool top_edge) const | 902 | int Workspace::packPositionUp(const AbstractClient* cl, int oldy, bool top_edge) const | ||
903 | { | 903 | { | ||
904 | int newy = clientArea(MaximizeArea, cl).top(); | 904 | int newy = clientArea(MaximizeArea, cl).top(); | ||
905 | if (oldy <= newy) // try another Xinerama screen | 905 | if (oldy <= newy) // try another Xinerama screen | ||
906 | newy = clientArea(MaximizeArea, | 906 | newy = clientArea(MaximizeArea, | ||
907 | QPoint(cl->geometry().center().x(), cl->geometry().top() - 1), cl->desktop()).top(); | 907 | QPoint(cl->frameGeometry().center().x(), cl->frameGeometry().top() - 1), cl->desktop()).top(); | ||
908 | if (cl->titlebarPosition() != AbstractClient::PositionTop) { | 908 | if (cl->titlebarPosition() != AbstractClient::PositionTop) { | ||
909 | QRect geo = cl->geometry(); | 909 | QRect geo = cl->frameGeometry(); | ||
910 | int top = newy - cl->clientPos().y(); | 910 | int top = newy - cl->clientPos().y(); | ||
911 | geo.moveTop(top); | 911 | geo.moveTop(top); | ||
912 | if (screens()->intersecting(geo) < 2) | 912 | if (screens()->intersecting(geo) < 2) | ||
913 | newy = top; | 913 | newy = top; | ||
914 | } | 914 | } | ||
915 | if (oldy <= newy) | 915 | if (oldy <= newy) | ||
916 | return oldy; | 916 | return oldy; | ||
917 | const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop(); | 917 | const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop(); | ||
918 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | 918 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | ||
919 | if (isIrrelevant(*it, cl, desktop)) | 919 | if (isIrrelevant(*it, cl, desktop)) | ||
920 | continue; | 920 | continue; | ||
921 | int y = top_edge ? (*it)->geometry().bottom() + 1 : (*it)->geometry().top() - 1; | 921 | int y = top_edge ? (*it)->frameGeometry().bottom() + 1 : (*it)->frameGeometry().top() - 1; | ||
922 | if (y > newy && y < oldy | 922 | if (y > newy && y < oldy | ||
923 | && !(cl->geometry().left() > (*it)->geometry().right() // they overlap in X direction | 923 | && !(cl->frameGeometry().left() > (*it)->frameGeometry().right() // they overlap in X direction | ||
924 | || cl->geometry().right() < (*it)->geometry().left())) | 924 | || cl->frameGeometry().right() < (*it)->frameGeometry().left())) | ||
925 | newy = y; | 925 | newy = y; | ||
926 | } | 926 | } | ||
927 | return newy; | 927 | return newy; | ||
928 | } | 928 | } | ||
929 | 929 | | |||
930 | int Workspace::packPositionDown(const AbstractClient* cl, int oldy, bool bottom_edge) const | 930 | int Workspace::packPositionDown(const AbstractClient* cl, int oldy, bool bottom_edge) const | ||
931 | { | 931 | { | ||
932 | int newy = clientArea(MaximizeArea, cl).bottom(); | 932 | int newy = clientArea(MaximizeArea, cl).bottom(); | ||
933 | if (oldy >= newy) // try another Xinerama screen | 933 | if (oldy >= newy) // try another Xinerama screen | ||
934 | newy = clientArea(MaximizeArea, | 934 | newy = clientArea(MaximizeArea, | ||
935 | QPoint(cl->geometry().center().x(), cl->geometry().bottom() + 1), cl->desktop()).bottom(); | 935 | QPoint(cl->frameGeometry().center().x(), cl->frameGeometry().bottom() + 1), cl->desktop()).bottom(); | ||
936 | if (cl->titlebarPosition() != AbstractClient::PositionBottom) { | 936 | if (cl->titlebarPosition() != AbstractClient::PositionBottom) { | ||
937 | QRect geo = cl->geometry(); | 937 | QRect geo = cl->frameGeometry(); | ||
938 | int btm = newy + cl->height() - (cl->clientSize().height() + cl->clientPos().y()); | 938 | int btm = newy + cl->height() - (cl->clientSize().height() + cl->clientPos().y()); | ||
939 | geo.moveBottom(btm); | 939 | geo.moveBottom(btm); | ||
940 | if (screens()->intersecting(geo) < 2) | 940 | if (screens()->intersecting(geo) < 2) | ||
941 | newy = btm; | 941 | newy = btm; | ||
942 | } | 942 | } | ||
943 | if (oldy >= newy) | 943 | if (oldy >= newy) | ||
944 | return oldy; | 944 | return oldy; | ||
945 | const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop(); | 945 | const int desktop = cl->desktop() == 0 || cl->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : cl->desktop(); | ||
946 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | 946 | for (auto it = m_allClients.constBegin(), end = m_allClients.constEnd(); it != end; ++it) { | ||
947 | if (isIrrelevant(*it, cl, desktop)) | 947 | if (isIrrelevant(*it, cl, desktop)) | ||
948 | continue; | 948 | continue; | ||
949 | int y = bottom_edge ? (*it)->geometry().top() - 1 : (*it)->geometry().bottom() + 1; | 949 | int y = bottom_edge ? (*it)->frameGeometry().top() - 1 : (*it)->frameGeometry().bottom() + 1; | ||
950 | if (y < newy && y > oldy | 950 | if (y < newy && y > oldy | ||
951 | && !(cl->geometry().left() > (*it)->geometry().right() | 951 | && !(cl->frameGeometry().left() > (*it)->frameGeometry().right() | ||
952 | || cl->geometry().right() < (*it)->geometry().left())) | 952 | || cl->frameGeometry().right() < (*it)->frameGeometry().left())) | ||
953 | newy = y; | 953 | newy = y; | ||
954 | } | 954 | } | ||
955 | return newy; | 955 | return newy; | ||
956 | } | 956 | } | ||
957 | 957 | | |||
958 | #endif | 958 | #endif | ||
959 | 959 | | |||
960 | } // namespace | 960 | } // namespace |