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

Unified Diff: ash/wm/toplevel_window_event_filter.cc

Issue 9455063: Makes windows scale slightly when dragging the caption. Also wired (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes tests Created 8 years, 10 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 | « ash/wm/toplevel_window_event_filter.h ('k') | ash/wm/toplevel_window_event_filter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/toplevel_window_event_filter.cc
diff --git a/ash/wm/toplevel_window_event_filter.cc b/ash/wm/toplevel_window_event_filter.cc
index 78645fefc7b98f769c6a14ea3a656692d0357c41..353ed18557894e0421557a1316e9c813fe266924 100644
--- a/ash/wm/toplevel_window_event_filter.cc
+++ b/ash/wm/toplevel_window_event_filter.cc
@@ -34,6 +34,10 @@ ToplevelWindowEventFilter::~ToplevelWindowEventFilter() {
bool ToplevelWindowEventFilter::PreHandleKeyEvent(aura::Window* target,
aura::KeyEvent* event) {
+ if (window_resizer_.get() && event->type() == ui::ET_KEY_PRESSED &&
+ event->key_code() == ui::VKEY_ESCAPE) {
+ CompleteDrag(DRAG_REVERT);
+ }
return false;
}
@@ -62,11 +66,19 @@ bool ToplevelWindowEventFilter::PreHandleMouseEvent(aura::Window* target,
return HandleDrag(target, event);
case ui::ET_MOUSE_CAPTURE_CHANGED:
case ui::ET_MOUSE_RELEASED:
- CompleteDrag(target);
+ CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ?
+ DRAG_COMPLETE : DRAG_REVERT);
if (in_move_loop_) {
MessageLoop::current()->Quit();
in_move_loop_ = false;
}
+ // Completing the drag may result in hiding the window. If this happens
+ // return true so no other filters/observers see the event. Otherwise they
+ // see the event on a hidden window.
+ if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED &&
+ !target->IsVisible()) {
+ return true;
+ }
break;
default:
break;
@@ -106,7 +118,7 @@ ui::GestureStatus ToplevelWindowEventFilter::PreHandleGestureEvent(
case ui::ET_GESTURE_SCROLL_END: {
if (!in_gesture_resize_)
return ui::GESTURE_STATUS_UNKNOWN;
- CompleteDrag(target);
+ CompleteDrag(DRAG_COMPLETE);
in_gesture_resize_ = false;
break;
}
@@ -137,7 +149,10 @@ void ToplevelWindowEventFilter::EndMoveLoop() {
return;
in_move_loop_ = false;
- window_resizer_.reset();
+ if (window_resizer_.get()) {
+ window_resizer_->RevertDrag();
+ window_resizer_.reset();
+ }
MessageLoopForUI::current()->Quit();
Shell::GetRootWindow()->PostNativeEvent(ui::CreateNoopEvent());
}
@@ -149,10 +164,14 @@ WindowResizer* ToplevelWindowEventFilter::CreateWindowResizer(
return new WindowResizer(window, point, window_component, grid_size_);
}
-void ToplevelWindowEventFilter::CompleteDrag(aura::Window* window) {
+void ToplevelWindowEventFilter::CompleteDrag(DragCompletionStatus status) {
scoped_ptr<WindowResizer> resizer(window_resizer_.release());
- if (resizer.get())
- resizer->CompleteDrag();
+ if (resizer.get()) {
+ if (status == DRAG_COMPLETE)
+ resizer->CompleteDrag();
+ else
+ resizer->RevertDrag();
+ }
}
bool ToplevelWindowEventFilter::HandleDrag(aura::Window* target,
« no previous file with comments | « ash/wm/toplevel_window_event_filter.h ('k') | ash/wm/toplevel_window_event_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698