blob: 07674df3288f8341fc0421d48318299256975310 (
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
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright (c) 2012 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/workspace_controller.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/workspace_event_filter.h"
#include "ash/wm/workspace/workspace_layout_manager.h"
#include "ash/wm/workspace/workspace_manager.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
namespace ash {
namespace internal {
namespace {
// Size of the grid when a grid is enabled.
const int kGridSize = 16;
} // namespace
WorkspaceController::WorkspaceController(aura::Window* viewport)
: viewport_(viewport),
workspace_manager_(new WorkspaceManager(viewport)),
layout_manager_(NULL),
event_filter_(NULL) {
aura::RootWindow* root_window = viewport->GetRootWindow();
event_filter_ = new WorkspaceEventFilter(viewport);
viewport->SetEventFilter(event_filter_);
layout_manager_ = new WorkspaceLayoutManager(
root_window, workspace_manager_.get());
viewport->SetLayoutManager(layout_manager_);
root_window->AddObserver(this);
SetGridSize(kGridSize);
}
WorkspaceController::~WorkspaceController() {
viewport_->GetRootWindow()->RemoveObserver(this);
// WorkspaceLayoutManager may attempt to access state from us. Destroy it now.
if (viewport_->layout_manager() == layout_manager_)
viewport_->SetLayoutManager(NULL);
}
void WorkspaceController::SetGridSize(int grid_size) {
workspace_manager_->set_grid_size(grid_size);
event_filter_->set_grid_size(grid_size);
}
void WorkspaceController::OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) {
if (key == aura::client::kRootWindowActiveWindowKey)
workspace_manager_->SetActiveWorkspaceByWindow(wm::GetActiveWindow());
}
} // namespace internal
} // namespace ash
|