| 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 #ifndef ASH_SHELL_H_ | 5 #ifndef ASH_SHELL_H_ |
| 6 #define ASH_SHELL_H_ | 6 #define ASH_SHELL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "ash/ash_export.h" | 12 #include "ash/ash_export.h" |
| 13 #include "ash/common/shelf/shelf_types.h" | 13 #include "ash/common/shelf/shelf_types.h" |
| 14 #include "ash/metrics/user_metrics_recorder.h" | 14 #include "ash/metrics/user_metrics_recorder.h" |
| 15 #include "ash/wm/cursor_manager_chromeos.h" | 15 #include "ash/wm/cursor_manager_chromeos.h" |
| 16 #include "ash/wm/system_modal_container_event_filter_delegate.h" | 16 #include "ash/wm/system_modal_container_event_filter_delegate.h" |
| 17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
| 21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 22 #include "ui/base/ui_base_types.h" | 22 #include "ui/base/ui_base_types.h" |
| 23 #include "ui/display/screen.h" | 23 #include "ui/display/screen.h" |
| 24 #include "ui/events/event_target.h" | 24 #include "ui/events/event_target.h" |
| 25 #include "ui/gfx/geometry/insets.h" | 25 #include "ui/gfx/geometry/insets.h" |
| 26 #include "ui/gfx/geometry/size.h" | 26 #include "ui/gfx/geometry/size.h" |
| 27 #include "ui/wm/core/cursor_manager.h" | 27 #include "ui/wm/core/cursor_manager.h" |
| 28 #include "ui/wm/public/activation_change_observer.h" | |
| 29 | 28 |
| 30 namespace aura { | 29 namespace aura { |
| 31 class EventFilter; | 30 class EventFilter; |
| 32 class RootWindow; | 31 class RootWindow; |
| 33 class Window; | 32 class Window; |
| 34 namespace client { | 33 namespace client { |
| 35 class ActivationClient; | 34 class ActivationClient; |
| 36 class FocusClient; | 35 class FocusClient; |
| 37 } | 36 } |
| 38 } | 37 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 class OverlayEventFilter; | 103 class OverlayEventFilter; |
| 105 class PartialMagnificationController; | 104 class PartialMagnificationController; |
| 106 class PointerWatcherDelegate; | 105 class PointerWatcherDelegate; |
| 107 class PowerButtonController; | 106 class PowerButtonController; |
| 108 class PowerEventObserver; | 107 class PowerEventObserver; |
| 109 class ProjectingObserver; | 108 class ProjectingObserver; |
| 110 class ResizeShadowController; | 109 class ResizeShadowController; |
| 111 class ResolutionNotificationController; | 110 class ResolutionNotificationController; |
| 112 class RootWindowController; | 111 class RootWindowController; |
| 113 class ScopedOverviewAnimationSettingsFactoryAura; | 112 class ScopedOverviewAnimationSettingsFactoryAura; |
| 114 class ScopedTargetRootWindow; | |
| 115 class ScreenAsh; | 113 class ScreenAsh; |
| 116 class ScreenOrientationController; | 114 class ScreenOrientationController; |
| 117 class ScreenshotController; | 115 class ScreenshotController; |
| 118 class ScreenPinningController; | 116 class ScreenPinningController; |
| 119 class ScreenPositionController; | 117 class ScreenPositionController; |
| 120 class SessionStateDelegate; | 118 class SessionStateDelegate; |
| 121 class Shelf; | 119 class Shelf; |
| 122 class ShelfWindowWatcher; | 120 class ShelfWindowWatcher; |
| 123 class ShellDelegate; | 121 class ShellDelegate; |
| 124 struct ShellInitParams; | 122 struct ShellInitParams; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 147 namespace test { | 145 namespace test { |
| 148 class ShellTestApi; | 146 class ShellTestApi; |
| 149 } | 147 } |
| 150 | 148 |
| 151 // Shell is a singleton object that presents the Shell API and implements the | 149 // Shell is a singleton object that presents the Shell API and implements the |
| 152 // RootWindow's delegate interface. | 150 // RootWindow's delegate interface. |
| 153 // | 151 // |
| 154 // Upon creation, the Shell sets itself as the RootWindow's delegate, which | 152 // Upon creation, the Shell sets itself as the RootWindow's delegate, which |
| 155 // takes ownership of the Shell. | 153 // takes ownership of the Shell. |
| 156 class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate, | 154 class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate, |
| 157 public ui::EventTarget, | 155 public ui::EventTarget { |
| 158 public aura::client::ActivationChangeObserver { | |
| 159 public: | 156 public: |
| 160 typedef std::vector<RootWindowController*> RootWindowControllerList; | 157 typedef std::vector<RootWindowController*> RootWindowControllerList; |
| 161 | 158 |
| 162 // A shell must be explicitly created so that it can call |Init()| with the | 159 // A shell must be explicitly created so that it can call |Init()| with the |
| 163 // delegate set. |delegate| can be NULL (if not required for initialization). | 160 // delegate set. |delegate| can be NULL (if not required for initialization). |
| 164 // Takes ownership of |delegate|. | 161 // Takes ownership of |delegate|. |
| 165 static Shell* CreateInstance(const ShellInitParams& init_params); | 162 static Shell* CreateInstance(const ShellInitParams& init_params); |
| 166 | 163 |
| 167 // Should never be called before |CreateInstance()|. | 164 // Should never be called before |CreateInstance()|. |
| 168 static Shell* GetInstance(); | 165 static Shell* GetInstance(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 179 // Returns all root window controllers. | 176 // Returns all root window controllers. |
| 180 // TODO(oshima): move this to |RootWindowController| | 177 // TODO(oshima): move this to |RootWindowController| |
| 181 static RootWindowControllerList GetAllRootWindowControllers(); | 178 static RootWindowControllerList GetAllRootWindowControllers(); |
| 182 | 179 |
| 183 // Returns the primary root Window. The primary root Window is the one that | 180 // Returns the primary root Window. The primary root Window is the one that |
| 184 // has a launcher. | 181 // has a launcher. |
| 185 static aura::Window* GetPrimaryRootWindow(); | 182 static aura::Window* GetPrimaryRootWindow(); |
| 186 | 183 |
| 187 // Returns a root Window when used as a target when creating a new window. | 184 // Returns a root Window when used as a target when creating a new window. |
| 188 // The root window of the active window is used in most cases, but can | 185 // The root window of the active window is used in most cases, but can |
| 189 // be overridden by using ScopedTargetRootWindow(). | 186 // be overridden by using ScopedRootWindowForNewWindows. |
| 190 // If you want to get the root Window of the active window, just use | 187 // If you want to get the root Window of the active window, just use |
| 191 // |wm::GetActiveWindow()->GetRootWindow()|. | 188 // |wm::GetActiveWindow()->GetRootWindow()|. |
| 192 static aura::Window* GetTargetRootWindow(); | 189 static aura::Window* GetTargetRootWindow(); |
| 193 | 190 |
| 194 // Returns the id of the display::Display corresponding to the window returned | 191 // Returns the id of the display::Display corresponding to the window returned |
| 195 // by |GetTargetRootWindow()| | 192 // by |GetTargetRootWindow()| |
| 196 static int64_t GetTargetDisplayId(); | 193 static int64_t GetTargetDisplayId(); |
| 197 | 194 |
| 198 // Returns all root windows. | 195 // Returns all root windows. |
| 199 static aura::Window::Windows GetAllRootWindows(); | 196 static aura::Window::Windows GetAllRootWindows(); |
| 200 | 197 |
| 201 static aura::Window* GetContainer(aura::Window* root_window, | 198 static aura::Window* GetContainer(aura::Window* root_window, |
| 202 int container_id); | 199 int container_id); |
| 203 static const aura::Window* GetContainer(const aura::Window* root_window, | 200 static const aura::Window* GetContainer(const aura::Window* root_window, |
| 204 int container_id); | 201 int container_id); |
| 205 | 202 |
| 206 // Returns the list of containers that match |container_id| in | 203 // Returns the list of containers that match |container_id| in |
| 207 // all root windows. If |priority_root| is given, the container | 204 // all root windows. If |priority_root| is given, the container |
| 208 // in the |priority_root| will be inserted at the top of the list. | 205 // in the |priority_root| will be inserted at the top of the list. |
| 209 static std::vector<aura::Window*> GetContainersFromAllRootWindows( | 206 static std::vector<aura::Window*> GetContainersFromAllRootWindows( |
| 210 int container_id, | 207 int container_id, |
| 211 aura::Window* priority_root); | 208 aura::Window* priority_root); |
| 212 | 209 |
| 213 void set_target_root_window(aura::Window* target_root_window) { | |
| 214 target_root_window_ = target_root_window; | |
| 215 } | |
| 216 | |
| 217 // Shows the context menu for the background and launcher at | 210 // Shows the context menu for the background and launcher at |
| 218 // |location_in_screen| (in screen coordinates). | 211 // |location_in_screen| (in screen coordinates). |
| 219 void ShowContextMenu(const gfx::Point& location_in_screen, | 212 void ShowContextMenu(const gfx::Point& location_in_screen, |
| 220 ui::MenuSourceType source_type); | 213 ui::MenuSourceType source_type); |
| 221 | 214 |
| 222 // Creates a default views::NonClientFrameView for use by windows in the | 215 // Creates a default views::NonClientFrameView for use by windows in the |
| 223 // Ash environment. | 216 // Ash environment. |
| 224 views::NonClientFrameView* CreateDefaultNonClientFrameView( | 217 views::NonClientFrameView* CreateDefaultNonClientFrameView( |
| 225 views::Widget* widget); | 218 views::Widget* widget); |
| 226 | 219 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 return screen_pinning_controller_.get(); | 466 return screen_pinning_controller_.get(); |
| 474 } | 467 } |
| 475 | 468 |
| 476 GPUSupport* gpu_support() { return gpu_support_.get(); } | 469 GPUSupport* gpu_support() { return gpu_support_.get(); } |
| 477 | 470 |
| 478 private: | 471 private: |
| 479 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor); | 472 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor); |
| 480 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors); | 473 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors); |
| 481 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate); | 474 FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate); |
| 482 friend class RootWindowController; | 475 friend class RootWindowController; |
| 483 friend class ScopedTargetRootWindow; | |
| 484 friend class test::ShellTestApi; | 476 friend class test::ShellTestApi; |
| 485 friend class shell::WindowWatcher; | 477 friend class shell::WindowWatcher; |
| 486 | 478 |
| 487 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair; | 479 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair; |
| 488 | 480 |
| 489 // Takes ownership of |delegate|. | 481 // Takes ownership of |delegate|. |
| 490 Shell(ShellDelegate* delegate, base::SequencedWorkerPool* blocking_pool); | 482 Shell(ShellDelegate* delegate, base::SequencedWorkerPool* blocking_pool); |
| 491 ~Shell() override; | 483 ~Shell() override; |
| 492 | 484 |
| 493 void Init(const ShellInitParams& init_params); | 485 void Init(const ShellInitParams& init_params); |
| 494 | 486 |
| 495 // Initializes virtual keyboard controller. | 487 // Initializes virtual keyboard controller. |
| 496 void InitKeyboard(); | 488 void InitKeyboard(); |
| 497 | 489 |
| 498 // Initializes the root window so that it can host browser windows. | 490 // Initializes the root window so that it can host browser windows. |
| 499 void InitRootWindow(aura::Window* root_window); | 491 void InitRootWindow(aura::Window* root_window); |
| 500 | 492 |
| 501 // Prepares the shelf to be deleted. | 493 // Prepares the shelf to be deleted. |
| 502 void ShutdownShelf(); | 494 void ShutdownShelf(); |
| 503 | 495 |
| 504 // SystemModalContainerEventFilterDelegate: | 496 // SystemModalContainerEventFilterDelegate: |
| 505 bool CanWindowReceiveEvents(aura::Window* window) override; | 497 bool CanWindowReceiveEvents(aura::Window* window) override; |
| 506 | 498 |
| 507 // Overridden from ui::EventTarget: | 499 // Overridden from ui::EventTarget: |
| 508 bool CanAcceptEvent(const ui::Event& event) override; | 500 bool CanAcceptEvent(const ui::Event& event) override; |
| 509 EventTarget* GetParentTarget() override; | 501 EventTarget* GetParentTarget() override; |
| 510 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; | 502 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; |
| 511 ui::EventTargeter* GetEventTargeter() override; | 503 ui::EventTargeter* GetEventTargeter() override; |
| 512 | 504 |
| 513 // Overridden from aura::client::ActivationChangeObserver: | |
| 514 void OnWindowActivated( | |
| 515 aura::client::ActivationChangeObserver::ActivationReason reason, | |
| 516 aura::Window* gained_active, | |
| 517 aura::Window* lost_active) override; | |
| 518 | |
| 519 static Shell* instance_; | 505 static Shell* instance_; |
| 520 | 506 |
| 521 // If set before the Shell is initialized, the mouse cursor will be hidden | 507 // If set before the Shell is initialized, the mouse cursor will be hidden |
| 522 // when the screen is initially created. | 508 // when the screen is initially created. |
| 523 static bool initially_hide_cursor_; | 509 static bool initially_hide_cursor_; |
| 524 | 510 |
| 525 std::unique_ptr<ScopedOverviewAnimationSettingsFactoryAura> | 511 std::unique_ptr<ScopedOverviewAnimationSettingsFactoryAura> |
| 526 scoped_overview_animation_settings_factory_; | 512 scoped_overview_animation_settings_factory_; |
| 527 std::unique_ptr<WmShellAura> wm_shell_; | 513 std::unique_ptr<WmShellAura> wm_shell_; |
| 528 | 514 |
| 529 // When no explicit target display/RootWindow is given, new windows are | |
| 530 // created on |scoped_target_root_window_| , unless NULL in | |
| 531 // which case they are created on |target_root_window_|. | |
| 532 // |target_root_window_| never becomes NULL during the session. | |
| 533 aura::Window* target_root_window_; | |
| 534 aura::Window* scoped_target_root_window_; | |
| 535 | |
| 536 // The CompoundEventFilter owned by aura::Env object. | 515 // The CompoundEventFilter owned by aura::Env object. |
| 537 std::unique_ptr<::wm::CompoundEventFilter> env_filter_; | 516 std::unique_ptr<::wm::CompoundEventFilter> env_filter_; |
| 538 | 517 |
| 539 std::vector<WindowAndBoundsPair> to_restore_; | 518 std::vector<WindowAndBoundsPair> to_restore_; |
| 540 | 519 |
| 541 std::unique_ptr<UserMetricsRecorder> user_metrics_recorder_; | 520 std::unique_ptr<UserMetricsRecorder> user_metrics_recorder_; |
| 542 std::unique_ptr<AcceleratorControllerDelegateAura> | 521 std::unique_ptr<AcceleratorControllerDelegateAura> |
| 543 accelerator_controller_delegate_; | 522 accelerator_controller_delegate_; |
| 544 std::unique_ptr<UserWallpaperDelegate> user_wallpaper_delegate_; | 523 std::unique_ptr<UserWallpaperDelegate> user_wallpaper_delegate_; |
| 545 std::unique_ptr<SessionStateDelegate> session_state_delegate_; | 524 std::unique_ptr<SessionStateDelegate> session_state_delegate_; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 base::SequencedWorkerPool* blocking_pool_; | 624 base::SequencedWorkerPool* blocking_pool_; |
| 646 | 625 |
| 647 bool in_mus_ = false; | 626 bool in_mus_ = false; |
| 648 | 627 |
| 649 DISALLOW_COPY_AND_ASSIGN(Shell); | 628 DISALLOW_COPY_AND_ASSIGN(Shell); |
| 650 }; | 629 }; |
| 651 | 630 |
| 652 } // namespace ash | 631 } // namespace ash |
| 653 | 632 |
| 654 #endif // ASH_SHELL_H_ | 633 #endif // ASH_SHELL_H_ |
| OLD | NEW |