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

Proposed by Eleni Maria Stea
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 3880
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)
lp:~hikiko/unity/unity.1349281 updated
3879. By Eleni Maria Stea on 2014-10-09

removed double call to LayoutGridWindows, GetRows is enough

3880. By Eleni Maria Stea on 2014-10-09

merged scale-pos-fixes so that we use the window y to choose the row and
the x value of the center to order the window inside the row

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
1=== modified file 'plugins/unityshell/src/unityshell.cpp'
2--- plugins/unityshell/src/unityshell.cpp 2014-09-04 22:12:01 +0000
3+++ plugins/unityshell/src/unityshell.cpp 2014-10-09 13:24:20 +0000
4@@ -3718,7 +3718,6 @@
5 }
6
7 auto max_bounds = NuxGeometryFromCompRect(output.workArea());
8-
9 if (launcher_controller_->options()->hide_mode != LAUNCHER_HIDE_NEVER)
10 {
11 int monitor_width = unity_settings_.LauncherWidth(monitor);
12@@ -3732,19 +3731,18 @@
13 layout.spacing = local::SCALE_SPACING.CP(monitor_scale);
14 int padding = local::SCALE_PADDING.CP(monitor_scale);
15 max_bounds.Expand(-padding, -padding);
16- layout.LayoutWindows(layout_windows, max_bounds, final_bounds);
17+ layout.LayoutWindowsNearest(layout_windows, max_bounds, final_bounds);
18
19- auto lw_it = layout_windows.begin();
20- for (auto const& sw : scaled_windows)
21+ for (auto const& lw : layout_windows)
22 {
23- if (lw_it == layout_windows.end())
24- break;
25-
26- LayoutWindow::Ptr const& lw = *lw_it;
27-
28- if (sw->window->id() != lw->xid)
29+ auto sw_it = std::find_if(scaled_windows.begin(), scaled_windows.end(), [&lw] (ScaleWindow* sw) {
30+ return sw->window->id() == lw->xid;
31+ });
32+
33+ if (sw_it == scaled_windows.end())
34 continue;
35
36+ ScaleWindow* sw = *sw_it;
37 ScaleSlot slot(CompRectFromNuxGeo(lw->result));
38 slot.scale = lw->scale;
39
40@@ -3761,7 +3759,6 @@
41 slot.filled = true;
42
43 sw->setSlot(slot);
44- ++lw_it;
45 }
46 }
47
48
49=== modified file 'unity-shared/LayoutSystem.cpp'
50--- unity-shared/LayoutSystem.cpp 2014-03-10 13:17:01 +0000
51+++ unity-shared/LayoutSystem.cpp 2014-10-09 13:24:20 +0000
52@@ -32,7 +32,33 @@
53 if (windows.empty())
54 return;
55
56- LayoutGridWindows(windows, max_bounds, final_bounds);
57+ LayoutGridWindows(windows, GetRows(windows, max_bounds), max_bounds, final_bounds);
58+}
59+
60+void LayoutSystem::LayoutWindowsNearest(LayoutWindow::Vector& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds)
61+{
62+ if (windows.empty())
63+ return;
64+
65+ std::stable_sort(windows.begin(), windows.end(), [](LayoutWindow::Ptr const& a, LayoutWindow::Ptr const& b) {
66+ return a->geo.y < b->geo.y;
67+ });
68+
69+ std::vector<LayoutWindow::Vector> rows = GetRows(windows, max_bounds);
70+ LayoutWindow::Vector ordered_windows;
71+
72+ for (auto& row : rows)
73+ {
74+ std::stable_sort(row.begin(), row.end(), [](LayoutWindow::Ptr const& a, LayoutWindow::Ptr const& b) {
75+ return (a->geo.x + a->geo.width / 2) < (b->geo.x + b->geo.width / 2);
76+ });
77+
78+ for (auto const& win : row)
79+ ordered_windows.push_back(win);
80+ }
81+
82+ LayoutGridWindows(ordered_windows, rows, max_bounds, final_bounds);
83+ windows = ordered_windows;
84 }
85
86 nux::Size LayoutSystem::GridSizeForWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds) const
87@@ -229,10 +255,8 @@
88 return rows;
89 }
90
91-void LayoutSystem::LayoutGridWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds)
92+void LayoutSystem::LayoutGridWindows(LayoutWindow::Vector const& windows, std::vector<LayoutWindow::Vector> const& rows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds)
93 {
94- std::vector<LayoutWindow::Vector> const& rows = GetRows(windows, max_bounds);
95-
96 int height = rows.size();
97 int non_spacing_height = max_bounds.height - ((height - 1) * spacing);
98 int row_height = std::min (max_row_height(), non_spacing_height / height);
99
100=== modified file 'unity-shared/LayoutSystem.h'
101--- unity-shared/LayoutSystem.h 2014-03-10 13:17:01 +0000
102+++ unity-shared/LayoutSystem.h 2014-10-09 13:24:20 +0000
103@@ -64,10 +64,11 @@
104 LayoutSystem();
105
106 void LayoutWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
107+ void LayoutWindowsNearest(LayoutWindow::Vector& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
108 std::vector<int> GetRowSizes(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds) const;
109
110 protected:
111- void LayoutGridWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
112+ void LayoutGridWindows(LayoutWindow::Vector const& windows, std::vector<LayoutWindow::Vector> const& rows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
113
114 nux::Geometry LayoutRow(LayoutWindow::Vector const& row, nux::Geometry const& row_bounds);
115 nux::Geometry CompressAndPadRow(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds);