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

Side by Side Diff: ash/shell/shell_main.cc

Issue 9808026: Layout panels on top of their launcher icons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ununsed constanrs removed Created 8 years, 9 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
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 <map> 5 #include <map>
6 6
7 #include "ash/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/launcher/launcher_delegate.h" 8 #include "ash/launcher/launcher_delegate.h"
9 #include "ash/launcher/launcher_model.h" 9 #include "ash/launcher/launcher_model.h"
10 #include "ash/launcher/launcher_types.h" 10 #include "ash/launcher/launcher_types.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/shell_delegate.h" 12 #include "ash/shell_delegate.h"
13 #include "ash/shell_factory.h" 13 #include "ash/shell_factory.h"
14 #include "ash/shell_window_ids.h" 14 #include "ash/shell_window_ids.h"
15 #include "ash/shell/example_factory.h" 15 #include "ash/shell/example_factory.h"
16 #include "ash/shell/toplevel_window.h" 16 #include "ash/shell/toplevel_window.h"
17 #include "ash/shell/shell_main_parts.h" 17 #include "ash/shell/shell_main_parts.h"
18 #include "ash/wm/partial_screenshot_view.h" 18 #include "ash/wm/partial_screenshot_view.h"
19 #include "ash/wm/window_util.h" 19 #include "ash/wm/window_util.h"
20 #include "base/at_exit.h" 20 #include "base/at_exit.h"
21 #include "base/command_line.h" 21 #include "base/command_line.h"
22 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
23 #include "base/message_loop.h" 23 #include "base/message_loop.h"
24 #include "grit/ui_resources.h" 24 #include "grit/ui_resources.h"
25 #include "ui/aura/env.h" 25 #include "ui/aura/env.h"
26 #include "ui/aura/client/aura_constants.h"
26 #include "ui/aura/client/window_types.h" 27 #include "ui/aura/client/window_types.h"
27 #include "ui/aura/root_window.h" 28 #include "ui/aura/root_window.h"
28 #include "ui/aura/window_observer.h" 29 #include "ui/aura/window_observer.h"
29 #include "ui/base/resource/resource_bundle.h" 30 #include "ui/base/resource/resource_bundle.h"
30 #include "ui/base/ui_base_paths.h" 31 #include "ui/base/ui_base_paths.h"
31 #include "ui/gfx/canvas.h" 32 #include "ui/gfx/canvas.h"
32 #include "ui/gfx/compositor/test/compositor_test_support.h" 33 #include "ui/gfx/compositor/test/compositor_test_support.h"
33 #include "ui/views/test/test_views_delegate.h" 34 #include "ui/views/test/test_views_delegate.h"
34 #include "ui/views/widget/widget.h" 35 #include "ui/views/widget/widget.h"
35 #include "ui/views/widget/widget_delegate.h" 36 #include "ui/views/widget/widget_delegate.h"
(...skipping 17 matching lines...) Expand all
53 54
54 private: 55 private:
55 DISALLOW_COPY_AND_ASSIGN(ShellViewsDelegate); 56 DISALLOW_COPY_AND_ASSIGN(ShellViewsDelegate);
56 }; 57 };
57 58
58 // WindowWatcher is responsible for listening for newly created windows and 59 // WindowWatcher is responsible for listening for newly created windows and
59 // creating items on the Launcher for them. 60 // creating items on the Launcher for them.
60 class WindowWatcher : public aura::WindowObserver { 61 class WindowWatcher : public aura::WindowObserver {
61 public: 62 public:
62 WindowWatcher() 63 WindowWatcher()
63 : window_(ash::Shell::GetInstance()->launcher()->window_container()) { 64 : window_(ash::Shell::GetInstance()->launcher()->window_container()),
65 panel_container_(
66 ash::Shell::GetInstance()->GetContainer(
67 ash::internal::kShellWindowId_PanelContainer)) {
64 window_->AddObserver(this); 68 window_->AddObserver(this);
69 panel_container_->AddObserver(this);
65 } 70 }
66 71
67 virtual ~WindowWatcher() { 72 virtual ~WindowWatcher() {
68 window_->RemoveObserver(this); 73 window_->RemoveObserver(this);
74 panel_container_->AddObserver(this);
69 } 75 }
70 76
71 aura::Window* GetWindowByID(ash::LauncherID id) { 77 aura::Window* GetWindowByID(ash::LauncherID id) {
72 IDToWindow::const_iterator i = id_to_window_.find(id); 78 IDToWindow::const_iterator i = id_to_window_.find(id);
73 return i != id_to_window_.end() ? i->second : NULL; 79 return i != id_to_window_.end() ? i->second : NULL;
74 } 80 }
75 81
76 ash::LauncherID GetIDByWindow(aura::Window* window) const { 82 ash::LauncherID GetIDByWindow(aura::Window* window) const {
77 for (IDToWindow::const_iterator i = id_to_window_.begin(); 83 for (IDToWindow::const_iterator i = id_to_window_.begin();
78 i != id_to_window_.end(); ++i) { 84 i != id_to_window_.end(); ++i) {
79 if (i->second == window) 85 if (i->second == window)
80 return i->first; 86 return i->first;
81 } 87 }
82 return 0; // TODO: add a constant for this. 88 return 0; // TODO: add a constant for this.
83 } 89 }
84 90
85 // aura::WindowObserver overrides: 91 // aura::WindowObserver overrides:
86 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE { 92 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE {
87 if (new_window->type() != aura::client::WINDOW_TYPE_NORMAL) 93 //if ((new_window->type() != aura::client::WINDOW_TYPE_NORMAL)
sky 2012/03/23 21:41:14 Keep the old code.
88 return; 94 // || (new_window->type() != aura::client::WINDOW_TYPE_PANEL))
95 // return;
89 96
90 static int image_count = 0; 97 static int image_count = 0;
91 ash::LauncherModel* model = ash::Shell::GetInstance()->launcher()->model(); 98 ash::LauncherModel* model = ash::Shell::GetInstance()->launcher()->model();
92 ash::LauncherItem item; 99 ash::LauncherItem item;
100 ash::LauncherID id = model->next_id();
93 item.type = ash::TYPE_TABBED; 101 item.type = ash::TYPE_TABBED;
94 id_to_window_[model->next_id()] = new_window; 102 id_to_window_[id] = new_window;
95 item.num_tabs = image_count + 1; 103 item.num_tabs = image_count + 1;
96 item.image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); 104 item.image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
97 item.image.allocPixels(); 105 item.image.allocPixels();
98 item.image.eraseARGB(255, 106 item.image.eraseARGB(255,
99 image_count == 0 ? 255 : 0, 107 image_count == 0 ? 255 : 0,
100 image_count == 1 ? 255 : 0, 108 image_count == 1 ? 255 : 0,
101 image_count == 2 ? 255 : 0); 109 image_count == 2 ? 255 : 0);
102 image_count = (image_count + 1) % 3; 110 image_count = (image_count + 1) % 3;
103 model->Add(model->item_count(), item); 111 model->Add(model->item_count(), item);
112 new_window->SetProperty(aura::client::kLauncherIDKey, id);
sky 2012/03/23 21:41:14 What is this for?
104 } 113 }
105 114
106 virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE { 115 virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE {
107 for (IDToWindow::iterator i = id_to_window_.begin(); 116 for (IDToWindow::iterator i = id_to_window_.begin();
108 i != id_to_window_.end(); ++i) { 117 i != id_to_window_.end(); ++i) {
109 if (i->second == window) { 118 if (i->second == window) {
110 ash::LauncherModel* model = 119 ash::LauncherModel* model =
111 ash::Shell::GetInstance()->launcher()->model(); 120 ash::Shell::GetInstance()->launcher()->model();
112 int index = model->ItemIndexByID(i->first); 121 int index = model->ItemIndexByID(i->first);
113 DCHECK_NE(-1, index); 122 DCHECK_NE(-1, index);
114 model->RemoveItemAt(index); 123 model->RemoveItemAt(index);
115 id_to_window_.erase(i); 124 id_to_window_.erase(i);
116 break; 125 break;
117 } 126 }
118 } 127 }
119 } 128 }
120 129
121 private: 130 private:
122 typedef std::map<ash::LauncherID, aura::Window*> IDToWindow; 131 typedef std::map<ash::LauncherID, aura::Window*> IDToWindow;
123 132
124 // Window watching for newly created windows to be added to. 133 // Window watching for newly created windows to be added to.
125 aura::Window* window_; 134 aura::Window* window_;
126 135
136 aura::Window* panel_container_;
137
127 // Maps from window to the id we gave it. 138 // Maps from window to the id we gave it.
128 IDToWindow id_to_window_; 139 IDToWindow id_to_window_;
129 140
130 DISALLOW_COPY_AND_ASSIGN(WindowWatcher); 141 DISALLOW_COPY_AND_ASSIGN(WindowWatcher);
131 }; 142 };
132 143
133 class LauncherDelegateImpl : public ash::LauncherDelegate { 144 class LauncherDelegateImpl : public ash::LauncherDelegate {
134 public: 145 public:
135 explicit LauncherDelegateImpl(WindowWatcher* watcher) 146 explicit LauncherDelegateImpl(WindowWatcher* watcher)
136 : watcher_(watcher) { 147 : watcher_(watcher) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 window_watcher.reset(); 298 window_watcher.reset();
288 299
289 ash::Shell::DeleteInstance(); 300 ash::Shell::DeleteInstance();
290 301
291 aura::Env::DeleteInstance(); 302 aura::Env::DeleteInstance();
292 303
293 ui::CompositorTestSupport::Terminate(); 304 ui::CompositorTestSupport::Terminate();
294 305
295 return 0; 306 return 0;
296 } 307 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698