Merge lp:~hikiko/unity/unity.1349281 into lp:unity

Proposed by Eleni Maria Stea
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3883
Proposed branch: lp:~hikiko/unity/unity.1349281
Merge into: lp:unity
Diff against target: 115 lines (+38/-16)
3 files modified
plugins/unityshell/src/unityshell.cpp (+8/-11)
unity-shared/LayoutSystem.cpp (+28/-4)
unity-shared/LayoutSystem.h (+2/-1)
To merge this branch: bzr merge lp:~hikiko/unity/unity.1349281
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marco Trevisan (Treviño) Approve
Stephen M. Webb Pending
Review via email: mp+237391@code.launchpad.net

Commit message

LayoutSystem: make sure the exposed open windows are displayed in the "correct" order

In expose mode the windows were placed in z-order starting by the top-most window that was always put in the bottom right corner. After the change the windows are placed in a similar order to their initial one.

here's a video of the expose mode after the change: http://youtu.be/eYFTeJjaDQE

Description of the change

it fixes bug #1349281: the exposed open windows are not displayed in the "correct" order.

In expose mode the windows were placed in z-order starting by the top-most window that was always put in the bottom right corner. After the change the windows are placed in a similar order to their initial one.

here's a video of the expose mode after the change: http://youtu.be/eYFTeJjaDQE

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

See inline comments

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ah, one more thing...

In case where acentery == bcentery (for example when the windows are maximized), the windows should probably be ordered using the last time they have been used as a reference (return something like wm.GetWindowActiveNumber(a->xid) > wm.GetWindowActiveNumber(b->xid);)

Revision history for this message
Eleni Maria Stea (hikiko) wrote :

thanks :) I replied/fixed the issues

Revision history for this message
Eleni Maria Stea (hikiko) wrote :

> Ah, one more thing...
>
> In case where acentery == bcentery (for example when the windows are
> maximized), the windows should probably be ordered using the last time they
> have been used as a reference (return something like
> wm.GetWindowActiveNumber(a->xid) > wm.GetWindowActiveNumber(b->xid);)

no need to do that, I use stable_sort for that reason so what will happen is that since the windows are already ordered by z, if their center y are equal the first by z (topmost) will be first :D so, we shouldn't worry to order them manually :) I've tested this case!

Revision history for this message
Eleni Maria Stea (hikiko) wrote :

