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

Side by Side Diff: athena/wm/window_manager_impl.cc

Issue 394043002: athena: Add a minimized state for the home-card. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 6 years, 5 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 | « athena/wm/public/window_manager_observer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/wm/public/window_manager.h" 5 #include "athena/wm/public/window_manager.h"
6 6
7 #include "athena/input/public/accelerator_manager.h" 7 #include "athena/input/public/accelerator_manager.h"
8 #include "athena/screen/public/screen_manager.h" 8 #include "athena/screen/public/screen_manager.h"
9 #include "athena/wm/public/window_manager_observer.h"
9 #include "athena/wm/window_overview_mode.h" 10 #include "athena/wm/window_overview_mode.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/observer_list.h"
11 #include "ui/aura/layout_manager.h" 13 #include "ui/aura/layout_manager.h"
12 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
13 #include "ui/wm/public/window_types.h" 15 #include "ui/wm/public/window_types.h"
14 16
15 namespace athena { 17 namespace athena {
16 namespace { 18 namespace {
17 19
18 class WindowManagerImpl : public WindowManager, 20 class WindowManagerImpl : public WindowManager,
19 public WindowOverviewModeDelegate, 21 public WindowOverviewModeDelegate,
20 public aura::WindowObserver, 22 public aura::WindowObserver,
21 public AcceleratorHandler { 23 public AcceleratorHandler {
22 public: 24 public:
23 WindowManagerImpl(); 25 WindowManagerImpl();
24 virtual ~WindowManagerImpl(); 26 virtual ~WindowManagerImpl();
25 27
26 void Layout(); 28 void Layout();
27 29
28 // WindowManager: 30 // WindowManager:
29 virtual void ToggleOverview() OVERRIDE { 31 virtual void ToggleOverview() OVERRIDE {
30 if (overview_) 32 if (overview_) {
31 overview_.reset(); 33 overview_.reset();
32 else 34 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
35 OnOverviewModeExit());
36 } else {
33 overview_ = WindowOverviewMode::Create(container_.get(), this); 37 overview_ = WindowOverviewMode::Create(container_.get(), this);
38 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
39 OnOverviewModeEnter());
40 }
34 } 41 }
35 42
36 private: 43 private:
37 enum Command { 44 enum Command {
38 COMMAND_TOGGLE_OVERVIEW, 45 COMMAND_TOGGLE_OVERVIEW,
39 }; 46 };
40 47
41 void InstallAccelerators() { 48 void InstallAccelerators() {
42 const AcceleratorData accelerator_data[] = { 49 const AcceleratorData accelerator_data[] = {
43 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW, 50 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, COMMAND_TOGGLE_OVERVIEW,
44 AF_NONE}, 51 AF_NONE},
45 }; 52 };
46 AcceleratorManager::Get()->RegisterAccelerators( 53 AcceleratorManager::Get()->RegisterAccelerators(
47 accelerator_data, arraysize(accelerator_data), this); 54 accelerator_data, arraysize(accelerator_data), this);
48 } 55 }
49 56
57 // WindowManager:
58 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE {
59 observers_.AddObserver(observer);
60 }
61
62 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE {
63 observers_.RemoveObserver(observer);
64 }
65
50 // WindowOverviewModeDelegate: 66 // WindowOverviewModeDelegate:
51 virtual void OnSelectWindow(aura::Window* window) OVERRIDE { 67 virtual void OnSelectWindow(aura::Window* window) OVERRIDE {
52 CHECK_EQ(container_.get(), window->parent()); 68 CHECK_EQ(container_.get(), window->parent());
53 container_->StackChildAtTop(window); 69 container_->StackChildAtTop(window);
54 overview_.reset(); 70 overview_.reset();
71 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
72 OnOverviewModeExit());
55 } 73 }
56 74
57 // aura::WindowObserver 75 // aura::WindowObserver
58 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { 76 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {
59 if (window == container_) 77 if (window == container_)
60 container_.reset(); 78 container_.reset();
61 } 79 }
62 80
63 // AcceleratorHandler: 81 // AcceleratorHandler:
64 virtual bool IsCommandEnabled(int command_id) const OVERRIDE { return true; } 82 virtual bool IsCommandEnabled(int command_id) const OVERRIDE { return true; }
65 virtual bool OnAcceleratorFired(int command_id, 83 virtual bool OnAcceleratorFired(int command_id,
66 const ui::Accelerator& accelerator) OVERRIDE { 84 const ui::Accelerator& accelerator) OVERRIDE {
67 switch (command_id) { 85 switch (command_id) {
68 case COMMAND_TOGGLE_OVERVIEW: 86 case COMMAND_TOGGLE_OVERVIEW:
69 ToggleOverview(); 87 ToggleOverview();
70 break; 88 break;
71 } 89 }
72 return true; 90 return true;
73 } 91 }
74 92
75 scoped_ptr<aura::Window> container_; 93 scoped_ptr<aura::Window> container_;
76 scoped_ptr<WindowOverviewMode> overview_; 94 scoped_ptr<WindowOverviewMode> overview_;
95 ObserverList<WindowManagerObserver> observers_;
77 96
78 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); 97 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl);
79 }; 98 };
80 99
81 class WindowManagerImpl* instance = NULL; 100 class WindowManagerImpl* instance = NULL;
82 101
83 class AthenaContainerLayoutManager : public aura::LayoutManager { 102 class AthenaContainerLayoutManager : public aura::LayoutManager {
84 public: 103 public:
85 AthenaContainerLayoutManager() {} 104 AthenaContainerLayoutManager() {}
86 virtual ~AthenaContainerLayoutManager() {} 105 virtual ~AthenaContainerLayoutManager() {}
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return instance; 167 return instance;
149 } 168 }
150 169
151 // static 170 // static
152 void WindowManager::Shutdown() { 171 void WindowManager::Shutdown() {
153 DCHECK(instance); 172 DCHECK(instance);
154 delete instance; 173 delete instance;
155 DCHECK(!instance); 174 DCHECK(!instance);
156 } 175 }
157 176
177 // static
178 WindowManager* WindowManager::GetInstance() {
179 DCHECK(instance);
180 return instance;
181 }
182
158 } // namespace athena 183 } // namespace athena
OLDNEW
« no previous file with comments | « athena/wm/public/window_manager_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698