Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ui / ozone / platform / dri / cursor_factory_evdev_dri.cc
index fd073ca..273dd1a 100644 (file)
@@ -5,21 +5,21 @@
 #include "ui/ozone/platform/dri/cursor_factory_evdev_dri.h"
 
 #include "ui/gfx/geometry/point_conversions.h"
-#include "ui/gfx/ozone/dri/dri_surface_factory.h"
+#include "ui/ozone/platform/dri/dri_surface_factory.h"
 
 namespace ui {
 
-CursorFactoryEvdevDri::CursorFactoryEvdevDri(gfx::DriSurfaceFactory* dri)
+CursorFactoryEvdevDri::CursorFactoryEvdevDri(DriSurfaceFactory* dri)
     : dri_(dri) {
-  cursor_window_ = dri_->GetAcceleratedWidget();
-  cursor_bounds_ = gfx::RectF(0, 0, 2560, 1700);  // TODO(spang): Argh!
-  cursor_location_ =
-      gfx::PointF(cursor_bounds_.width() / 2, cursor_bounds_.height() / 2);
+  // TODO(dnicoara) Assume the first widget since at this point there are no
+  // widgets initialized.
+  cursor_window_ = DriSurfaceFactory::kDefaultWidgetHandle;
+  cursor_location_ = gfx::PointF(2560 / 2, 1700 / 2);  // TODO(spang): Argh!
 
   // The DRI cursor is invisible unless explicitly set. Therefore, set the
   // pointer cursor on initialization.
   // TODO(spang): Move this to DRI window initialization.
-  SetCursor(dri->GetAcceleratedWidget(), GetDefaultCursor(kCursorPointer));
+  SetCursor(cursor_window_, GetDefaultCursor(kCursorPointer));
 }
 
 CursorFactoryEvdevDri::~CursorFactoryEvdevDri() {}
@@ -29,6 +29,7 @@ void CursorFactoryEvdevDri::SetBitmapCursor(
     scoped_refptr<BitmapCursorOzone> cursor) {
   if (cursor_ == cursor)
     return;
+
   cursor_ = cursor;
   if (cursor_)
     dri_->SetHardwareCursor(
@@ -39,12 +40,16 @@ void CursorFactoryEvdevDri::SetBitmapCursor(
 
 void CursorFactoryEvdevDri::MoveCursorTo(gfx::AcceleratedWidget widget,
                                          const gfx::PointF& location) {
+  if (widget != cursor_window_)
+    dri_->UnsetHardwareCursor(cursor_window_);
+
   cursor_window_ = widget;
   cursor_location_ = location;
-  cursor_location_.SetToMax(
-      gfx::PointF(cursor_bounds_.x(), cursor_bounds_.y()));
-  cursor_location_.SetToMin(
-      gfx::PointF(cursor_bounds_.right(), cursor_bounds_.bottom()));
+
+  gfx::Size size = dri_->GetWidgetSize(cursor_window_);
+  cursor_location_.SetToMax(gfx::PointF(0, 0));
+  cursor_location_.SetToMin(gfx::PointF(size.width(), size.height()));
+
   if (cursor_)
     dri_->MoveHardwareCursor(cursor_window_, bitmap_location());
 }
@@ -53,7 +58,7 @@ void CursorFactoryEvdevDri::MoveCursor(const gfx::Vector2dF& delta) {
   MoveCursorTo(cursor_window_, cursor_location_ + delta);
 }
 
-gfx::AcceleratedWidget CursorFactoryEvdevDri::window() {
+gfx::AcceleratedWidget CursorFactoryEvdevDri::GetCursorWindow() {
   return cursor_window_;
 }