:s/top-most/the window that is first in the previous z-ordering

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Nice!

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2014-09-04 22:12:01 +0000
+++ plugins/unityshell/src/unityshell.cpp 2014-10-09 13:24:20 +0000
@@ -3718,7 +3718,6 @@
3718 }3718 }
37193719
3720 auto max_bounds = NuxGeometryFromCompRect(output.workArea());3720 auto max_bounds = NuxGeometryFromCompRect(output.workArea());
3721
3722 if (launcher_controller_->options()->hide_mode != LAUNCHER_HIDE_NEVER)3721 if (launcher_controller_->options()->hide_mode != LAUNCHER_HIDE_NEVER)
3723 {3722 {
3724 int monitor_width = unity_settings_.LauncherWidth(monitor);3723 int monitor_width = unity_settings_.LauncherWidth(monitor);
@@ -3732,19 +3731,18 @@
3732 layout.spacing = local::SCALE_SPACING.CP(monitor_scale);3731 layout.spacing = local::SCALE_SPACING.CP(monitor_scale);
3733 int padding = local::SCALE_PADDING.CP(monitor_scale);3732 int padding = local::SCALE_PADDING.CP(monitor_scale);
3734 max_bounds.Expand(-padding, -padding);3733 max_bounds.Expand(-padding, -padding);
3735 layout.LayoutWindows(layout_windows, max_bounds, final_bounds);3734 layout.LayoutWindowsNearest(layout_windows, max_bounds, final_bounds);
37363735
3737 auto lw_it = layout_windows.begin();3736 for (auto const& lw : layout_windows)
3738 for (auto const& sw : scaled_windows)
3739 {3737 {
3740 if (lw_it == layout_windows.end())3738 auto sw_it = std::find_if(scaled_windows.begin(), scaled_windows.end(), [&lw] (ScaleWindow* sw) {
3741 break;3739 return sw->window->id() == lw->xid;
37423740 });
3743 LayoutWindow::Ptr const& lw = *lw_it;3741
37443742 if (sw_it == scaled_windows.end())
3745 if (sw->window->id() != lw->xid)
3746 continue;3743 continue;
37473744
3745 ScaleWindow* sw = *sw_it;
3748 ScaleSlot slot(CompRectFromNuxGeo(lw->result));3746 ScaleSlot slot(CompRectFromNuxGeo(lw->result));
3749 slot.scale = lw->scale;3747 slot.scale = lw->scale;
37503748
@@ -3761,7 +3759,6 @@
3761 slot.filled = true;3759 slot.filled = true;
37623760
3763 sw->setSlot(slot);3761 sw->setSlot(slot);
3764 ++lw_it;
3765 }3762 }
3766 }3763 }
37673764
37683765
=== modified file 'unity-shared/LayoutSystem.cpp'
--- unity-shared/LayoutSystem.cpp 2014-03-10 13:17:01 +0000
+++ unity-shared/LayoutSystem.cpp 2014-10-09 13:24:20 +0000
@@ -32,7 +32,33 @@
32 if (windows.empty())32 if (windows.empty())
33 return;33 return;
3434
35 LayoutGridWindows(windows, max_bounds, final_bounds);35 LayoutGridWindows(windows, GetRows(windows, max_bounds), max_bounds, final_bounds);
36}
37
38void LayoutSystem::LayoutWindowsNearest(LayoutWindow::Vector& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds)
39{
40 if (windows.empty())
41 return;
42
43 std::stable_sort(windows.begin(), windows.end(), [](LayoutWindow::Ptr const& a, LayoutWindow::Ptr const& b) {
44 return a->geo.y < b->geo.y;
45 });
46
47 std::vector<LayoutWindow::Vector> rows = GetRows(windows, max_bounds);
48 LayoutWindow::Vector ordered_windows;
49
50 for (auto& row : rows)
51 {
52 std::stable_sort(row.begin(), row.end(), [](LayoutWindow::Ptr const& a, LayoutWindow::Ptr const& b) {
53 return (a->geo.x + a->geo.width / 2) < (b->geo.x + b->geo.width / 2);
54 });
55
56 for (auto const& win : row)
57 ordered_windows.push_back(win);
58 }
59
60 LayoutGridWindows(ordered_windows, rows, max_bounds, final_bounds);
61 windows = ordered_windows;
36}62}
3763
38nux::Size LayoutSystem::GridSizeForWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds) const64nux::Size LayoutSystem::GridSizeForWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds) const
@@ -229,10 +255,8 @@
229 return rows;255 return rows;
230}256}
231257
232void LayoutSystem::LayoutGridWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds)258void LayoutSystem::LayoutGridWindows(LayoutWindow::Vector const& windows, std::vector<LayoutWindow::Vector> const& rows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds)
233{259{
234 std::vector<LayoutWindow::Vector> const& rows = GetRows(windows, max_bounds);
235
236 int height = rows.size();260 int height = rows.size();
237 int non_spacing_height = max_bounds.height - ((height - 1) * spacing);261 int non_spacing_height = max_bounds.height - ((height - 1) * spacing);
238 int row_height = std::min (max_row_height(), non_spacing_height / height);262 int row_height = std::min (max_row_height(), non_spacing_height / height);
239263
=== modified file 'unity-shared/LayoutSystem.h'
--- unity-shared/LayoutSystem.h 2014-03-10 13:17:01 +0000
+++ unity-shared/LayoutSystem.h 2014-10-09 13:24:20 +0000
@@ -64,10 +64,11 @@
64 LayoutSystem();64 LayoutSystem();
6565
66 void LayoutWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);66 void LayoutWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
67 void LayoutWindowsNearest(LayoutWindow::Vector& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
67 std::vector<int> GetRowSizes(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds) const;68 std::vector<int> GetRowSizes(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds) const;
6869
69protected:70protected:
70 void LayoutGridWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);71 void LayoutGridWindows(LayoutWindow::Vector const& windows, std::vector<LayoutWindow::Vector> const& rows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
7172
72 nux::Geometry LayoutRow(LayoutWindow::Vector const& row, nux::Geometry const& row_bounds);73 nux::Geometry LayoutRow(LayoutWindow::Vector const& row, nux::Geometry const& row_bounds);
73 nux::Geometry CompressAndPadRow(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds);74 nux::Geometry CompressAndPadRow(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds);