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

Side by Side Diff: ash/wm/toplevel_window_event_handler.cc

Issue 144193002: Only drag or maximize / restore when event has not yet been handled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Always ignore handled events. Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/toplevel_window_event_handler.h" 5 #include "ash/wm/toplevel_window_event_handler.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/wm/resize_shadow_controller.h" 8 #include "ash/wm/resize_shadow_controller.h"
9 #include "ash/wm/window_resizer.h" 9 #include "ash/wm/window_resizer.h"
10 #include "ash/wm/window_state.h" 10 #include "ash/wm/window_state.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 void ToplevelWindowEventHandler::OnKeyEvent(ui::KeyEvent* event) { 133 void ToplevelWindowEventHandler::OnKeyEvent(ui::KeyEvent* event) {
134 if (window_resizer_.get() && event->type() == ui::ET_KEY_PRESSED && 134 if (window_resizer_.get() && event->type() == ui::ET_KEY_PRESSED &&
135 event->key_code() == ui::VKEY_ESCAPE) { 135 event->key_code() == ui::VKEY_ESCAPE) {
136 CompleteDrag(DRAG_REVERT); 136 CompleteDrag(DRAG_REVERT);
137 } 137 }
138 } 138 }
139 139
140 void ToplevelWindowEventHandler::OnMouseEvent( 140 void ToplevelWindowEventHandler::OnMouseEvent(
141 ui::MouseEvent* event) { 141 ui::MouseEvent* event) {
142 if (event->handled())
143 return;
142 if ((event->flags() & 144 if ((event->flags() &
143 (ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON)) != 0) 145 (ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON)) != 0)
144 return; 146 return;
145 147
146 if (in_gesture_drag_) 148 if (in_gesture_drag_)
147 return; 149 return;
148 150
149 aura::Window* target = static_cast<aura::Window*>(event->target()); 151 aura::Window* target = static_cast<aura::Window*>(event->target());
150 switch (event->type()) { 152 switch (event->type()) {
151 case ui::ET_MOUSE_PRESSED: 153 case ui::ET_MOUSE_PRESSED:
(...skipping 11 matching lines...) Expand all
163 break; 165 break;
164 case ui::ET_MOUSE_EXITED: 166 case ui::ET_MOUSE_EXITED:
165 HandleMouseExited(target, event); 167 HandleMouseExited(target, event);
166 break; 168 break;
167 default: 169 default:
168 break; 170 break;
169 } 171 }
170 } 172 }
171 173
172 void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) { 174 void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
175 if (event->handled())
176 return;
173 aura::Window* target = static_cast<aura::Window*>(event->target()); 177 aura::Window* target = static_cast<aura::Window*>(event->target());
174 if (!target->delegate()) 178 if (!target->delegate())
175 return; 179 return;
176 180
177 if (window_resizer_.get() && !in_gesture_drag_) 181 if (window_resizer_.get() && !in_gesture_drag_)
178 return; 182 return;
179 183
180 if (window_resizer_.get() && 184 if (window_resizer_.get() &&
181 window_resizer_->resizer()->GetTarget() != target) { 185 window_resizer_->resizer()->GetTarget() != target) {
182 return; 186 return;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 aura::Window* target, 381 aura::Window* target,
378 ui::MouseEvent* event) { 382 ui::MouseEvent* event) {
379 if (event->phase() != ui::EP_PRETARGET) 383 if (event->phase() != ui::EP_PRETARGET)
380 return; 384 return;
381 385
382 CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ? 386 CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ?
383 DRAG_COMPLETE : DRAG_REVERT); 387 DRAG_COMPLETE : DRAG_REVERT);
384 // Completing the drag may result in hiding the window. If this happens 388 // Completing the drag may result in hiding the window. If this happens
385 // return true so no other handlers/observers see the event. Otherwise 389 // return true so no other handlers/observers see the event. Otherwise
386 // they see the event on a hidden window. 390 // they see the event on a hidden window.
387 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED && 391 if (window_resizer_ &&
392 event->type() == ui::ET_MOUSE_CAPTURE_CHANGED &&
388 !target->IsVisible()) { 393 !target->IsVisible()) {
389 event->StopPropagation(); 394 event->StopPropagation();
390 } 395 }
391 } 396 }
392 397
393 void ToplevelWindowEventHandler::HandleDrag( 398 void ToplevelWindowEventHandler::HandleDrag(
394 aura::Window* target, 399 aura::Window* target,
395 ui::LocatedEvent* event) { 400 ui::LocatedEvent* event) {
396 // This function only be triggered to move window 401 // This function only be triggered to move window
397 // by mouse drag or touch move event. 402 // by mouse drag or touch move event.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 494
490 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { 495 void ToplevelWindowEventHandler::ResizerWindowDestroyed() {
491 // We explicitly don't invoke RevertDrag() since that may do things to window. 496 // We explicitly don't invoke RevertDrag() since that may do things to window.
492 // Instead we destroy the resizer. 497 // Instead we destroy the resizer.
493 window_resizer_.reset(); 498 window_resizer_.reset();
494 499
495 CompleteDrag(DRAG_REVERT); 500 CompleteDrag(DRAG_REVERT);
496 } 501 }
497 502
498 } // namespace ash 503 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698