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

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: Indentation 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 void ToplevelWindowEventHandler::OnKeyEvent(ui::KeyEvent* event) { 177 void ToplevelWindowEventHandler::OnKeyEvent(ui::KeyEvent* event) {
178 if (window_resizer_.get() && event->type() == ui::ET_KEY_PRESSED && 178 if (window_resizer_.get() && event->type() == ui::ET_KEY_PRESSED &&
179 event->key_code() == ui::VKEY_ESCAPE) { 179 event->key_code() == ui::VKEY_ESCAPE) {
180 CompleteDrag(DRAG_REVERT); 180 CompleteDrag(DRAG_REVERT);
181 } 181 }
182 } 182 }
183 183
184 void ToplevelWindowEventHandler::OnMouseEvent( 184 void ToplevelWindowEventHandler::OnMouseEvent(
185 ui::MouseEvent* event) { 185 ui::MouseEvent* event) {
186 if (event->handled())
187 return;
186 if ((event->flags() & 188 if ((event->flags() &
187 (ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON)) != 0) 189 (ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON)) != 0)
188 return; 190 return;
189 191
190 if (in_gesture_drag_) 192 if (in_gesture_drag_)
191 return; 193 return;
192 194
193 aura::Window* target = static_cast<aura::Window*>(event->target()); 195 aura::Window* target = static_cast<aura::Window*>(event->target());
194 switch (event->type()) { 196 switch (event->type()) {
195 case ui::ET_MOUSE_PRESSED: 197 case ui::ET_MOUSE_PRESSED:
(...skipping 11 matching lines...) Expand all
207 break; 209 break;
208 case ui::ET_MOUSE_EXITED: 210 case ui::ET_MOUSE_EXITED:
209 HandleMouseExited(target, event); 211 HandleMouseExited(target, event);
210 break; 212 break;
211 default: 213 default:
212 break; 214 break;
213 } 215 }
214 } 216 }
215 217
216 void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) { 218 void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
219 if (event->handled())
220 return;
217 aura::Window* target = static_cast<aura::Window*>(event->target()); 221 aura::Window* target = static_cast<aura::Window*>(event->target());
218 if (!target->delegate()) 222 if (!target->delegate())
219 return; 223 return;
220 224
221 if (window_resizer_.get() && !in_gesture_drag_) 225 if (window_resizer_.get() && !in_gesture_drag_)
222 return; 226 return;
223 227
224 if (window_resizer_.get() && 228 if (window_resizer_.get() &&
225 window_resizer_->resizer()->GetTarget() != target) { 229 window_resizer_->resizer()->GetTarget() != target) {
226 return; 230 return;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 aura::Window* target, 492 aura::Window* target,
489 ui::MouseEvent* event) { 493 ui::MouseEvent* event) {
490 if (event->phase() != ui::EP_PRETARGET) 494 if (event->phase() != ui::EP_PRETARGET)
491 return; 495 return;
492 496
493 CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ? 497 CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ?
494 DRAG_COMPLETE : DRAG_REVERT); 498 DRAG_COMPLETE : DRAG_REVERT);
495 // Completing the drag may result in hiding the window. If this happens 499 // Completing the drag may result in hiding the window. If this happens
496 // return true so no other handlers/observers see the event. Otherwise 500 // return true so no other handlers/observers see the event. Otherwise
497 // they see the event on a hidden window. 501 // they see the event on a hidden window.
498 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED && 502 if (window_resizer_ &&
503 event->type() == ui::ET_MOUSE_CAPTURE_CHANGED &&
499 !target->IsVisible()) { 504 !target->IsVisible()) {
500 event->StopPropagation(); 505 event->StopPropagation();
501 } 506 }
502 } 507 }
503 508
504 void ToplevelWindowEventHandler::HandleDrag( 509 void ToplevelWindowEventHandler::HandleDrag(
505 aura::Window* target, 510 aura::Window* target,
506 ui::LocatedEvent* event) { 511 ui::LocatedEvent* event) {
507 // This function only be triggered to move window 512 // This function only be triggered to move window
508 // by mouse drag or touch move event. 513 // by mouse drag or touch move event.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 605
601 void ToplevelWindowEventHandler::ResizerWindowDestroyed() { 606 void ToplevelWindowEventHandler::ResizerWindowDestroyed() {
602 // We explicitly don't invoke RevertDrag() since that may do things to window. 607 // We explicitly don't invoke RevertDrag() since that may do things to window.
603 // Instead we destroy the resizer. 608 // Instead we destroy the resizer.
604 window_resizer_.reset(); 609 window_resizer_.reset();
605 610
606 CompleteDrag(DRAG_REVERT); 611 CompleteDrag(DRAG_REVERT);
607 } 612 }
608 613
609 } // namespace ash 614 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/panels/panel_window_event_handler.cc ('k') | ash/wm/toplevel_window_event_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698