summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorEleni Maria Stea <elenimaria.stea@canonical.com>2014-10-16 15:10:15 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-10-16 15:10:15 +0000
commit5162b50bbda8215daa8e46ed620fe052c9b7b448 (patch)
tree072166630cead629efeea8bdbd5c4d327ad4be5b /unity-shared
parent860fb995364c766263f5ba6757763b760f5b5f86 (diff)
parentf7f9b6223983bb698d5be96a6840203126812e23 (diff)
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 Fixes: 1349281 Approved by: PS Jenkins bot, Marco Trevisan (TreviƱo) (bzr r3883)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/LayoutSystem.cpp32
-rw-r--r--unity-shared/LayoutSystem.h3
2 files changed, 30 insertions, 5 deletions
diff --git a/unity-shared/LayoutSystem.cpp b/unity-shared/LayoutSystem.cpp
index f2ea8b87a..396ee4cac 100644
--- a/unity-shared/LayoutSystem.cpp
+++ b/unity-shared/LayoutSystem.cpp
@@ -32,7 +32,33 @@ void LayoutSystem::LayoutWindows(LayoutWindow::Vector const& windows, nux::Geome
if (windows.empty())
return;
- LayoutGridWindows(windows, max_bounds, final_bounds);
+ LayoutGridWindows(windows, GetRows(windows, max_bounds), max_bounds, final_bounds);
+}
+
+void LayoutSystem::LayoutWindowsNearest(LayoutWindow::Vector& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds)
+{
+ if (windows.empty())
+ return;
+
+ std::stable_sort(windows.begin(), windows.end(), [](LayoutWindow::Ptr const& a, LayoutWindow::Ptr const& b) {
+ return a->geo.y < b->geo.y;
+ });
+
+ std::vector<LayoutWindow::Vector> rows = GetRows(windows, max_bounds);
+ LayoutWindow::Vector ordered_windows;
+
+ for (auto& row : rows)
+ {
+ std::stable_sort(row.begin(), row.end(), [](LayoutWindow::Ptr const& a, LayoutWindow::Ptr const& b) {
+ return (a->geo.x + a->geo.width / 2) < (b->geo.x + b->geo.width / 2);
+ });
+
+ for (auto const& win : row)
+ ordered_windows.push_back(win);
+ }
+
+ LayoutGridWindows(ordered_windows, rows, max_bounds, final_bounds);
+ windows = ordered_windows;
}
nux::Size LayoutSystem::GridSizeForWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds) const
@@ -229,10 +255,8 @@ std::vector<LayoutWindow::Vector> LayoutSystem::GetRows(LayoutWindow::Vector con
return rows;
}
-void LayoutSystem::LayoutGridWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds)
+void LayoutSystem::LayoutGridWindows(LayoutWindow::Vector const& windows, std::vector<LayoutWindow::Vector> const& rows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds)
{
- std::vector<LayoutWindow::Vector> const& rows = GetRows(windows, max_bounds);
-
int height = rows.size();
int non_spacing_height = max_bounds.height - ((height - 1) * spacing);
int row_height = std::min (max_row_height(), non_spacing_height / height);
diff --git a/unity-shared/LayoutSystem.h b/unity-shared/LayoutSystem.h
index 6241f727c..96b7d9c90 100644
--- a/unity-shared/LayoutSystem.h
+++ b/unity-shared/LayoutSystem.h
@@ -64,10 +64,11 @@ public:
LayoutSystem();
void LayoutWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
+ void LayoutWindowsNearest(LayoutWindow::Vector& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
std::vector<int> GetRowSizes(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds) const;
protected:
- void LayoutGridWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
+ void LayoutGridWindows(LayoutWindow::Vector const& windows, std::vector<LayoutWindow::Vector> const& rows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
nux::Geometry LayoutRow(LayoutWindow::Vector const& row, nux::Geometry const& row_bounds);
nux::Geometry CompressAndPadRow(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds);