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

Side by Side Diff: ash/wm/workspace/workspace2.cc

Issue 10916221: Make ToplevelWindowEventFilter and WorkspaceEventFilter into event handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « ash/wm/workspace/workspace2.h ('k') | ash/wm/workspace/workspace_event_filter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/workspace/workspace2.h" 5 #include "ash/wm/workspace/workspace2.h"
6 6
7 #include "ash/shell_window_ids.h" 7 #include "ash/shell_window_ids.h"
8 #include "ash/wm/property_util.h" 8 #include "ash/wm/property_util.h"
9 #include "ash/wm/window_properties.h" 9 #include "ash/wm/window_properties.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
11 #include "ash/wm/workspace/workspace_event_filter.h" 11 #include "ash/wm/workspace/workspace_event_handler.h"
12 #include "ash/wm/workspace/workspace_manager2.h" 12 #include "ash/wm/workspace/workspace_manager2.h"
13 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
14 14
15 namespace ash { 15 namespace ash {
16 namespace internal { 16 namespace internal {
17 17
18 Workspace2::Workspace2(WorkspaceManager2* manager, 18 Workspace2::Workspace2(WorkspaceManager2* manager,
19 aura::Window* parent, 19 aura::Window* parent,
20 bool is_maximized) 20 bool is_maximized)
21 : is_maximized_(is_maximized), 21 : is_maximized_(is_maximized),
22 workspace_manager_(manager), 22 workspace_manager_(manager),
23 window_(new aura::Window(NULL)), 23 window_(new aura::Window(NULL)),
24 event_filter_(new WorkspaceEventFilter(window_)) { 24 event_handler_(new WorkspaceEventHandler(window_)) {
25 window_->SetProperty(internal::kChildWindowVisibilityChangesAnimatedKey, 25 window_->SetProperty(internal::kChildWindowVisibilityChangesAnimatedKey,
26 true); 26 true);
27 window_->set_id(kShellWindowId_WorkspaceContainer); 27 window_->set_id(kShellWindowId_WorkspaceContainer);
28 window_->SetName("WorkspaceContainer"); 28 window_->SetName("WorkspaceContainer");
29 window_->Init(ui::LAYER_NOT_DRAWN); 29 window_->Init(ui::LAYER_NOT_DRAWN);
30 // Do this so when animating out windows don't extend beyond the bounds. 30 // Do this so when animating out windows don't extend beyond the bounds.
31 window_->layer()->SetMasksToBounds(true); 31 window_->layer()->SetMasksToBounds(true);
32 window_->Hide(); 32 window_->Hide();
33 window_->SetParent(parent); 33 window_->SetParent(parent);
34 window_->SetEventFilter(event_filter_); 34 window_->AddPreTargetHandler(event_handler_);
35 window_->SetProperty(internal::kUsesScreenCoordinatesKey, true); 35 window_->SetProperty(internal::kUsesScreenCoordinatesKey, true);
36 } 36 }
37 37
38 Workspace2::~Workspace2() { 38 Workspace2::~Workspace2() {
39 // ReleaseWindow() should have been invoked before we're deleted. 39 // ReleaseWindow() should have been invoked before we're deleted.
40 DCHECK(!window_); 40 DCHECK(!window_);
41 } 41 }
42 42
43 aura::Window* Workspace2::ReleaseWindow() { 43 aura::Window* Workspace2::ReleaseWindow() {
44 // Remove the LayoutManager and EventFilter as they refer back to us and/or 44 // Remove the LayoutManager and EventFilter as they refer back to us and/or
45 // WorkspaceManager. 45 // WorkspaceManager.
46 window_->SetLayoutManager(NULL); 46 window_->SetLayoutManager(NULL);
47 window_->SetEventFilter(NULL); 47 window_->SetEventFilter(NULL);
48 aura::Window* window = window_; 48 aura::Window* window = window_;
49 window_ = NULL; 49 window_ = NULL;
50 event_filter_ = NULL; 50 event_handler_ = NULL;
51 return window; 51 return window;
52 } 52 }
53 53
54 bool Workspace2::ShouldMoveToPending() const { 54 bool Workspace2::ShouldMoveToPending() const {
55 if (!is_maximized_) 55 if (!is_maximized_)
56 return false; 56 return false;
57 57
58 bool has_visible_non_maximized_window = false; 58 bool has_visible_non_maximized_window = false;
59 for (size_t i = 0; i < window_->children().size(); ++i) { 59 for (size_t i = 0; i < window_->children().size(); ++i) {
60 aura::Window* child(window_->children()[i]); 60 aura::Window* child(window_->children()[i]);
(...skipping 16 matching lines...) Expand all
77 WorkspaceManager2::WillRestoreMaximized(child)) { 77 WorkspaceManager2::WillRestoreMaximized(child)) {
78 if (++count == 2) 78 if (++count == 2)
79 return count; 79 return count;
80 } 80 }
81 } 81 }
82 return count; 82 return count;
83 } 83 }
84 84
85 } // namespace internal 85 } // namespace internal
86 } // namespace ash 86 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace2.h ('k') | ash/wm/workspace/workspace_event_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698