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

Unified Diff: components/exo/pointer.cc

Issue 2778913002: exo: Clean up cursor code (Closed)
Patch Set: Rebase Created 3 years, 9 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/shell_surface.cc » ('j') | 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 a1778eb34cb1220669661032e29b3b587a0a0cc3..092501a46248c805c0403528c72492abcd7e9d73 100644
--- a/components/exo/pointer.cc
+++ b/components/exo/pointer.cc
@@ -119,7 +119,7 @@ void Pointer::SetCursor(Surface* surface, const gfx::Point& hotspot) {
if (!cursor_changed)
return;
- // If |surface_| is set then ascynchrounsly capture a snapshot of cursor,
+ // If |surface_| is set then asynchronously capture a snapshot of cursor,
// otherwise cancel pending capture and immediately set the cursor to "none".
if (surface_) {
CaptureCursor();
@@ -166,7 +166,10 @@ void Pointer::OnMouseEvent(ui::MouseEvent* event) {
delegate_->OnPointerFrame();
}
- if (focus_ && event->IsMouseEvent() && event->type() != ui::ET_MOUSE_EXITED) {
+ if (!focus_)
+ return;
+
+ if (event->IsMouseEvent() && event->type() != ui::ET_MOUSE_EXITED) {
// Generate motion event if location changed. We need to check location
// here as mouse movement can generate both "moved" and "entered" events
// but OnPointerMotion should only be called if location changed since
@@ -180,44 +183,39 @@ void Pointer::OnMouseEvent(ui::MouseEvent* event) {
switch (event->type()) {
case ui::ET_MOUSE_PRESSED:
- case ui::ET_MOUSE_RELEASED:
- if (focus_) {
- delegate_->OnPointerButton(event->time_stamp(),
- event->changed_button_flags(),
- event->type() == ui::ET_MOUSE_PRESSED);
- delegate_->OnPointerFrame();
- }
+ case ui::ET_MOUSE_RELEASED: {
+ delegate_->OnPointerButton(event->time_stamp(),
+ event->changed_button_flags(),
+ event->type() == ui::ET_MOUSE_PRESSED);
+ delegate_->OnPointerFrame();
break;
- case ui::ET_SCROLL:
- if (focus_) {
- ui::ScrollEvent* scroll_event = static_cast<ui::ScrollEvent*>(event);
- delegate_->OnPointerScroll(
- event->time_stamp(),
- gfx::Vector2dF(scroll_event->x_offset(), scroll_event->y_offset()),
- false);
- delegate_->OnPointerFrame();
- }
+ }
+ case ui::ET_SCROLL: {
+ ui::ScrollEvent* scroll_event = static_cast<ui::ScrollEvent*>(event);
+ delegate_->OnPointerScroll(
+ event->time_stamp(),
+ gfx::Vector2dF(scroll_event->x_offset(), scroll_event->y_offset()),
+ false);
+ delegate_->OnPointerFrame();
break;
- case ui::ET_MOUSEWHEEL:
- if (focus_) {
- delegate_->OnPointerScroll(
- event->time_stamp(),
- static_cast<ui::MouseWheelEvent*>(event)->offset(), true);
- delegate_->OnPointerFrame();
- }
+ }
+ case ui::ET_MOUSEWHEEL: {
+ delegate_->OnPointerScroll(
+ event->time_stamp(),
+ static_cast<ui::MouseWheelEvent*>(event)->offset(), true);
+ delegate_->OnPointerFrame();
break;
- case ui::ET_SCROLL_FLING_START:
- if (focus_) {
- delegate_->OnPointerScrollStop(event->time_stamp());
- delegate_->OnPointerFrame();
- }
+ }
+ case ui::ET_SCROLL_FLING_START: {
+ delegate_->OnPointerScrollStop(event->time_stamp());
+ delegate_->OnPointerFrame();
break;
- case ui::ET_SCROLL_FLING_CANCEL:
- if (focus_) {
- delegate_->OnPointerScrollCancel(event->time_stamp());
- delegate_->OnPointerFrame();
- }
+ }
+ case ui::ET_SCROLL_FLING_CANCEL: {
+ delegate_->OnPointerScrollCancel(event->time_stamp());
+ delegate_->OnPointerFrame();
break;
+ }
case ui::ET_MOUSE_MOVED:
case ui::ET_MOUSE_DRAGGED:
case ui::ET_MOUSE_ENTERED:
@@ -229,14 +227,16 @@ void Pointer::OnMouseEvent(ui::MouseEvent* event) {
break;
}
- if (focus_)
- UpdateCursorScale();
+ UpdateCursorScale();
}
void Pointer::OnScrollEvent(ui::ScrollEvent* event) {
OnMouseEvent(event);
}
+////////////////////////////////////////////////////////////////////////////////
+// WMHelper::CursorObserver overrides:
+
void Pointer::OnCursorSetChanged(ui::CursorSetType cursor_set) {
if (focus_)
UpdateCursorScale();
@@ -321,6 +321,7 @@ void Pointer::UpdateCursorScale() {
void Pointer::CaptureCursor() {
DCHECK(surface_);
+ DCHECK(focus_);
// Set UI scale before submitting capture request.
surface_->window()->layer()->SetTransform(
« no previous file with comments | « no previous file | components/exo/shell_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698