Merge lp:~azzar1/unity/fix-lp-1374785 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3892
Proposed branch: lp:~azzar1/unity/fix-lp-1374785
Merge into: lp:unity
Diff against target: 55 lines (+20/-16)
1 file modified
unity-shared/UScreen.cpp (+20/-16)
To merge this branch: bzr merge lp:~azzar1/unity/fix-lp-1374785
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marco Trevisan (Treviño) Approve
Review via email: mp+241117@code.launchpad.net

Commit message

Make sure GetScreenGeometry returns the correct value.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

+1

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
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 'unity-shared/UScreen.cpp'
2--- unity-shared/UScreen.cpp 2014-08-05 21:22:40 +0000
3+++ unity-shared/UScreen.cpp 2014-11-07 17:19:07 +0000
4@@ -73,21 +73,13 @@
5
6 int UScreen::GetMonitorAtPosition(int x, int y) const
7 {
8- int monitors = gdk_screen_get_n_monitors(screen_);
9+ int idx = 0;
10
11- for (int i = 0; i < monitors; ++i)
12+ for (auto const& monitor : monitors_)
13 {
14- GdkRectangle rect = { 0 };
15- gdk_screen_get_monitor_geometry(screen_, i, &rect);
16-
17- float scale = gdk_screen_get_monitor_scale_factor(screen_, i);
18- nux::Geometry geo(rect.x, rect.y, rect.width, rect.height);
19-
20- if (scale != 1.0)
21- geo = geo * scale;
22-
23- if (geo.IsPointInside(x, y))
24- return i;
25+ if (monitor.IsPointInside(x, y))
26+ return idx;
27+ ++idx;
28 }
29
30 return gdk_screen_get_monitor_at_point(screen_, x, y);
31@@ -105,9 +97,21 @@
32
33 nux::Geometry UScreen::GetScreenGeometry() const
34 {
35- int width = gdk_screen_get_width(screen_);
36- int height = gdk_screen_get_height(screen_);
37- return nux::Geometry(0, 0, width, height);
38+ if (monitors_.empty())
39+ return {};
40+
41+ auto rightmost_geo = max_element(monitors_.begin(), monitors_.end(), [](nux::Geometry const& a, nux::Geometry const& b) {
42+ return a.x + a.width < b.x + b.width;
43+ });
44+
45+ auto lower_geo = max_element(monitors_.begin(), monitors_.end(), [](nux::Geometry const& a, nux::Geometry const& b) {
46+ return a.y + a.height < b.y + b.height;
47+ });
48+
49+ auto width = rightmost_geo->x + rightmost_geo->width;
50+ auto height = lower_geo->y + lower_geo->height;
51+
52+ return {0, 0, width, height};
53 }
54
55 const std::string UScreen::GetMonitorName(int output_number = 0) const