| 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 <queue> | 7 #include <queue> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "ash/wm/root_window_layout_manager.h" | 48 #include "ash/wm/root_window_layout_manager.h" |
| 49 #include "ash/wm/stacking_controller.h" | 49 #include "ash/wm/stacking_controller.h" |
| 50 #include "ash/wm/status_area_layout_manager.h" | 50 #include "ash/wm/status_area_layout_manager.h" |
| 51 #include "ash/wm/system_background_controller.h" | 51 #include "ash/wm/system_background_controller.h" |
| 52 #include "ash/wm/system_modal_container_layout_manager.h" | 52 #include "ash/wm/system_modal_container_layout_manager.h" |
| 53 #include "ash/wm/window_properties.h" | 53 #include "ash/wm/window_properties.h" |
| 54 #include "ash/wm/window_state_aura.h" | 54 #include "ash/wm/window_state_aura.h" |
| 55 #include "ash/wm/window_util.h" | 55 #include "ash/wm/window_util.h" |
| 56 #include "ash/wm/workspace_controller.h" | 56 #include "ash/wm/workspace_controller.h" |
| 57 #include "base/command_line.h" | 57 #include "base/command_line.h" |
| 58 #include "base/macros.h" |
| 58 #include "base/memory/ptr_util.h" | 59 #include "base/memory/ptr_util.h" |
| 59 #include "base/time/time.h" | 60 #include "base/time/time.h" |
| 60 #include "ui/aura/client/aura_constants.h" | 61 #include "ui/aura/client/aura_constants.h" |
| 61 #include "ui/aura/client/screen_position_client.h" | 62 #include "ui/aura/client/screen_position_client.h" |
| 62 #include "ui/aura/window.h" | 63 #include "ui/aura/window.h" |
| 63 #include "ui/aura/window_delegate.h" | 64 #include "ui/aura/window_delegate.h" |
| 64 #include "ui/aura/window_event_dispatcher.h" | 65 #include "ui/aura/window_event_dispatcher.h" |
| 65 #include "ui/aura/window_observer.h" | 66 #include "ui/aura/window_observer.h" |
| 66 #include "ui/aura/window_tracker.h" | 67 #include "ui/aura/window_tracker.h" |
| 67 #include "ui/base/hit_test.h" | 68 #include "ui/base/hit_test.h" |
| 68 #include "ui/base/models/menu_model.h" | 69 #include "ui/base/models/menu_model.h" |
| 69 #include "ui/display/display.h" | 70 #include "ui/display/display.h" |
| 70 #include "ui/display/screen.h" | 71 #include "ui/display/screen.h" |
| 71 #include "ui/keyboard/keyboard_controller.h" | 72 #include "ui/keyboard/keyboard_controller.h" |
| 72 #include "ui/keyboard/keyboard_util.h" | 73 #include "ui/keyboard/keyboard_util.h" |
| 74 #include "ui/views/controls/menu/menu_model_adapter.h" |
| 73 #include "ui/views/controls/menu/menu_runner.h" | 75 #include "ui/views/controls/menu/menu_runner.h" |
| 74 #include "ui/views/view_model.h" | 76 #include "ui/views/view_model.h" |
| 75 #include "ui/views/view_model_utils.h" | 77 #include "ui/views/view_model_utils.h" |
| 76 #include "ui/wm/core/capture_controller.h" | 78 #include "ui/wm/core/capture_controller.h" |
| 77 #include "ui/wm/core/easy_resize_window_targeter.h" | 79 #include "ui/wm/core/easy_resize_window_targeter.h" |
| 78 #include "ui/wm/core/visibility_controller.h" | 80 #include "ui/wm/core/visibility_controller.h" |
| 79 #include "ui/wm/core/window_util.h" | 81 #include "ui/wm/core/window_util.h" |
| 80 #include "ui/wm/public/drag_drop_client.h" | 82 #include "ui/wm/public/drag_drop_client.h" |
| 81 #include "ui/wm/public/tooltip_client.h" | 83 #include "ui/wm/public/tooltip_client.h" |
| 82 #include "ui/wm/public/window_types.h" | 84 #include "ui/wm/public/window_types.h" |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 // We assume in throughout the code that this will not return NULL. If code | 591 // We assume in throughout the code that this will not return NULL. If code |
| 590 // triggers this for valid reasons, it should test status_area_widget first. | 592 // triggers this for valid reasons, it should test status_area_widget first. |
| 591 CHECK(shelf_->status_area_widget()); | 593 CHECK(shelf_->status_area_widget()); |
| 592 return shelf_->status_area_widget()->system_tray(); | 594 return shelf_->status_area_widget()->system_tray(); |
| 593 } | 595 } |
| 594 | 596 |
| 595 void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen, | 597 void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen, |
| 596 ui::MenuSourceType source_type) { | 598 ui::MenuSourceType source_type) { |
| 597 ShellDelegate* delegate = Shell::GetInstance()->delegate(); | 599 ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
| 598 DCHECK(delegate); | 600 DCHECK(delegate); |
| 599 std::unique_ptr<ui::MenuModel> menu_model( | 601 menu_model_.reset(delegate->CreateContextMenu(shelf_->shelf(), nullptr)); |
| 600 delegate->CreateContextMenu(shelf_->shelf(), nullptr)); | 602 if (!menu_model_) |
| 601 if (!menu_model) | |
| 602 return; | 603 return; |
| 603 | 604 |
| 605 menu_model_adapter_.reset(new views::MenuModelAdapter( |
| 606 menu_model_.get(), |
| 607 base::Bind(&RootWindowController::OnMenuClosed, base::Unretained(this)))); |
| 608 |
| 604 // Background controller may not be set yet if user clicked on status are | 609 // Background controller may not be set yet if user clicked on status are |
| 605 // before initial animation completion. See crbug.com/222218 | 610 // before initial animation completion. See crbug.com/222218 |
| 606 if (!wallpaper_controller_.get()) | 611 if (!wallpaper_controller_.get()) |
| 607 return; | 612 return; |
| 608 | 613 |
| 609 views::MenuRunner menu_runner(menu_model.get(), | 614 menu_runner_.reset(new views::MenuRunner( |
| 610 views::MenuRunner::CONTEXT_MENU); | 615 menu_model_adapter_->CreateMenu(), |
| 611 if (menu_runner.RunMenuAt(wallpaper_controller_->widget(), | 616 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC)); |
| 612 NULL, | 617 ignore_result( |
| 613 gfx::Rect(location_in_screen, gfx::Size()), | 618 menu_runner_->RunMenuAt(wallpaper_controller_->widget(), NULL, |
| 614 views::MENU_ANCHOR_TOPLEFT, | 619 gfx::Rect(location_in_screen, gfx::Size()), |
| 615 source_type) == views::MenuRunner::MENU_DELETED) { | 620 views::MENU_ANCHOR_TOPLEFT, source_type)); |
| 616 return; | |
| 617 } | |
| 618 | |
| 619 Shell::GetInstance()->UpdateShelfVisibility(); | |
| 620 } | 621 } |
| 621 | 622 |
| 622 void RootWindowController::UpdateShelfVisibility() { | 623 void RootWindowController::UpdateShelfVisibility() { |
| 623 shelf_->shelf_layout_manager()->UpdateVisibilityState(); | 624 shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
| 624 } | 625 } |
| 625 | 626 |
| 626 aura::Window* RootWindowController::GetWindowForFullscreenMode() { | 627 aura::Window* RootWindowController::GetWindowForFullscreenMode() { |
| 627 return wm::WmWindowAura::GetAuraWindow( | 628 return wm::WmWindowAura::GetAuraWindow( |
| 628 wm::GetWindowForFullscreenMode(wm::WmWindowAura::Get(GetRootWindow()))); | 629 wm::GetWindowForFullscreenMode(wm::WmWindowAura::Get(GetRootWindow()))); |
| 629 } | 630 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 | 685 |
| 685 //////////////////////////////////////////////////////////////////////////////// | 686 //////////////////////////////////////////////////////////////////////////////// |
| 686 // RootWindowController, private: | 687 // RootWindowController, private: |
| 687 | 688 |
| 688 RootWindowController::RootWindowController(AshWindowTreeHost* ash_host) | 689 RootWindowController::RootWindowController(AshWindowTreeHost* ash_host) |
| 689 : ash_host_(ash_host), | 690 : ash_host_(ash_host), |
| 690 root_window_layout_(NULL), | 691 root_window_layout_(NULL), |
| 691 docked_layout_manager_(NULL), | 692 docked_layout_manager_(NULL), |
| 692 panel_layout_manager_(NULL), | 693 panel_layout_manager_(NULL), |
| 693 touch_hud_debug_(NULL), | 694 touch_hud_debug_(NULL), |
| 694 touch_hud_projection_(NULL) { | 695 touch_hud_projection_(NULL), |
| 696 menu_model_(nullptr), |
| 697 menu_model_adapter_(nullptr), |
| 698 menu_runner_(nullptr) { |
| 695 aura::Window* root_window = GetRootWindow(); | 699 aura::Window* root_window = GetRootWindow(); |
| 696 GetRootWindowSettings(root_window)->controller = this; | 700 GetRootWindowSettings(root_window)->controller = this; |
| 697 | 701 |
| 698 stacking_controller_.reset(new StackingController); | 702 stacking_controller_.reset(new StackingController); |
| 699 aura::client::SetWindowTreeClient(root_window, stacking_controller_.get()); | 703 aura::client::SetWindowTreeClient(root_window, stacking_controller_.get()); |
| 700 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window)); | 704 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window)); |
| 701 } | 705 } |
| 702 | 706 |
| 703 void RootWindowController::Init(RootWindowType root_window_type, | 707 void RootWindowController::Init(RootWindowType root_window_type, |
| 704 bool first_run_after_boot) { | 708 bool first_run_after_boot) { |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 return; | 1047 return; |
| 1044 set_touch_hud_projection(new TouchHudProjection(GetRootWindow())); | 1048 set_touch_hud_projection(new TouchHudProjection(GetRootWindow())); |
| 1045 } | 1049 } |
| 1046 | 1050 |
| 1047 void RootWindowController::DisableTouchHudProjection() { | 1051 void RootWindowController::DisableTouchHudProjection() { |
| 1048 if (!touch_hud_projection_) | 1052 if (!touch_hud_projection_) |
| 1049 return; | 1053 return; |
| 1050 touch_hud_projection_->Remove(); | 1054 touch_hud_projection_->Remove(); |
| 1051 } | 1055 } |
| 1052 | 1056 |
| 1057 void RootWindowController::OnMenuClosed() { |
| 1058 menu_runner_.reset(); |
| 1059 menu_model_adapter_.reset(); |
| 1060 menu_model_.reset(); |
| 1061 Shell::GetInstance()->UpdateShelfVisibility(); |
| 1062 } |
| 1063 |
| 1053 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { | 1064 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { |
| 1054 shelf_->shelf_layout_manager()->UpdateVisibilityState(); | 1065 shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
| 1055 } | 1066 } |
| 1056 | 1067 |
| 1057 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { | 1068 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { |
| 1058 if (enabled) | 1069 if (enabled) |
| 1059 EnableTouchHudProjection(); | 1070 EnableTouchHudProjection(); |
| 1060 else | 1071 else |
| 1061 DisableTouchHudProjection(); | 1072 DisableTouchHudProjection(); |
| 1062 } | 1073 } |
| 1063 | 1074 |
| 1064 RootWindowController* GetRootWindowController( | 1075 RootWindowController* GetRootWindowController( |
| 1065 const aura::Window* root_window) { | 1076 const aura::Window* root_window) { |
| 1066 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; | 1077 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; |
| 1067 } | 1078 } |
| 1068 | 1079 |
| 1069 } // namespace ash | 1080 } // namespace ash |
| OLD | NEW |