#ifndef ASH_ROOT_WINDOW_CONTROLLER_H_
#define ASH_ROOT_WINDOW_CONTROLLER_H_
#include <map>
#include <memory>
#include <vector>
#include "ash/ash_export.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/style/ash_color_provider_source.h"
#include "ash/wm/workspace/workspace_types.h"
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
namespace aura {
class Window;
}
namespace gfx {
class Point;
}
namespace ui {
class WindowTreeHost;
class SimpleMenuModel;
}
namespace views {
class MenuRunner;
class Widget;
}
namespace wm {
class ScopedCaptureClient;
}
namespace ash {
class AccessibilityPanelLayoutManager;
class AlwaysOnTopController;
class AppMenuModelAdapter;
class AshWindowTreeHost;
class LockScreenActionBackgroundController;
enum class LoginStatus;
class RootWindowLayoutManager;
class Shelf;
class ShelfLayoutManager;
class SplitViewController;
class StackingController;
class StatusAreaWidget;
class SystemModalContainerLayoutManager;
class SystemWallpaperController;
class TouchExplorationManager;
class TouchHudDebug;
class TouchHudProjection;
class WallpaperWidgetController;
class WorkAreaInsets;
namespace curtain {
class SecurityCurtainWidgetController;
}
class ASH_EXPORT RootWindowController {
public:
enum class RootWindowType { PRIMARY, SECONDARY };
RootWindowController(const RootWindowController&) = delete;
RootWindowController& operator=(const RootWindowController&) = delete;
~RootWindowController();
static RootWindowController* CreateForPrimaryDisplay(AshWindowTreeHost* host);
static RootWindowController* CreateForSecondaryDisplay(
AshWindowTreeHost* host);
static RootWindowController* ForWindow(const aura::Window* window);
static RootWindowController* ForTargetRootWindow();
static std::vector<RootWindowController*> root_window_controllers() {
return root_window_controllers_ ? *root_window_controllers_
: std::vector<RootWindowController*>();
}
AshWindowTreeHost* ash_host() { return ash_host_.get(); }
const AshWindowTreeHost* ash_host() const { return ash_host_.get(); }
aura::WindowTreeHost* GetHost();
const aura::WindowTreeHost* GetHost() const;
aura::Window* GetRootWindow();
const aura::Window* GetRootWindow() const;
SplitViewController* split_view_controller() const {
return split_view_controller_.get();
}
Shelf* shelf() const { return shelf_.get(); }
TouchHudDebug* touch_hud_debug() const { return touch_hud_debug_; }
TouchHudProjection* touch_hud_projection() const {
return touch_hud_projection_;
}
void set_touch_hud_debug(TouchHudDebug* hud) { touch_hud_debug_ = hud; }
void set_touch_hud_projection(TouchHudProjection* hud) {
touch_hud_projection_ = hud;
}
RootWindowLayoutManager* root_window_layout_manager() {
return root_window_layout_manager_;
}
WorkAreaInsets* work_area_insets() { return work_area_insets_.get(); }
ShelfLayoutManager* GetShelfLayoutManager();
SystemModalContainerLayoutManager* GetSystemModalLayoutManager(
aura::Window* window);
AlwaysOnTopController* always_on_top_controller() {
return always_on_top_controller_.get();
}
StatusAreaWidget* GetStatusAreaWidget();
bool IsSystemTrayVisible();
bool CanWindowReceiveEvents(aura::Window* window);
aura::Window* FindEventTarget(const gfx::Point& location_in_screen);
gfx::Point GetLastMouseLocationInRoot();
aura::Window* GetContainer(int container_id);
const aura::Window* GetContainer(int container_id) const;
WallpaperWidgetController* wallpaper_widget_controller() {
return wallpaper_widget_controller_.get();
}
LockScreenActionBackgroundController*
lock_screen_action_background_controller() {
return lock_screen_action_background_controller_.get();
}
AshColorProviderSource* color_provider_source() {
return color_provider_source_.get();
}
void Shutdown();
void CloseChildWindows();
void MoveWindowsTo(aura::Window* dest);
void InitTouchHuds();
aura::Window* GetWindowForFullscreenMode();
bool IsInFullscreenMode();
void SetTouchAccessibilityAnchorPoint(const gfx::Point& anchor_point);
void ShowContextMenu(const gfx::Point& location_in_screen,
ui::MenuSourceType source_type);
void HideContextMenu();
void HideContextMenuNoAnimation();
bool IsContextMenuShown() const;
void UpdateAfterLoginStatusChange(LoginStatus status);
void CreateAmbientWidget();
void CloseAmbientWidget(bool immediately);
bool HasAmbientWidget() const;
views::Widget* ambient_widget_for_testing() { return ambient_widget_.get(); }
AppMenuModelAdapter* menu_model_adapter_for_testing() {
return root_window_menu_model_adapter_.get();
}
AccessibilityPanelLayoutManager* GetAccessibilityPanelLayoutManagerForTest();
void SetSecurityCurtainWidgetController(
std::unique_ptr<curtain::SecurityCurtainWidgetController> controller);
void ClearSecurityCurtainWidgetController();
curtain::SecurityCurtainWidgetController*
security_curtain_widget_controller();
private:
FRIEND_TEST_ALL_PREFIXES(RootWindowControllerTest,
ContextMenuDisappearsInTabletMode);
explicit RootWindowController(AshWindowTreeHost* ash_host);
void Init(RootWindowType root_window_type);
void InitLayoutManagers(
std::unique_ptr<RootWindowLayoutManager> root_window_layout_manager);
AccessibilityPanelLayoutManager* GetAccessibilityPanelLayoutManager() const;
void CreateContainers();
aura::Window* CreateContainer(int window_id,
const char* name,
aura::Window* parent);
void CreateSystemWallpaper(RootWindowType root_window_type);
void OnMenuClosed();
void OnFirstWallpaperWidgetSet();
std::unique_ptr<AshWindowTreeHost> ash_host_;
raw_ptr<aura::WindowTreeHost, DanglingUntriaged | ExperimentalAsh>
window_tree_host_;
raw_ptr<RootWindowLayoutManager, DanglingUntriaged | ExperimentalAsh>
root_window_layout_manager_ = nullptr;
std::unique_ptr<WallpaperWidgetController> wallpaper_widget_controller_;
std::unique_ptr<AlwaysOnTopController> always_on_top_controller_;
std::unique_ptr<AppMenuModelAdapter> root_window_menu_model_adapter_;
std::unique_ptr<ui::SimpleMenuModel> sort_apps_submenu_;
std::unique_ptr<StackingController> stacking_controller_;
std::unique_ptr<SplitViewController> split_view_controller_;
std::unique_ptr<Shelf> shelf_;
std::unique_ptr<SystemWallpaperController> system_wallpaper_;
std::unique_ptr<TouchExplorationManager> touch_exploration_manager_;
raw_ptr<TouchHudDebug, ExperimentalAsh> touch_hud_debug_ = nullptr;
raw_ptr<TouchHudProjection, ExperimentalAsh> touch_hud_projection_ = nullptr;
std::unique_ptr<::wm::ScopedCaptureClient> capture_client_;
std::unique_ptr<LockScreenActionBackgroundController>
lock_screen_action_background_controller_;
std::unique_ptr<views::Widget> ambient_widget_;
std::unique_ptr<curtain::SecurityCurtainWidgetController>
security_curtain_widget_controller_;
std::unique_ptr<AshColorProviderSource> color_provider_source_;
bool did_close_child_windows_ = false;
std::unique_ptr<WorkAreaInsets> work_area_insets_;
static std::vector<RootWindowController*>* root_window_controllers_;
};
}
#endif