Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 #include "ash/wm/toplevel_window_event_handler.h" | 41 #include "ash/wm/toplevel_window_event_handler.h" |
| 42 #include "ash/wm/window_properties.h" | 42 #include "ash/wm/window_properties.h" |
| 43 #include "ash/wm/window_util.h" | 43 #include "ash/wm/window_util.h" |
| 44 #include "ash/wm/workspace_controller.h" | 44 #include "ash/wm/workspace_controller.h" |
| 45 #include "base/command_line.h" | 45 #include "base/command_line.h" |
| 46 #include "base/time/time.h" | 46 #include "base/time/time.h" |
| 47 #include "ui/aura/client/aura_constants.h" | 47 #include "ui/aura/client/aura_constants.h" |
| 48 #include "ui/aura/client/tooltip_client.h" | 48 #include "ui/aura/client/tooltip_client.h" |
| 49 #include "ui/aura/root_window.h" | 49 #include "ui/aura/root_window.h" |
| 50 #include "ui/aura/window.h" | 50 #include "ui/aura/window.h" |
| 51 #include "ui/aura/window_delegate.h" | |
| 51 #include "ui/aura/window_observer.h" | 52 #include "ui/aura/window_observer.h" |
| 53 #include "ui/base/hit_test.h" | |
| 52 #include "ui/base/models/menu_model.h" | 54 #include "ui/base/models/menu_model.h" |
| 53 #include "ui/gfx/screen.h" | 55 #include "ui/gfx/screen.h" |
| 54 #include "ui/keyboard/keyboard_controller.h" | 56 #include "ui/keyboard/keyboard_controller.h" |
| 55 #include "ui/keyboard/keyboard_util.h" | 57 #include "ui/keyboard/keyboard_util.h" |
| 56 #include "ui/views/controls/menu/menu_runner.h" | 58 #include "ui/views/controls/menu/menu_runner.h" |
| 57 #include "ui/views/corewm/visibility_controller.h" | 59 #include "ui/views/corewm/visibility_controller.h" |
| 58 #include "ui/views/view_model.h" | 60 #include "ui/views/view_model.h" |
| 59 #include "ui/views/view_model_utils.h" | 61 #include "ui/views/view_model_utils.h" |
| 60 | 62 |
| 61 namespace ash { | 63 namespace ash { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 void SetUsesScreenCoordinates(aura::Window* container) { | 159 void SetUsesScreenCoordinates(aura::Window* container) { |
| 158 container->SetProperty(internal::kUsesScreenCoordinatesKey, true); | 160 container->SetProperty(internal::kUsesScreenCoordinatesKey, true); |
| 159 } | 161 } |
| 160 | 162 |
| 161 // Mark the container window so that a widget added to this container will | 163 // Mark the container window so that a widget added to this container will |
| 162 // say in the same root window regardless of the bounds specified. | 164 // say in the same root window regardless of the bounds specified. |
| 163 void DescendantShouldStayInSameRootWindow(aura::Window* container) { | 165 void DescendantShouldStayInSameRootWindow(aura::Window* container) { |
| 164 container->SetProperty(internal::kStayInSameRootWindowKey, true); | 166 container->SetProperty(internal::kStayInSameRootWindowKey, true); |
| 165 } | 167 } |
| 166 | 168 |
| 169 class EmptyWindowDelegate : public aura::WindowDelegate { | |
|
Daniel Erat
2013/08/02 15:40:26
add a comment describing what this class is/does
| |
| 170 public: | |
| 171 EmptyWindowDelegate() {} | |
| 172 virtual ~EmptyWindowDelegate() {} | |
| 173 | |
| 174 // aura::WindowDelegate overrides: | |
| 175 virtual gfx::Size GetMinimumSize() const OVERRIDE { | |
| 176 return gfx::Size(); | |
| 177 } | |
| 178 virtual gfx::Size GetMaximumSize() const OVERRIDE { | |
| 179 return gfx::Size(); | |
| 180 } | |
| 181 virtual void OnBoundsChanged(const gfx::Rect& old_bounds, | |
| 182 const gfx::Rect& new_bounds) OVERRIDE { | |
| 183 } | |
| 184 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE { | |
| 185 return gfx::kNullCursor; | |
| 186 } | |
| 187 virtual int GetNonClientComponent( | |
| 188 const gfx::Point& point) const OVERRIDE { | |
| 189 return HTNOWHERE; | |
| 190 } | |
| 191 virtual bool ShouldDescendIntoChildForEventHandling( | |
| 192 aura::Window* child, | |
| 193 const gfx::Point& location) OVERRIDE { | |
| 194 return false; | |
| 195 } | |
| 196 virtual bool CanFocus() OVERRIDE { | |
| 197 return false; | |
| 198 } | |
| 199 virtual void OnCaptureLost() OVERRIDE { | |
| 200 } | |
| 201 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | |
| 202 } | |
| 203 virtual void OnDeviceScaleFactorChanged( | |
| 204 float device_scale_factor) OVERRIDE { | |
| 205 } | |
| 206 virtual void OnWindowDestroying() OVERRIDE {} | |
| 207 virtual void OnWindowDestroyed() OVERRIDE {} | |
| 208 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE { | |
| 209 } | |
| 210 virtual bool HasHitTestMask() const OVERRIDE { | |
| 211 return false; | |
| 212 } | |
| 213 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {} | |
| 214 virtual scoped_refptr<ui::Texture> CopyTexture() OVERRIDE { | |
| 215 NOTREACHED(); | |
| 216 return scoped_refptr<ui::Texture>(); | |
| 217 } | |
| 218 | |
| 219 private: | |
| 220 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate); | |
| 221 }; | |
| 222 | |
| 167 } // namespace | 223 } // namespace |
| 168 | 224 |
| 169 namespace internal { | 225 namespace internal { |
| 170 | 226 |
| 171 RootWindowController::RootWindowController(aura::RootWindow* root_window) | 227 RootWindowController::RootWindowController(aura::RootWindow* root_window) |
| 172 : root_window_(root_window), | 228 : root_window_(root_window), |
| 173 root_window_layout_(NULL), | 229 root_window_layout_(NULL), |
| 174 docked_layout_manager_(NULL), | 230 docked_layout_manager_(NULL), |
| 175 panel_layout_manager_(NULL), | 231 panel_layout_manager_(NULL), |
| 176 touch_hud_debug_(NULL), | 232 touch_hud_debug_(NULL), |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 // |desktop_widget_| should be the same animating widget we try to move | 388 // |desktop_widget_| should be the same animating widget we try to move |
| 333 // to |kDesktopController|. Otherwise, we may close |desktop_widget_| | 389 // to |kDesktopController|. Otherwise, we may close |desktop_widget_| |
| 334 // before move it to |kDesktopController|. | 390 // before move it to |kDesktopController|. |
| 335 DCHECK_EQ(controller->widget(), widget); | 391 DCHECK_EQ(controller->widget(), widget); |
| 336 // Release the old controller and close its background widget. | 392 // Release the old controller and close its background widget. |
| 337 SetWallpaperController(controller); | 393 SetWallpaperController(controller); |
| 338 } | 394 } |
| 339 } | 395 } |
| 340 | 396 |
| 341 void RootWindowController::CloseChildWindows() { | 397 void RootWindowController::CloseChildWindows() { |
| 398 mouse_event_target_.reset(); | |
| 399 | |
| 342 if (!shelf_.get()) | 400 if (!shelf_.get()) |
| 343 return; | 401 return; |
| 344 // panel_layout_manager_ needs to be shut down before windows are destroyed. | 402 // panel_layout_manager_ needs to be shut down before windows are destroyed. |
| 345 if (panel_layout_manager_) { | 403 if (panel_layout_manager_) { |
| 346 panel_layout_manager_->Shutdown(); | 404 panel_layout_manager_->Shutdown(); |
| 347 panel_layout_manager_ = NULL; | 405 panel_layout_manager_ = NULL; |
| 348 } | 406 } |
| 349 // docked_layout_manager_ needs to be shut down before windows are destroyed. | 407 // docked_layout_manager_ needs to be shut down before windows are destroyed. |
| 350 if (docked_layout_manager_) { | 408 if (docked_layout_manager_) { |
| 351 if (shelf_->shelf_layout_manager()) | 409 if (shelf_->shelf_layout_manager()) |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 | 534 |
| 477 DCHECK(!shelf_.get()); | 535 DCHECK(!shelf_.get()); |
| 478 aura::Window* shelf_container = | 536 aura::Window* shelf_container = |
| 479 GetContainer(internal::kShellWindowId_ShelfContainer); | 537 GetContainer(internal::kShellWindowId_ShelfContainer); |
| 480 // TODO(harrym): Remove when status area is view. | 538 // TODO(harrym): Remove when status area is view. |
| 481 aura::Window* status_container = | 539 aura::Window* status_container = |
| 482 GetContainer(internal::kShellWindowId_StatusContainer); | 540 GetContainer(internal::kShellWindowId_StatusContainer); |
| 483 shelf_.reset(new ShelfWidget( | 541 shelf_.reset(new ShelfWidget( |
| 484 shelf_container, status_container, workspace_controller())); | 542 shelf_container, status_container, workspace_controller())); |
| 485 | 543 |
| 544 // This window exists only to be a event target on login screen. | |
| 545 // It does not have to handle events, nor be visible. | |
| 546 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate)); | |
| 547 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN); | |
| 548 | |
| 549 aura::Window* lock_background_container = | |
| 550 GetContainer(internal::kShellWindowId_LockScreenBackgroundContainer); | |
| 551 lock_background_container->AddChild(mouse_event_target_.get()); | |
| 552 mouse_event_target_->Show(); | |
| 553 | |
| 486 // Create Docked windows layout manager | 554 // Create Docked windows layout manager |
| 487 aura::Window* docked_container = GetContainer( | 555 aura::Window* docked_container = GetContainer( |
| 488 internal::kShellWindowId_DockedContainer); | 556 internal::kShellWindowId_DockedContainer); |
| 489 docked_layout_manager_ = | 557 docked_layout_manager_ = |
| 490 new internal::DockedWindowLayoutManager(docked_container); | 558 new internal::DockedWindowLayoutManager(docked_container); |
| 491 docked_container_handler_.reset( | 559 docked_container_handler_.reset( |
| 492 new ToplevelWindowEventHandler(docked_container)); | 560 new ToplevelWindowEventHandler(docked_container)); |
| 493 docked_container->SetLayoutManager(docked_layout_manager_); | 561 docked_container->SetLayoutManager(docked_layout_manager_); |
| 494 | 562 |
| 495 // Create Panel layout manager | 563 // Create Panel layout manager |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 set_touch_hud_projection(new TouchHudProjection(root_window_.get())); | 771 set_touch_hud_projection(new TouchHudProjection(root_window_.get())); |
| 704 } | 772 } |
| 705 | 773 |
| 706 void RootWindowController::DisableTouchHudProjection() { | 774 void RootWindowController::DisableTouchHudProjection() { |
| 707 if (!touch_hud_projection_) | 775 if (!touch_hud_projection_) |
| 708 return; | 776 return; |
| 709 touch_hud_projection_->Remove(); | 777 touch_hud_projection_->Remove(); |
| 710 } | 778 } |
| 711 | 779 |
| 712 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { | 780 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { |
| 781 if (status != user::LOGGED_IN_NONE) | |
| 782 mouse_event_target_.reset(); | |
| 713 shelf_->shelf_layout_manager()->UpdateVisibilityState(); | 783 shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
| 714 } | 784 } |
| 715 | 785 |
| 716 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { | 786 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { |
| 717 if (enabled) | 787 if (enabled) |
| 718 EnableTouchHudProjection(); | 788 EnableTouchHudProjection(); |
| 719 else | 789 else |
| 720 DisableTouchHudProjection(); | 790 DisableTouchHudProjection(); |
| 721 } | 791 } |
| 722 | 792 |
| 723 } // namespace internal | 793 } // namespace internal |
| 724 } // namespace ash | 794 } // namespace ash |
| OLD | NEW |