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