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 virtual bool IsDIPEnabled() OVERRIDE {
19 virtual gfx::Point GetCursorScreenPoint() OVERRIDE {
21 return gfx::Point(0, 0);
24 virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE {
26 return gfx::NativeWindow();
29 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point)
32 return gfx::NativeWindow();
35 virtual int GetNumDisplays() const OVERRIDE {
36 #if TARGET_IPHONE_SIMULATOR
37 // UIScreen does not reliably return correct results on the simulator.
40 return [[UIScreen screens] count];
44 virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE {
46 return std::vector<gfx::Display>(1, GetPrimaryDisplay());
49 // Returns the display nearest the specified window.
50 virtual gfx::Display GetDisplayNearestWindow(
51 gfx::NativeView view) const OVERRIDE {
53 return gfx::Display();
56 // Returns the the display nearest the specified point.
57 virtual gfx::Display GetDisplayNearestPoint(
58 const gfx::Point& point) const OVERRIDE {
60 return gfx::Display();
63 // Returns the display that most closely intersects the provided bounds.
64 virtual gfx::Display GetDisplayMatching(
65 const gfx::Rect& match_rect) const OVERRIDE {
67 return gfx::Display();
70 // Returns the primary display.
71 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE {
72 UIScreen* mainScreen = [UIScreen mainScreen];
74 gfx::Display display(0, gfx::Rect(mainScreen.bounds));
75 display.set_device_scale_factor([mainScreen scale]);
79 virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE {
80 // no display change on iOS.
83 virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE {
84 // no display change on iOS.
92 Screen* CreateNativeScreen() {