| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/panels/panel_window_event_handler.h" | 5 #include "ash/wm/panels/panel_window_event_handler.h" |
| 6 | 6 |
| 7 #include "ash/shell_port.h" | 7 #include "ash/shell_port.h" |
| 8 #include "ash/wm/window_state.h" | 8 #include "ash/wm/window_state.h" |
| 9 #include "ash/wm/window_util.h" |
| 9 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 10 #include "ui/aura/window_delegate.h" | 11 #include "ui/aura/window_delegate.h" |
| 11 #include "ui/base/hit_test.h" | 12 #include "ui/base/hit_test.h" |
| 12 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
| 13 | 14 |
| 14 namespace ash { | 15 namespace ash { |
| 15 | 16 |
| 16 PanelWindowEventHandler::PanelWindowEventHandler() {} | 17 PanelWindowEventHandler::PanelWindowEventHandler() {} |
| 17 | 18 |
| 18 PanelWindowEventHandler::~PanelWindowEventHandler() {} | 19 PanelWindowEventHandler::~PanelWindowEventHandler() {} |
| 19 | 20 |
| 20 void PanelWindowEventHandler::OnMouseEvent(ui::MouseEvent* event) { | 21 void PanelWindowEventHandler::OnMouseEvent(ui::MouseEvent* event) { |
| 21 aura::Window* target = static_cast<aura::Window*>(event->target()); | 22 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 22 if (!event->handled() && event->type() == ui::ET_MOUSE_PRESSED && | 23 if (!event->handled() && event->type() == ui::ET_MOUSE_PRESSED && |
| 23 event->flags() & ui::EF_IS_DOUBLE_CLICK && | 24 event->flags() & ui::EF_IS_DOUBLE_CLICK && |
| 24 event->IsOnlyLeftMouseButton() && | 25 event->IsOnlyLeftMouseButton() && |
| 25 target->delegate()->GetNonClientComponent(event->location()) == | 26 wm::GetNonClientComponent(target, event->location()) == HTCAPTION) { |
| 26 HTCAPTION) { | |
| 27 ShellPort::Get()->RecordUserMetricsAction(UMA_PANEL_MINIMIZE_CAPTION_CLICK); | 27 ShellPort::Get()->RecordUserMetricsAction(UMA_PANEL_MINIMIZE_CAPTION_CLICK); |
| 28 wm::GetWindowState(target)->Minimize(); | 28 wm::GetWindowState(target)->Minimize(); |
| 29 event->StopPropagation(); | 29 event->StopPropagation(); |
| 30 return; | 30 return; |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 void PanelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) { | 34 void PanelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) { |
| 35 aura::Window* target = static_cast<aura::Window*>(event->target()); | 35 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 36 if (!event->handled() && event->type() == ui::ET_GESTURE_TAP && | 36 if (!event->handled() && event->type() == ui::ET_GESTURE_TAP && |
| 37 event->details().tap_count() == 2 && | 37 event->details().tap_count() == 2 && |
| 38 target->delegate()->GetNonClientComponent(event->location()) == | 38 wm::GetNonClientComponent(target, event->location()) == HTCAPTION) { |
| 39 HTCAPTION) { | |
| 40 ShellPort::Get()->RecordUserMetricsAction( | 39 ShellPort::Get()->RecordUserMetricsAction( |
| 41 UMA_PANEL_MINIMIZE_CAPTION_GESTURE); | 40 UMA_PANEL_MINIMIZE_CAPTION_GESTURE); |
| 42 wm::GetWindowState(target)->Minimize(); | 41 wm::GetWindowState(target)->Minimize(); |
| 43 event->StopPropagation(); | 42 event->StopPropagation(); |
| 44 return; | 43 return; |
| 45 } | 44 } |
| 46 } | 45 } |
| 47 | 46 |
| 48 } // namespace ash | 47 } // namespace ash |
| OLD | NEW |