| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/screen.h" | 5 #include "ui/display/screen.h" |
| 6 | 6 |
| 7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/gfx/display.h" | 10 #include "ui/display/display.h" |
| 11 | 11 |
| 12 namespace display { |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 class ScreenIos : public gfx::Screen { | 15 class ScreenIos : public Screen { |
| 15 gfx::Point GetCursorScreenPoint() override { | 16 gfx::Point GetCursorScreenPoint() override { |
| 16 NOTIMPLEMENTED(); | 17 NOTIMPLEMENTED(); |
| 17 return gfx::Point(0, 0); | 18 return gfx::Point(0, 0); |
| 18 } | 19 } |
| 19 | 20 |
| 20 bool IsWindowUnderCursor(gfx::NativeWindow window) override { | 21 bool IsWindowUnderCursor(gfx::NativeWindow window) override { |
| 21 NOTIMPLEMENTED(); | 22 NOTIMPLEMENTED(); |
| 22 return false; | 23 return false; |
| 23 } | 24 } |
| 24 | 25 |
| 25 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override { | 26 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override { |
| 26 NOTIMPLEMENTED(); | 27 NOTIMPLEMENTED(); |
| 27 return gfx::NativeWindow(); | 28 return gfx::NativeWindow(); |
| 28 } | 29 } |
| 29 | 30 |
| 30 int GetNumDisplays() const override { | 31 int GetNumDisplays() const override { |
| 31 #if TARGET_IPHONE_SIMULATOR | 32 #if TARGET_IPHONE_SIMULATOR |
| 32 // UIScreen does not reliably return correct results on the simulator. | 33 // UIScreen does not reliably return correct results on the simulator. |
| 33 return 1; | 34 return 1; |
| 34 #else | 35 #else |
| 35 return [[UIScreen screens] count]; | 36 return [[UIScreen screens] count]; |
| 36 #endif | 37 #endif |
| 37 } | 38 } |
| 38 | 39 |
| 39 std::vector<gfx::Display> GetAllDisplays() const override { | 40 std::vector<Display> GetAllDisplays() const override { |
| 40 NOTIMPLEMENTED(); | 41 NOTIMPLEMENTED(); |
| 41 return std::vector<gfx::Display>(1, GetPrimaryDisplay()); | 42 return std::vector<Display>(1, GetPrimaryDisplay()); |
| 42 } | 43 } |
| 43 | 44 |
| 44 // Returns the display nearest the specified window. | 45 // Returns the display nearest the specified window. |
| 45 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const override { | 46 Display GetDisplayNearestWindow(gfx::NativeView view) const override { |
| 46 NOTIMPLEMENTED(); | 47 NOTIMPLEMENTED(); |
| 47 return gfx::Display(); | 48 return Display(); |
| 48 } | 49 } |
| 49 | 50 |
| 50 // Returns the the display nearest the specified point. | 51 // Returns the the display nearest the specified point. |
| 51 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override { | 52 Display GetDisplayNearestPoint(const gfx::Point& point) const override { |
| 52 NOTIMPLEMENTED(); | 53 NOTIMPLEMENTED(); |
| 53 return gfx::Display(); | 54 return Display(); |
| 54 } | 55 } |
| 55 | 56 |
| 56 // Returns the display that most closely intersects the provided bounds. | 57 // Returns the display that most closely intersects the provided bounds. |
| 57 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override { | 58 Display GetDisplayMatching(const gfx::Rect& match_rect) const override { |
| 58 NOTIMPLEMENTED(); | 59 NOTIMPLEMENTED(); |
| 59 return gfx::Display(); | 60 return Display(); |
| 60 } | 61 } |
| 61 | 62 |
| 62 // Returns the primary display. | 63 // Returns the primary display. |
| 63 gfx::Display GetPrimaryDisplay() const override { | 64 Display GetPrimaryDisplay() const override { |
| 64 UIScreen* mainScreen = [UIScreen mainScreen]; | 65 UIScreen* mainScreen = [UIScreen mainScreen]; |
| 65 CHECK(mainScreen); | 66 CHECK(mainScreen); |
| 66 gfx::Display display(0, gfx::Rect(mainScreen.bounds)); | 67 Display display(0, gfx::Rect(mainScreen.bounds)); |
| 67 display.set_device_scale_factor([mainScreen scale]); | 68 display.set_device_scale_factor([mainScreen scale]); |
| 68 return display; | 69 return display; |
| 69 } | 70 } |
| 70 | 71 |
| 71 void AddObserver(gfx::DisplayObserver* observer) override { | 72 void AddObserver(DisplayObserver* observer) override { |
| 72 // no display change on iOS. | 73 // no display change on iOS. |
| 73 } | 74 } |
| 74 | 75 |
| 75 void RemoveObserver(gfx::DisplayObserver* observer) override { | 76 void RemoveObserver(DisplayObserver* observer) override { |
| 76 // no display change on iOS. | 77 // no display change on iOS. |
| 77 } | 78 } |
| 78 }; | 79 }; |
| 79 | 80 |
| 80 } // namespace | 81 } // namespace |
| 81 | 82 |
| 82 namespace gfx { | |
| 83 | |
| 84 Screen* CreateNativeScreen() { | 83 Screen* CreateNativeScreen() { |
| 85 return new ScreenIos; | 84 return new ScreenIos; |
| 86 } | 85 } |
| 87 | 86 |
| 88 } // namespace gfx | 87 } // namespace gfx |
| OLD | NEW |