| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "ash/wm/root_window_layout_manager.h" | 49 #include "ash/wm/root_window_layout_manager.h" |
| 50 #include "ash/wm/stacking_controller.h" | 50 #include "ash/wm/stacking_controller.h" |
| 51 #include "ash/wm/status_area_layout_manager.h" | 51 #include "ash/wm/status_area_layout_manager.h" |
| 52 #include "ash/wm/system_background_controller.h" | 52 #include "ash/wm/system_background_controller.h" |
| 53 #include "ash/wm/system_modal_container_layout_manager.h" | 53 #include "ash/wm/system_modal_container_layout_manager.h" |
| 54 #include "ash/wm/window_properties.h" | 54 #include "ash/wm/window_properties.h" |
| 55 #include "ash/wm/window_state_aura.h" | 55 #include "ash/wm/window_state_aura.h" |
| 56 #include "ash/wm/window_util.h" | 56 #include "ash/wm/window_util.h" |
| 57 #include "ash/wm/workspace_controller.h" | 57 #include "ash/wm/workspace_controller.h" |
| 58 #include "base/command_line.h" | 58 #include "base/command_line.h" |
| 59 #include "base/macros.h" |
| 59 #include "base/memory/ptr_util.h" | 60 #include "base/memory/ptr_util.h" |
| 60 #include "base/time/time.h" | 61 #include "base/time/time.h" |
| 61 #include "ui/aura/client/aura_constants.h" | 62 #include "ui/aura/client/aura_constants.h" |
| 62 #include "ui/aura/client/screen_position_client.h" | 63 #include "ui/aura/client/screen_position_client.h" |
| 63 #include "ui/aura/window.h" | 64 #include "ui/aura/window.h" |
| 64 #include "ui/aura/window_delegate.h" | 65 #include "ui/aura/window_delegate.h" |
| 65 #include "ui/aura/window_event_dispatcher.h" | 66 #include "ui/aura/window_event_dispatcher.h" |
| 66 #include "ui/aura/window_observer.h" | 67 #include "ui/aura/window_observer.h" |
| 67 #include "ui/aura/window_tracker.h" | 68 #include "ui/aura/window_tracker.h" |
| 68 #include "ui/base/hit_test.h" | 69 #include "ui/base/hit_test.h" |
| 69 #include "ui/base/models/menu_model.h" | 70 #include "ui/base/models/menu_model.h" |
| 70 #include "ui/display/display.h" | 71 #include "ui/display/display.h" |
| 71 #include "ui/display/screen.h" | 72 #include "ui/display/screen.h" |
| 72 #include "ui/keyboard/keyboard_controller.h" | 73 #include "ui/keyboard/keyboard_controller.h" |
| 73 #include "ui/keyboard/keyboard_util.h" | 74 #include "ui/keyboard/keyboard_util.h" |
| 75 #include "ui/views/controls/menu/menu_model_adapter.h" |
| 74 #include "ui/views/controls/menu/menu_runner.h" | 76 #include "ui/views/controls/menu/menu_runner.h" |
| 75 #include "ui/views/view_model.h" | 77 #include "ui/views/view_model.h" |
| 76 #include "ui/views/view_model_utils.h" | 78 #include "ui/views/view_model_utils.h" |
| 77 #include "ui/wm/core/capture_controller.h" | 79 #include "ui/wm/core/capture_controller.h" |
| 78 #include "ui/wm/core/easy_resize_window_targeter.h" | 80 #include "ui/wm/core/easy_resize_window_targeter.h" |
| 79 #include "ui/wm/core/visibility_controller.h" | 81 #include "ui/wm/core/visibility_controller.h" |
| 80 #include "ui/wm/core/window_util.h" | 82 #include "ui/wm/core/window_util.h" |
| 81 #include "ui/wm/public/drag_drop_client.h" | 83 #include "ui/wm/public/drag_drop_client.h" |
| 82 #include "ui/wm/public/tooltip_client.h" | 84 #include "ui/wm/public/tooltip_client.h" |
| 83 #include "ui/wm/public/window_types.h" | 85 #include "ui/wm/public/window_types.h" |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 // We assume in throughout the code that this will not return NULL. If code | 584 // We assume in throughout the code that this will not return NULL. If code |
| 583 // triggers this for valid reasons, it should test status_area_widget first. | 585 // triggers this for valid reasons, it should test status_area_widget first. |
| 584 CHECK(shelf_->status_area_widget()); | 586 CHECK(shelf_->status_area_widget()); |
| 585 return shelf_->status_area_widget()->system_tray(); | 587 return shelf_->status_area_widget()->system_tray(); |
| 586 } | 588 } |
| 587 | 589 |
| 588 void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen, | 590 void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen, |
| 589 ui::MenuSourceType source_type) { | 591 ui::MenuSourceType source_type) { |
| 590 ShellDelegate* delegate = Shell::GetInstance()->delegate(); | 592 ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
| 591 DCHECK(delegate); | 593 DCHECK(delegate); |
| 592 std::unique_ptr<ui::MenuModel> menu_model( | 594 menu_model_.reset(delegate->CreateContextMenu(shelf_->shelf(), nullptr)); |
| 593 delegate->CreateContextMenu(shelf_->shelf(), nullptr)); | 595 if (!menu_model_) |
| 594 if (!menu_model) | |
| 595 return; | 596 return; |
| 596 | 597 |
| 598 menu_model_adapter_.reset(new views::MenuModelAdapter( |
| 599 menu_model_.get(), |
| 600 base::Bind(&RootWindowController::OnMenuClosed, base::Unretained(this)))); |
| 601 |
| 597 // Background controller may not be set yet if user clicked on status are | 602 // Background controller may not be set yet if user clicked on status are |
| 598 // before initial animation completion. See crbug.com/222218 | 603 // before initial animation completion. See crbug.com/222218 |
| 599 if (!wallpaper_controller_.get()) | 604 if (!wallpaper_controller_.get()) |
| 600 return; | 605 return; |
| 601 | 606 |
| 602 views::MenuRunner menu_runner(menu_model.get(), | 607 menu_runner_.reset(new views::MenuRunner( |
| 603 views::MenuRunner::CONTEXT_MENU); | 608 menu_model_adapter_->CreateMenu(), |
| 604 if (menu_runner.RunMenuAt(wallpaper_controller_->widget(), | 609 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC)); |
| 605 NULL, | 610 ignore_result( |
| 606 gfx::Rect(location_in_screen, gfx::Size()), | 611 menu_runner_->RunMenuAt(wallpaper_controller_->widget(), NULL, |
| 607 views::MENU_ANCHOR_TOPLEFT, | 612 gfx::Rect(location_in_screen, gfx::Size()), |
| 608 source_type) == views::MenuRunner::MENU_DELETED) { | 613 views::MENU_ANCHOR_TOPLEFT, source_type)); |
| 609 return; | |
| 610 } | |
| 611 | |
| 612 Shell::GetInstance()->UpdateShelfVisibility(); | |
| 613 } | 614 } |
| 614 | 615 |
| 615 void RootWindowController::UpdateShelfVisibility() { | 616 void RootWindowController::UpdateShelfVisibility() { |
| 616 shelf_->shelf_layout_manager()->UpdateVisibilityState(); | 617 shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
| 617 } | 618 } |
| 618 | 619 |
| 619 aura::Window* RootWindowController::GetWindowForFullscreenMode() { | 620 aura::Window* RootWindowController::GetWindowForFullscreenMode() { |
| 620 return wm::WmWindowAura::GetAuraWindow( | 621 return wm::WmWindowAura::GetAuraWindow( |
| 621 wm::GetWindowForFullscreenMode(wm::WmWindowAura::Get(GetRootWindow()))); | 622 wm::GetWindowForFullscreenMode(wm::WmWindowAura::Get(GetRootWindow()))); |
| 622 } | 623 } |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 return; | 1037 return; |
| 1037 set_touch_hud_projection(new TouchHudProjection(GetRootWindow())); | 1038 set_touch_hud_projection(new TouchHudProjection(GetRootWindow())); |
| 1038 } | 1039 } |
| 1039 | 1040 |
| 1040 void RootWindowController::DisableTouchHudProjection() { | 1041 void RootWindowController::DisableTouchHudProjection() { |
| 1041 if (!touch_hud_projection_) | 1042 if (!touch_hud_projection_) |
| 1042 return; | 1043 return; |
| 1043 touch_hud_projection_->Remove(); | 1044 touch_hud_projection_->Remove(); |
| 1044 } | 1045 } |
| 1045 | 1046 |
| 1047 void RootWindowController::OnMenuClosed() { |
| 1048 menu_runner_.reset(); |
| 1049 menu_model_adapter_.reset(); |
| 1050 menu_model_.reset(); |
| 1051 Shell::GetInstance()->UpdateShelfVisibility(); |
| 1052 } |
| 1053 |
| 1046 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { | 1054 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { |
| 1047 shelf_->shelf_layout_manager()->UpdateVisibilityState(); | 1055 shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
| 1048 } | 1056 } |
| 1049 | 1057 |
| 1050 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { | 1058 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { |
| 1051 if (enabled) | 1059 if (enabled) |
| 1052 EnableTouchHudProjection(); | 1060 EnableTouchHudProjection(); |
| 1053 else | 1061 else |
| 1054 DisableTouchHudProjection(); | 1062 DisableTouchHudProjection(); |
| 1055 } | 1063 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1068 aura::Window* primary_root_window = Shell::GetInstance() | 1076 aura::Window* primary_root_window = Shell::GetInstance() |
| 1069 ->window_tree_host_manager() | 1077 ->window_tree_host_manager() |
| 1070 ->GetPrimaryRootWindow(); | 1078 ->GetPrimaryRootWindow(); |
| 1071 return GetRootWindowSettings(primary_root_window)->controller; | 1079 return GetRootWindowSettings(primary_root_window)->controller; |
| 1072 } | 1080 } |
| 1073 | 1081 |
| 1074 return GetRootWindowSettings(root_window)->controller; | 1082 return GetRootWindowSettings(root_window)->controller; |
| 1075 } | 1083 } |
| 1076 | 1084 |
| 1077 } // namespace ash | 1085 } // namespace ash |
| OLD | NEW |