summaryrefslogtreecommitdiffstats
path: root/chromium/ash/wm/panels/panel_window_event_handler.cc
blob: cb4946991951c5df45c5c3d6c72c2c38a3791f50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/wm/panels/panel_window_event_handler.h"

#include "ash/wm/window_state.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/base/hit_test.h"
#include "ui/events/event.h"

namespace ash {
namespace internal {

PanelWindowEventHandler::PanelWindowEventHandler(aura::Window* owner)
    : ToplevelWindowEventHandler(owner) {
}

PanelWindowEventHandler::~PanelWindowEventHandler() {
}

void PanelWindowEventHandler::OnMouseEvent(ui::MouseEvent* event) {
  aura::Window* target = static_cast<aura::Window*>(event->target());
  if (event->type() == ui::ET_MOUSE_PRESSED &&
      event->flags() & ui::EF_IS_DOUBLE_CLICK &&
      event->IsOnlyLeftMouseButton() &&
      target->delegate()->GetNonClientComponent(event->location()) ==
          HTCAPTION) {
    wm::GetWindowState(target)->Minimize();
    return;
  }
  ToplevelWindowEventHandler::OnMouseEvent(event);
}

void PanelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
  aura::Window* target = static_cast<aura::Window*>(event->target());
  if (event->type() == ui::ET_GESTURE_TAP &&
      event->details().tap_count() == 2 &&
      target->delegate()->GetNonClientComponent(event->location()) ==
          HTCAPTION) {
    wm::GetWindowState(target)->Minimize();
    event->StopPropagation();
    return;
  }
  ToplevelWindowEventHandler::OnGestureEvent(event);
}

}  // namespace internal
}  // namespace ash