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

Unified Diff: components/exo/display.h

Issue 2396883003: exo: Fix dragging edge cases (Closed)
Patch Set: Fix presubmit errors Created 4 years, 2 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 | « no previous file | components/exo/display.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/display.h
diff --git a/components/exo/display.h b/components/exo/display.h
index d4f3b3d08065b522f902612fe7fabe6c23a806de..6b653592f95f344907deb02c4fd61a661c826c21 100644
--- a/components/exo/display.h
+++ b/components/exo/display.h
@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/memory/shared_memory_handle.h"
+#include "ui/gfx/geometry/point.h"
#if defined(USE_OZONE)
#include "base/files/scoped_file.h"
@@ -20,10 +21,6 @@
#include "ui/gfx/native_pixmap_handle.h"
#endif
-namespace gfx {
-class Point;
-}
-
namespace exo {
class NotificationSurface;
class NotificationSurfaceManager;
@@ -39,12 +36,45 @@ class Buffer;
// The core display class. This class provides functions for creating surfaces
// and is in charge of combining the contents of multiple surfaces into one
// displayable output.
+//
+// This class is also responsible for conversion between server-side screen
+// coordinates and client-side virtual coordinates. This mapping enables
+// support for multiple displays when the client is limited to a single
+// display. In that case, the client uses a virtual display computed as
+// the bounding box of the physical displays, and the server translates
+// positions based on the display layout. For example, P is the client's
+// origin in virtual coordinates, and Q is the server's origin in screen
+// coordinates.
+//
+// P Q
+// +-----+ /
+// | |/
+// | 2 +-----------+
+// | | |
+// +-----+ 1 |
+// | |
+// +-----------+
+//
class Display {
public:
Display();
explicit Display(NotificationSurfaceManager* notification_surface_manager);
~Display();
+ void set_virtual_origin(const gfx::Point& virtual_origin) {
+ virtual_origin_ = virtual_origin;
+ }
+
+ template <typename Point>
reveman 2016/10/16 23:16:02 why the template argument? what are the different
Dominik Laskowski 2016/10/18 21:22:56 gfx::Point and gfx::Rect. Would overloads be prefe
+ void ConvertFromVirtualToScreen(Point* point) const {
+ *point += virtual_origin_.OffsetFromOrigin();
+ }
+
+ template <typename Point>
+ void ConvertFromScreenToVirtual(Point* point) const {
+ *point -= virtual_origin_.OffsetFromOrigin();
+ }
+
// Creates a new surface.
std::unique_ptr<Surface> CreateSurface();
@@ -88,6 +118,9 @@ class Display {
const std::string& notification_id);
private:
+ // Origin of the virtual screen relative to the primary display.
+ gfx::Point virtual_origin_;
+
NotificationSurfaceManager* const notification_surface_manager_;
DISALLOW_COPY_AND_ASSIGN(Display);
« no previous file with comments | « no previous file | components/exo/display.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698