Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2667)

Unified Diff: ui/gfx/screen_mac.mm

Issue 47073006: GetDisplayForScreen cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: GetDisplayForScreen cleanup - Review comment on comparison addressed Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/screen_mac.mm
diff --git a/ui/gfx/screen_mac.mm b/ui/gfx/screen_mac.mm
index a7ea204be5c829b80433003dad1e814d668ae41c..f63bd306cd8bb19273def02b0ebbfe24ddf97b53 100644
--- a/ui/gfx/screen_mac.mm
+++ b/ui/gfx/screen_mac.mm
@@ -42,15 +42,16 @@ NSScreen* GetMatchingScreen(const gfx::Rect& match_rect) {
return max_screen;
}
-gfx::Display GetDisplayForScreen(NSScreen* screen, bool is_primary) {
+gfx::Display GetDisplayForScreen(NSScreen* screen) {
NSRect frame = [screen frame];
// TODO(oshima): Implement ID and Observer.
gfx::Display display(0, gfx::Rect(NSRectToCGRect(frame)));
NSRect visible_frame = [screen visibleFrame];
+ NSScreen* primary = [[NSScreen screens] objectAtIndex:0];
// Convert work area's coordinate systems.
- if (is_primary) {
+ if ([screen isEqual:primary]) {
gfx::Rect work_area = gfx::Rect(NSRectToCGRect(visible_frame));
work_area.set_y(frame.size.height - visible_frame.origin.y -
visible_frame.size.height);
@@ -142,7 +143,7 @@ class ScreenMac : public gfx::Screen {
NSScreen* match_screen = [window screen];
if (!match_screen)
return GetPrimaryDisplay();
- return GetDisplayForScreen(match_screen, false /* may not be primary */);
+ return GetDisplayForScreen(match_screen);
}
virtual gfx::Display GetDisplayNearestPoint(
@@ -154,7 +155,7 @@ class ScreenMac : public gfx::Screen {
ns_point.y = NSMaxY([primary frame]) - ns_point.y;
for (NSScreen* screen in screens) {
if (NSMouseInRect(ns_point, [screen frame], NO))
- return GetDisplayForScreen(screen, screen == primary);
+ return GetDisplayForScreen(screen);
}
return GetPrimaryDisplay();
}
@@ -163,7 +164,7 @@ class ScreenMac : public gfx::Screen {
virtual gfx::Display GetDisplayMatching(
const gfx::Rect& match_rect) const OVERRIDE {
NSScreen* match_screen = GetMatchingScreen(match_rect);
- return GetDisplayForScreen(match_screen, false /* may not be primary */);
+ return GetDisplayForScreen(match_screen);
}
// Returns the primary display.
@@ -171,7 +172,7 @@ class ScreenMac : public gfx::Screen {
// Primary display is defined as the display with the menubar,
// which is always at index 0.
NSScreen* primary = [[NSScreen screens] objectAtIndex:0];
- gfx::Display display = GetDisplayForScreen(primary, true /* primary */);
+ gfx::Display display = GetDisplayForScreen(primary);
return display;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698