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

Unified Diff: components/exo/pointer.cc

Issue 2934953002: exo: Reparent pointer surface (Closed)
Patch Set: Add comment Created 3 years, 6 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 | « components/exo/pointer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/pointer.cc
diff --git a/components/exo/pointer.cc b/components/exo/pointer.cc
index 637ecb1bf43faa18c56205b2d6e6cd70d7003d26..2271212085be6ee4ae72f40f096ca8100cd30ceb 100644
--- a/components/exo/pointer.cc
+++ b/components/exo/pointer.cc
@@ -78,6 +78,7 @@ Pointer::Pointer(PointerDelegate* delegate)
auto* helper = WMHelper::GetInstance();
helper->AddPreTargetHandler(this);
helper->AddCursorObserver(this);
+ helper->AddDisplayConfigurationObserver(this);
}
Pointer::~Pointer() {
@@ -89,6 +90,7 @@ Pointer::~Pointer() {
focus_->UnregisterCursorProvider(this);
}
auto* helper = WMHelper::GetInstance();
+ helper->RemoveDisplayConfigurationObserver(this);
helper->RemoveCursorObserver(this);
helper->RemovePreTargetHandler(this);
}
@@ -108,24 +110,7 @@ void Pointer::SetCursor(Surface* surface, const gfx::Point& hotspot) {
DLOG(ERROR) << "Surface has already been assigned a role";
return;
}
- if (surface_) {
- surface_->window()->SetTransform(gfx::Transform());
- if (surface_->window()->parent())
- surface_->window()->parent()->RemoveChild(surface_->window());
- surface_->SetSurfaceDelegate(nullptr);
- surface_->RemoveSurfaceObserver(this);
- }
- surface_ = surface;
- if (surface_) {
- surface_->SetSurfaceDelegate(this);
- surface_->AddSurfaceObserver(this);
- // Note: Surface window needs to be added to the tree so we can take a
- // snapshot. Where in the tree is not important but we might as well use
- // the cursor container.
- WMHelper::GetInstance()
- ->GetPrimaryDisplayContainer(ash::kShellWindowId_MouseCursorContainer)
- ->AddChild(surface_->window());
- }
+ UpdatePointerSurface(surface);
cursor_changed = true;
}
@@ -280,6 +265,13 @@ void Pointer::OnCursorDisplayChanged(const display::Display& display) {
UpdateCursor();
}
+////////////////////////////////////////////////////////////////////////////////
+// WMHelper::DisplayConfigurationObserver overrides:
+
+void Pointer::OnDisplayConfigurationChanged() {
+ UpdatePointerSurface(surface_);
+}
+
////////////////////////////////////////////////////////////////////////////////
// SurfaceDelegate overrides:
@@ -321,6 +313,27 @@ Surface* Pointer::GetEffectiveTargetForEvent(ui::Event* event) const {
return delegate_->CanAcceptPointerEventsForSurface(target) ? target : nullptr;
}
+void Pointer::UpdatePointerSurface(Surface* surface) {
+ if (surface_) {
+ surface_->window()->SetTransform(gfx::Transform());
+ if (surface_->window()->parent())
+ surface_->window()->parent()->RemoveChild(surface_->window());
+ surface_->SetSurfaceDelegate(nullptr);
+ surface_->RemoveSurfaceObserver(this);
+ }
+ surface_ = surface;
+ if (surface_) {
+ surface_->SetSurfaceDelegate(this);
+ surface_->AddSurfaceObserver(this);
+ // Note: Surface window needs to be added to the tree so we can take a
+ // snapshot. Where in the tree is not important but we might as well use
+ // the cursor container.
+ WMHelper::GetInstance()
+ ->GetPrimaryDisplayContainer(ash::kShellWindowId_MouseCursorContainer)
+ ->AddChild(surface_->window());
+ }
+}
+
void Pointer::CaptureCursor(const gfx::Point& hotspot) {
DCHECK(surface_);
DCHECK(focus_);
« no previous file with comments | « components/exo/pointer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698