forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshelf_window_watcher_item_delegate.cc
75 lines (61 loc) · 2.1 KB
/
shelf_window_watcher_item_delegate.cc
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// 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/shelf/shelf_window_watcher_item_delegate.h"
#include "ash/shelf/shelf_model.h"
#include "ash/shelf/shelf_util.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/wm/window_state.h"
#include "ui/aura/window.h"
#include "ui/views/corewm/window_animations.h"
#include "ui/views/widget/widget.h"
namespace ash {
namespace internal {
ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(
aura::Window* window, ShelfModel* model)
: window_(window),
model_(model) {
}
ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {
}
void ShelfWindowWatcherItemDelegate::Close() {
views::Widget::GetWidgetForNativeWindow(window_)->Close();
}
bool ShelfWindowWatcherItemDelegate::ItemSelected(const ui::Event& event) {
wm::WindowState* window_state = wm::GetWindowState(window_);
if (window_state->IsActive()) {
if (event.type() & ui::ET_KEY_RELEASED) {
views::corewm::AnimateWindow(window_,
views::corewm::WINDOW_ANIMATION_TYPE_BOUNCE);
} else {
window_state->Minimize();
}
} else {
window_state->Activate();
}
return false;
}
base::string16 ShelfWindowWatcherItemDelegate::GetTitle() {
return GetShelfItemDetailsForWindow(window_)->title;
}
ui::MenuModel* ShelfWindowWatcherItemDelegate::CreateContextMenu(
aura::Window* root_window) {
ash::LauncherItem item =
*(model_->ItemByID(GetLauncherIDForWindow(window_)));
return Shell::GetInstance()->delegate()->CreateContextMenu(root_window,
this,
&item);
}
ShelfMenuModel* ShelfWindowWatcherItemDelegate::CreateApplicationMenu(
int event_flags) {
return NULL;
}
bool ShelfWindowWatcherItemDelegate::IsDraggable() {
return true;
}
bool ShelfWindowWatcherItemDelegate::ShouldShowTooltip() {
return true;
}
} // namespace internal
} // namespace ash