Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Unified Diff: ui/display/screen.h

Issue 1964153002: Move Screen, its impls, DisplayObserver and DisplayChangeNotifier to ui/display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tabs Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/display/mac/screen_mac.mm ('k') | ui/display/screen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/display/screen.h
diff --git a/ui/display/screen.h b/ui/display/screen.h
index d7f2cab16ce20bef04aff52b958ed39c9996d66e..b035b25f8f481fa4928739281ebf60f25f5d2c00 100644
--- a/ui/display/screen.h
+++ b/ui/display/screen.h
@@ -1,19 +1,101 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_DISPLAY_SCREEN_H_
#define UI_DISPLAY_SCREEN_H_
-#include "ui/gfx/screen.h"
+#include <vector>
-namespace display {
+#include "base/macros.h"
+#include "ui/display/display.h"
+#include "ui/display/display_export.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace gfx {
+class Display;
+class Point;
+class Rect;
+}
-// TODO(oshima): move the gfx::Screen to display::Screen.
+namespace display {
using Display = gfx::Display;
-using DisplayObserver = gfx::DisplayObserver;
-using Screen = gfx::Screen;
+class DisplayObserver;
+
+// A utility class for getting various info about screen size, displays,
+// cursor position, etc.
+//
+// Note that this class does not represent an individual display connected to a
+// computer -- see the Display class for that. A single Screen object exists
+// regardless of the number of connected displays.
+class DISPLAY_EXPORT Screen {
+ public:
+ Screen();
+ virtual ~Screen();
+
+ // Retrieves the single Screen object.
+ static Screen* GetScreen();
+
+ // Sets the global screen. NOTE: this does not take ownership of |screen|.
+ // Tests must be sure to reset any state they install.
+ static void SetScreenInstance(Screen* instance);
+
+ // Returns the current absolute position of the mouse pointer.
+ virtual gfx::Point GetCursorScreenPoint() = 0;
+
+ // Returns true if the cursor is directly over |window|.
+ virtual bool IsWindowUnderCursor(gfx::NativeWindow window) = 0;
+
+ // Returns the window at the given screen coordinate |point|.
+ virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) = 0;
+
+ // Returns the number of displays.
+ // Mirrored displays are excluded; this method is intended to return the
+ // number of distinct, usable displays.
+ virtual int GetNumDisplays() const = 0;
+
+ // Returns the list of displays that are currently available.
+ virtual std::vector<display::Display> GetAllDisplays() const = 0;
+
+ // Returns the display nearest the specified window.
+ // If the window is NULL or the window is not rooted to a display this will
+ // return the primary display.
+ virtual display::Display GetDisplayNearestWindow(
+ gfx::NativeView view) const = 0;
+
+ // Returns the display nearest the specified point. |point| should be in DIPs.
+ virtual display::Display GetDisplayNearestPoint(
+ const gfx::Point& point) const = 0;
+
+ // Returns the display that most closely intersects the provided bounds.
+ virtual display::Display GetDisplayMatching(
+ const gfx::Rect& match_rect) const = 0;
+
+ // Returns the primary display.
+ virtual display::Display GetPrimaryDisplay() const = 0;
+
+ // Adds/Removes display observers.
+ virtual void AddObserver(DisplayObserver* observer) = 0;
+ virtual void RemoveObserver(DisplayObserver* observer) = 0;
+
+ // Converts |screen_rect| to DIP coordinates in the context of |view| clamping
+ // to the enclosing rect if the coordinates do not fall on pixel boundaries.
+ // If |view| is null, the primary display is used as the context.
+ virtual gfx::Rect ScreenToDIPRectInWindow(gfx::NativeView view,
+ const gfx::Rect& screen_rect) const;
+
+ // Converts |dip_rect| to screen coordinates in the context of |view| clamping
+ // to the enclosing rect if the coordinates do not fall on pixel boundaries.
+ // If |view| is null, the primary display is used as the context.
+ virtual gfx::Rect DIPToScreenRectInWindow(gfx::NativeView view,
+ const gfx::Rect& dip_rect) const;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Screen);
+};
+
+Screen* CreateNativeScreen();
-} // display
+} // namespace display
#endif // UI_DISPLAY_SCREEN_H_
« no previous file with comments | « ui/display/mac/screen_mac.mm ('k') | ui/display/screen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698