Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: ash/wm_shell.h

Issue 2808723004: Renames WmShell to ShellPort (Closed)
Patch Set: feedback Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ASH_WM_SHELL_H_
6 #define ASH_WM_SHELL_H_
7
8 #include <stdint.h>
9
10 #include <memory>
11 #include <vector>
12
13 #include "ash/ash_export.h"
14 #include "ash/metrics/gesture_action_type.h"
15 #include "ash/metrics/user_metrics_action.h"
16 #include "ash/wm/lock_state_observer.h"
17 #include "base/observer_list.h"
18 #include "ui/base/ui_base_types.h"
19 #include "ui/compositor/layer_type.h"
20 #include "ui/wm/public/activation_change_observer.h"
21 #include "ui/wm/public/window_types.h"
22
23 namespace display {
24 class Display;
25 class ManagedDisplayInfo;
26 }
27
28 namespace gfx {
29 class Insets;
30 class Point;
31 }
32
33 namespace views {
34 class PointerWatcher;
35 enum class PointerWatcherEventTypes;
36 }
37
38 namespace ash {
39 class AcceleratorController;
40 class ImmersiveFullscreenController;
41 class KeyEventWatcher;
42 class KeyboardUI;
43 class RootWindowController;
44 class ScopedDisableInternalMouseAndKeyboard;
45 class SessionStateDelegate;
46 struct ShellInitParams;
47 class WindowCycleEventFilter;
48 class WindowResizer;
49 class WmDisplayObserver;
50 class WmWindow;
51 class WorkspaceEventHandler;
52
53 enum class Config;
54 enum class LoginStatus;
55 enum class TaskSwitchSource;
56
57 namespace wm {
58 class MaximizeModeEventHandler;
59 class WindowState;
60 }
61
62 // Similar to ash::Shell. Eventually the two will be merged.
63 class ASH_EXPORT WmShell {
64 public:
65 virtual ~WmShell();
66
67 static WmShell* Get();
68 static bool HasInstance() { return instance_ != nullptr; }
69
70 virtual void Shutdown();
71
72 // Returns true when ash is running as a service_manager::Service.
73 // TODO(sky): remove and convert to GetAshConfig().
74 virtual bool IsRunningInMash() const = 0;
75 virtual Config GetAshConfig() const = 0;
76
77 // Convenience for GetPrimaryRootWindow()->GetRootWindowController().
78 RootWindowController* GetPrimaryRootWindowController();
79
80 virtual WmWindow* GetPrimaryRootWindow() = 0;
81
82 // Returns the root window for the specified display.
83 virtual WmWindow* GetRootWindowForDisplayId(int64_t display_id) = 0;
84
85 // Retuns the display info associated with |display_id|.
86 // TODO(mash): Remove when DisplayManager has been moved. crbug.com/622480
87 virtual const display::ManagedDisplayInfo& GetDisplayInfo(
88 int64_t display_id) const = 0;
89
90 // Matches that of DisplayManager::IsActiveDisplayId().
91 // TODO(mash): Remove when DisplayManager has been moved. crbug.com/622480
92 virtual bool IsActiveDisplayId(int64_t display_id) const = 0;
93
94 // Returns true if the desktop is in unified mode and there are no mirroring
95 // displays.
96 // TODO(mash): Remove when DisplayManager has been moved. crbug.com/622480
97 virtual bool IsInUnifiedMode() const = 0;
98
99 // Returns true if the desktop is in unified mode.
100 // TODO(mash): Remove when DisplayManager has been moved. crbug.com/622480
101 virtual bool IsInUnifiedModeIgnoreMirroring() const = 0;
102
103 // Returns the first display; this is the first display listed by hardware,
104 // which corresponds to internal displays on devices with integrated displays.
105 // TODO(mash): Remove when DisplayManager has been moved. crbug.com/622480
106 virtual display::Display GetFirstDisplay() const = 0;
107
108 // Returns true if the first window shown on first run should be
109 // unconditionally maximized, overriding the heuristic that normally chooses
110 // the window size.
111 bool IsForceMaximizeOnFirstRun();
112
113 // Sets work area insets of the display containing |window|, pings observers.
114 virtual void SetDisplayWorkAreaInsets(WmWindow* window,
115 const gfx::Insets& insets) = 0;
116
117 // Returns true if a system-modal dialog window is currently open.
118 bool IsSystemModalWindowOpen();
119
120 // Creates a modal background (a partially-opaque fullscreen window) on all
121 // displays for |window|.
122 void CreateModalBackground(WmWindow* window);
123
124 // Called when a modal window is removed. It will activate another modal
125 // window if any, or remove modal screens on all displays.
126 void OnModalWindowRemoved(WmWindow* removed);
127
128 // For testing only: set simulation that a modal window is open
129 void SimulateModalWindowOpenForTesting(bool modal_window_open) {
130 simulate_modal_window_open_for_testing_ = modal_window_open;
131 }
132
133 // See aura::client::CursorClient for details on these.
134 virtual void LockCursor() = 0;
135 virtual void UnlockCursor() = 0;
136 virtual bool IsMouseEventsEnabled() = 0;
137
138 virtual std::vector<WmWindow*> GetAllRootWindows() = 0;
139
140 virtual void RecordGestureAction(GestureActionType action) = 0;
141 virtual void RecordUserMetricsAction(UserMetricsAction action) = 0;
142 virtual void RecordTaskSwitchMetric(TaskSwitchSource source) = 0;
143
144 // Shows the context menu for the wallpaper or shelf at |location_in_screen|.
145 void ShowContextMenu(const gfx::Point& location_in_screen,
146 ui::MenuSourceType source_type);
147
148 // Returns a WindowResizer to handle dragging. |next_window_resizer| is
149 // the next WindowResizer in the WindowResizer chain. This may return
150 // |next_window_resizer|.
151 virtual std::unique_ptr<WindowResizer> CreateDragWindowResizer(
152 std::unique_ptr<WindowResizer> next_window_resizer,
153 wm::WindowState* window_state) = 0;
154
155 virtual std::unique_ptr<WindowCycleEventFilter>
156 CreateWindowCycleEventFilter() = 0;
157
158 virtual std::unique_ptr<wm::MaximizeModeEventHandler>
159 CreateMaximizeModeEventHandler() = 0;
160
161 virtual std::unique_ptr<WorkspaceEventHandler> CreateWorkspaceEventHandler(
162 WmWindow* workspace_window) = 0;
163
164 virtual std::unique_ptr<ScopedDisableInternalMouseAndKeyboard>
165 CreateScopedDisableInternalMouseAndKeyboard() = 0;
166
167 virtual std::unique_ptr<ImmersiveFullscreenController>
168 CreateImmersiveFullscreenController() = 0;
169
170 // Creates the KeyboardUI. This is called early on.
171 virtual std::unique_ptr<KeyboardUI> CreateKeyboardUI() = 0;
172
173 virtual std::unique_ptr<KeyEventWatcher> CreateKeyEventWatcher() = 0;
174
175 virtual SessionStateDelegate* GetSessionStateDelegate() = 0;
176
177 virtual void AddDisplayObserver(WmDisplayObserver* observer) = 0;
178 virtual void RemoveDisplayObserver(WmDisplayObserver* observer) = 0;
179
180 // If |events| is PointerWatcherEventTypes::MOVES,
181 // PointerWatcher::OnPointerEventObserved() is called for pointer move events.
182 // If |events| is PointerWatcherEventTypes::DRAGS,
183 // PointerWatcher::OnPointerEventObserved() is called for pointer drag events.
184 // Requesting pointer moves or drags may incur a performance hit and should be
185 // avoided if possible.
186 virtual void AddPointerWatcher(views::PointerWatcher* watcher,
187 views::PointerWatcherEventTypes events) = 0;
188 virtual void RemovePointerWatcher(views::PointerWatcher* watcher) = 0;
189
190 // TODO: Move these back to LockStateController when that has been moved.
191 void OnLockStateEvent(LockStateObserver::EventType event);
192 void AddLockStateObserver(LockStateObserver* observer);
193 void RemoveLockStateObserver(LockStateObserver* observer);
194
195 // True if any touch points are down.
196 virtual bool IsTouchDown() = 0;
197
198 // TODO(jamescook): Remove this when VirtualKeyboardController has been moved.
199 virtual void ToggleIgnoreExternalKeyboard() = 0;
200
201 // Enable or disable the laser pointer.
202 virtual void SetLaserPointerEnabled(bool enabled) = 0;
203
204 // Enable or disable the partial magnifier.
205 virtual void SetPartialMagnifierEnabled(bool enabled) = 0;
206
207 virtual void CreatePointerWatcherAdapter() = 0;
208
209 protected:
210 WmShell();
211
212 // Called during startup to create the primary WindowTreeHost and
213 // the corresponding RootWindowController.
214 virtual void CreatePrimaryHost() = 0;
215 virtual void InitHosts(const ShellInitParams& init_params) = 0;
216
217 // Called during startup to create the AcceleratorController.
218 virtual std::unique_ptr<AcceleratorController>
219 CreateAcceleratorController() = 0;
220
221 private:
222 friend class AcceleratorControllerTest;
223 friend class Shell;
224
225 static WmShell* instance_;
226
227 base::ObserverList<LockStateObserver> lock_state_observers_;
228
229 bool simulate_modal_window_open_for_testing_ = false;
230 };
231
232 } // namespace ash
233
234 #endif // ASH_WM_SHELL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698