exo: Drop window on touch release

Windows were not dropped after dragging using touch, resulting in broken
input due to unreleased capture. Phantom windows in extended desktop
mode would also stick around.

BUG=738200
TEST=Phantom windows disappear on touch release.

Review-Url: https://codereview.chromium.org/2968593002
Cr-Commit-Position: refs/heads/master@{#483870}
diff --git a/components/exo/shell_surface.cc b/components/exo/shell_surface.cc
index 565afe4..c9be39b 100644
--- a/components/exo/shell_surface.cc
+++ b/components/exo/shell_surface.cc
@@ -1118,6 +1118,50 @@
   }
 }
 
+void ShellSurface::OnGestureEvent(ui::GestureEvent* event) {
+  if (!resizer_) {
+    views::View::OnGestureEvent(event);
+    return;
+  }
+
+  if (event->handled())
+    return;
+
+  // TODO(domlaskowski): Handle touch dragging/resizing for BoundsMode::SHELL.
+  // See crbug.com/738606.
+  switch (event->type()) {
+    case ui::ET_GESTURE_END: {
+      ScopedConfigure scoped_configure(this, false);
+      EndDrag(false /* revert */);
+      break;
+    }
+    case ui::ET_GESTURE_SCROLL_BEGIN:
+    case ui::ET_GESTURE_SCROLL_END:
+    case ui::ET_GESTURE_SCROLL_UPDATE:
+    case ui::ET_GESTURE_TAP:
+    case ui::ET_GESTURE_TAP_DOWN:
+    case ui::ET_GESTURE_TAP_CANCEL:
+    case ui::ET_GESTURE_TAP_UNCONFIRMED:
+    case ui::ET_GESTURE_DOUBLE_TAP:
+    case ui::ET_GESTURE_BEGIN:
+    case ui::ET_GESTURE_TWO_FINGER_TAP:
+    case ui::ET_GESTURE_PINCH_BEGIN:
+    case ui::ET_GESTURE_PINCH_END:
+    case ui::ET_GESTURE_PINCH_UPDATE:
+    case ui::ET_GESTURE_LONG_PRESS:
+    case ui::ET_GESTURE_LONG_TAP:
+    case ui::ET_GESTURE_SWIPE:
+    case ui::ET_GESTURE_SHOW_PRESS:
+    case ui::ET_SCROLL:
+    case ui::ET_SCROLL_FLING_START:
+    case ui::ET_SCROLL_FLING_CANCEL:
+      break;
+    default:
+      NOTREACHED();
+      break;
+  }
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // ui::AcceleratorTarget overrides:
 
diff --git a/components/exo/shell_surface.h b/components/exo/shell_surface.h
index 8f570c7e..ab05c116 100644
--- a/components/exo/shell_surface.h
+++ b/components/exo/shell_surface.h
@@ -271,6 +271,7 @@
   // Overridden from ui::EventHandler:
   void OnKeyEvent(ui::KeyEvent* event) override;
   void OnMouseEvent(ui::MouseEvent* event) override;
+  void OnGestureEvent(ui::GestureEvent* event) override;
 
   // Overridden from ui::AcceleratorTarget:
   bool AcceleratorPressed(const ui::Accelerator& accelerator) override;