Mir

Merge lp:~alan-griffiths/mir/remove-constraints-on-surface-placement into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 2524
Proposed branch: lp:~alan-griffiths/mir/remove-constraints-on-surface-placement
Merge into: lp:mir
Prerequisite: lp:~alan-griffiths/mir/more-surface-resize
Diff against target: 162 lines (+8/-92)
2 files modified
examples/server_example_canonical_window_manager.cpp (+4/-46)
src/server/shell/canonical_window_manager.cpp (+4/-46)
To merge this branch: bzr merge lp:~alan-griffiths/mir/remove-constraints-on-surface-placement
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+257114@code.launchpad.net

Commit message

shell, examples: remove excessive constraint on surface position
(LP: #1447882)

Description of the change

shell, examples: remove excessive constraint on surface position

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

7: [ FAILED ] TestClientInput.keymap_changes_change_keycode_received

Not touched - lp:1448210

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

That feels better.

(1) This looks like a TODO (which it kind of is, but isn't):
46 + // placeholder - constrain onscreen
If anything in future you'd just want a little logic that ensures a window rectangle always intersects the screen rectangle somehow so you don't lose it entirely. But even that's not so such an issue with dragging as with display layout reconfiguration.

(2) Keep in mind that window snapping would eventually need more than a single rectangle:
93 + Rectangle const& /*bounds*/)
You would indeed use a bounding rectangle for the screen, but also the set of all window rectangles whose exterior edges can be snapped to.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> That feels better.
>
> (1) This looks like a TODO (which it kind of is, but isn't):
> 46 + // placeholder - constrain onscreen
> If anything in future you'd just want a little logic that ensures a window
> rectangle always intersects the screen rectangle somehow so you don't lose it
> entirely. But even that's not so such an issue with dragging as with display
> layout reconfiguration.
>
> (2) Keep in mind that window snapping would eventually need more than a single
> rectangle:
> 93 + Rectangle const& /*bounds*/)
> You would indeed use a bounding rectangle for the screen, but also the set of
> all window rectangles whose exterior edges can be snapped to.

Agreed

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/server_example_canonical_window_manager.cpp'
--- examples/server_example_canonical_window_manager.cpp 2015-04-28 16:24:07 +0000
+++ examples/server_example_canonical_window_manager.cpp 2015-04-28 16:24:07 +0000
@@ -722,7 +722,7 @@
722 Size const& requested_size,722 Size const& requested_size,
723 bool const left_resize,723 bool const left_resize,
724 bool const top_resize,724 bool const top_resize,
725 Rectangle const& bounds)725 Rectangle const& /*bounds*/)
726{726{
727 auto const& surface_info = tools->info_for(surface);727 auto const& surface_info = tools->info_for(surface);
728728
@@ -816,35 +816,7 @@
816 if (top_resize)816 if (top_resize)
817 new_pos.y += new_size.height - requested_size.height;817 new_pos.y += new_size.height - requested_size.height;
818818
819 if (left_resize)819 // placeholder - constrain onscreen
820 {
821 if (new_pos.x < bounds.top_left.x)
822 {
823 new_size.width = new_size.width + (new_pos.x - bounds.top_left.x);
824 new_pos.x = bounds.top_left.x;
825 }
826 }
827 else
828 {
829 auto to_bottom_right = bounds.bottom_right() - (new_pos + as_displacement(new_size));
830 if (to_bottom_right.dx < DeltaX{0})
831 new_size.width = new_size.width + to_bottom_right.dx;
832 }
833
834 if (top_resize)
835 {
836 if (new_pos.y < bounds.top_left.y)
837 {
838 new_size.height = new_size.height + (new_pos.y - bounds.top_left.y);
839 new_pos.y = bounds.top_left.y;
840 }
841 }
842 else
843 {
844 auto to_bottom_right = bounds.bottom_right() - (new_pos + as_displacement(new_size));
845 if (to_bottom_right.dy < DeltaY{0})
846 new_size.height = new_size.height + to_bottom_right.dy;
847 }
848820
849 switch (surface_info.state)821 switch (surface_info.state)
850 {822 {
@@ -884,7 +856,7 @@
884 return true;856 return true;
885}857}
886858
887bool me::CanonicalWindowManagerPolicyCopy::drag(std::shared_ptr<ms::Surface> surface, Point to, Point from, Rectangle bounds)859bool me::CanonicalWindowManagerPolicyCopy::drag(std::shared_ptr<ms::Surface> surface, Point to, Point from, Rectangle /*bounds*/)
888{860{
889 if (!surface)861 if (!surface)
890 return false;862 return false;
@@ -892,23 +864,9 @@
892 if (!surface->input_area_contains(from) && !tools->info_for(surface).titlebar)864 if (!surface->input_area_contains(from) && !tools->info_for(surface).titlebar)
893 return false;865 return false;
894866
895 auto const top_left = surface->top_left();
896 auto const surface_size = surface->size();
897 auto const bottom_right = top_left + as_displacement(surface_size);
898
899 auto movement = to - from;867 auto movement = to - from;
900868
901 if (movement.dx < DeltaX{0})869 // placeholder - constrain onscreen
902 movement.dx = std::max(movement.dx, (bounds.top_left - top_left).dx);
903
904 if (movement.dy < DeltaY{0})
905 movement.dy = std::max(movement.dy, (bounds.top_left - top_left).dy);
906
907 if (movement.dx > DeltaX{0})
908 movement.dx = std::min(movement.dx, (bounds.bottom_right() - bottom_right).dx);
909
910 if (movement.dy > DeltaY{0})
911 movement.dy = std::min(movement.dy, (bounds.bottom_right() - bottom_right).dy);
912870
913 move_tree(surface, movement);871 move_tree(surface, movement);
914872
915873
=== modified file 'src/server/shell/canonical_window_manager.cpp'
--- src/server/shell/canonical_window_manager.cpp 2015-04-28 16:24:07 +0000
+++ src/server/shell/canonical_window_manager.cpp 2015-04-28 16:24:07 +0000
@@ -637,7 +637,7 @@
637 Size const& requested_size,637 Size const& requested_size,
638 bool const left_resize,638 bool const left_resize,
639 bool const top_resize,639 bool const top_resize,
640 Rectangle const& bounds)640 Rectangle const& /*bounds*/)
641{641{
642 auto const& surface_info = tools->info_for(surface);642 auto const& surface_info = tools->info_for(surface);
643643
@@ -731,35 +731,7 @@
731 if (top_resize)731 if (top_resize)
732 new_pos.y += new_size.height - requested_size.height;732 new_pos.y += new_size.height - requested_size.height;
733733
734 if (left_resize)734 // placeholder - constrain onscreen
735 {
736 if (new_pos.x < bounds.top_left.x)
737 {
738 new_size.width = new_size.width + (new_pos.x - bounds.top_left.x);
739 new_pos.x = bounds.top_left.x;
740 }
741 }
742 else
743 {
744 auto to_bottom_right = bounds.bottom_right() - (new_pos + as_displacement(new_size));
745 if (to_bottom_right.dx < DeltaX{0})
746 new_size.width = new_size.width + to_bottom_right.dx;
747 }
748
749 if (top_resize)
750 {
751 if (new_pos.y < bounds.top_left.y)
752 {
753 new_size.height = new_size.height + (new_pos.y - bounds.top_left.y);
754 new_pos.y = bounds.top_left.y;
755 }
756 }
757 else
758 {
759 auto to_bottom_right = bounds.bottom_right() - (new_pos + as_displacement(new_size));
760 if (to_bottom_right.dy < DeltaY{0})
761 new_size.height = new_size.height + to_bottom_right.dy;
762 }
763735
764 switch (surface_info.state)736 switch (surface_info.state)
765 {737 {
@@ -798,27 +770,13 @@
798 return true;770 return true;
799}771}
800772
801bool msh::CanonicalWindowManagerPolicy::drag(std::shared_ptr<ms::Surface> surface, Point to, Point from, Rectangle bounds)773bool msh::CanonicalWindowManagerPolicy::drag(std::shared_ptr<ms::Surface> surface, Point to, Point from, Rectangle /*bounds*/)
802{774{
803 if (surface && surface->input_area_contains(from))775 if (surface && surface->input_area_contains(from))
804 {776 {
805 auto const top_left = surface->top_left();
806 auto const surface_size = surface->size();
807 auto const bottom_right = top_left + as_displacement(surface_size);
808
809 auto movement = to - from;777 auto movement = to - from;
810778
811 if (movement.dx < DeltaX{0})779 // placeholder - constrain onscreen
812 movement.dx = std::max(movement.dx, (bounds.top_left - top_left).dx);
813
814 if (movement.dy < DeltaY{0})
815 movement.dy = std::max(movement.dy, (bounds.top_left - top_left).dy);
816
817 if (movement.dx > DeltaX{0})
818 movement.dx = std::min(movement.dx, (bounds.bottom_right() - bottom_right).dx);
819
820 if (movement.dy > DeltaY{0})
821 movement.dy = std::min(movement.dy, (bounds.bottom_right() - bottom_right).dy);
822780
823 move_tree(surface, movement);781 move_tree(surface, movement);
824782

Subscribers

People subscribed via source and target branches