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
=== modified file 'unity-shared/UScreen.cpp'
--- unity-shared/UScreen.cpp 2014-08-05 21:22:40 +0000
+++ unity-shared/UScreen.cpp 2014-11-07 17:19:07 +0000
@@ -73,21 +73,13 @@
7373
74int UScreen::GetMonitorAtPosition(int x, int y) const74int UScreen::GetMonitorAtPosition(int x, int y) const
75{75{
76 int monitors = gdk_screen_get_n_monitors(screen_);76 int idx = 0;
7777
78 for (int i = 0; i < monitors; ++i)78 for (auto const& monitor : monitors_)
79 {79 {
80 GdkRectangle rect = { 0 };80 if (monitor.IsPointInside(x, y))
81 gdk_screen_get_monitor_geometry(screen_, i, &rect);81 return idx;
8282 ++idx;
83 float scale = gdk_screen_get_monitor_scale_factor(screen_, i);
84 nux::Geometry geo(rect.x, rect.y, rect.width, rect.height);
85
86 if (scale != 1.0)
87 geo = geo * scale;
88
89 if (geo.IsPointInside(x, y))
90 return i;
91 }83 }
9284
93 return gdk_screen_get_monitor_at_point(screen_, x, y);85 return gdk_screen_get_monitor_at_point(screen_, x, y);
@@ -105,9 +97,21 @@
10597
106nux::Geometry UScreen::GetScreenGeometry() const98nux::Geometry UScreen::GetScreenGeometry() const
107{99{
108 int width = gdk_screen_get_width(screen_);100 if (monitors_.empty())
109 int height = gdk_screen_get_height(screen_);101 return {};
110 return nux::Geometry(0, 0, width, height);102
103 auto rightmost_geo = max_element(monitors_.begin(), monitors_.end(), [](nux::Geometry const& a, nux::Geometry const& b) {
104 return a.x + a.width < b.x + b.width;
105 });
106
107 auto lower_geo = max_element(monitors_.begin(), monitors_.end(), [](nux::Geometry const& a, nux::Geometry const& b) {
108 return a.y + a.height < b.y + b.height;
109 });
110
111 auto width = rightmost_geo->x + rightmost_geo->width;
112 auto height = lower_geo->y + lower_geo->height;
113
114 return {0, 0, width, height};
111}115}
112116
113const std::string UScreen::GetMonitorName(int output_number = 0) const117const std::string UScreen::GetMonitorName(int output_number = 0) const