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