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.
5 #include "ui/gfx/screen.h"
7 #import <UIKit/UIKit.h>
9 #include "base/logging.h"
10 #include "ui/gfx/display.h"
14 class ScreenIos : public gfx::Screen {
15 gfx::Point GetCursorScreenPoint() override {
17 return gfx::Point(0, 0);
20 gfx::NativeWindow GetWindowUnderCursor() override {
22 return gfx::NativeWindow();
25 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override {
27 return gfx::NativeWindow();
30 int GetNumDisplays() const override {
31 #if TARGET_IPHONE_SIMULATOR
32 // UIScreen does not reliably return correct results on the simulator.
35 return [[UIScreen screens] count];
39 std::vector<gfx::Display> GetAllDisplays() const override {
41 return std::vector<gfx::Display>(1, GetPrimaryDisplay());
44 // Returns the display nearest the specified window.
45 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const override {
47 return gfx::Display();
50 // Returns the the display nearest the specified point.
51 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override {
53 return gfx::Display();
56 // Returns the display that most closely intersects the provided bounds.
57 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override {
59 return gfx::Display();
62 // Returns the primary display.
63 gfx::Display GetPrimaryDisplay() const override {
64 UIScreen* mainScreen = [UIScreen mainScreen];
66 gfx::Display display(0, gfx::Rect(mainScreen.bounds));
67 display.set_device_scale_factor([mainScreen scale]);
71 void AddObserver(gfx::DisplayObserver* observer) override {
72 // no display change on iOS.
75 void RemoveObserver(gfx::DisplayObserver* observer) override {
76 // no display change on iOS.
84 Screen* CreateNativeScreen() {