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

Side by Side Diff: ui/views/mus/native_widget_mus.h

Issue 2611773002: Removes code using mus client lib (Closed)
Patch Set: dont run on linux Created 3 years, 11 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
« no previous file with comments | « ui/views/mus/interactive_ui_tests_mus.cc ('k') | ui/views/mus/native_widget_mus.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 UI_VIEWS_MUS_NATIVE_WIDGET_MUS_H_
6 #define UI_VIEWS_MUS_NATIVE_WIDGET_MUS_H_
7
8 #include <stdint.h>
9
10 #include <map>
11 #include <memory>
12 #include <string>
13 #include <vector>
14
15 #include "base/callback.h"
16 #include "base/macros.h"
17 #include "base/memory/weak_ptr.h"
18 #include "services/ui/public/cpp/input_event_handler.h"
19 #include "services/ui/public/interfaces/window_tree.mojom.h"
20 #include "ui/aura/client/drag_drop_delegate.h"
21 #include "ui/aura/window_delegate.h"
22 #include "ui/aura/window_tree_host_observer.h"
23 #include "ui/platform_window/platform_window_delegate.h"
24 #include "ui/views/mus/mus_export.h"
25 #include "ui/views/mus/window_tree_host_mus.h"
26 #include "ui/views/widget/native_widget_private.h"
27
28 namespace aura {
29 namespace client {
30 class DragDropClient;
31 class ScreenPositionClient;
32 class WindowParentingClient;
33 }
34 class Window;
35 }
36
37 namespace ui {
38 class Window;
39 class WindowTreeClient;
40 namespace mojom {
41 enum class Cursor;
42 enum class EventResult;
43 }
44 }
45
46 namespace ui {
47 class Event;
48 }
49
50 namespace wm {
51 class CursorManager;
52 class FocusController;
53 }
54
55 namespace views {
56 namespace corewm {
57 class TooltipController;
58 }
59 class DropHelper;
60 class DropTargetMus;
61 class InputMethodMus;
62 class TooltipManagerAura;
63
64 // An implementation of NativeWidget that binds to a ui::Window. Because Aura
65 // is used extensively within Views code, this code uses aura and binds to the
66 // ui::Window via a Mus-specific aura::WindowTreeHost impl. Because the root
67 // aura::Window in a hierarchy is created without a delegate by the
68 // aura::WindowTreeHost, we must create a child aura::Window in this class
69 // (content_) and attach it to the root.
70 class VIEWS_MUS_EXPORT NativeWidgetMus
71 : public internal::NativeWidgetPrivate,
72 public aura::WindowDelegate,
73 public aura::WindowTreeHostObserver,
74 public aura::client::DragDropDelegate,
75 public NON_EXPORTED_BASE(ui::InputEventHandler) {
76 public:
77 NativeWidgetMus(
78 internal::NativeWidgetDelegate* delegate,
79 ui::Window* window,
80 ui::mojom::CompositorFrameSinkType compositor_frame_sink_type);
81 ~NativeWidgetMus() override;
82
83 // Configures the set of properties supplied to the window manager when
84 // creating a new Window for a Widget.
85 static void ConfigurePropertiesForNewWindow(
86 const Widget::InitParams& init_params,
87 std::map<std::string, std::vector<uint8_t>>* properties);
88
89 // Notifies all widgets the frame constants changed in some way.
90 static void NotifyFrameChanged(ui::WindowTreeClient* client);
91
92 // Returns the native widget for a ui::Window, or null if there is none.
93 static NativeWidgetMus* GetForWindow(ui::Window* window);
94
95 // Returns the widget for a ui::Window, or null if there is none.
96 static Widget* GetWidgetForWindow(ui::Window* window);
97
98 ui::mojom::CompositorFrameSinkType compositor_frame_sink_type() const {
99 return compositor_frame_sink_type_;
100 }
101 ui::Window* window() { return window_; }
102 aura::Window* aura_window() { return content_; }
103 WindowTreeHostMus* window_tree_host() { return window_tree_host_.get(); }
104
105 aura::Window* GetRootWindow();
106
107 void OnPlatformWindowClosed();
108 void OnActivationChanged(bool active);
109
110 protected:
111 // Updates the client area in the ui::Window.
112 virtual void UpdateClientArea();
113
114 // internal::NativeWidgetPrivate:
115 NonClientFrameView* CreateNonClientFrameView() override;
116 void InitNativeWidget(const Widget::InitParams& params) override;
117 void OnWidgetInitDone() override;
118 bool ShouldUseNativeFrame() const override;
119 bool ShouldWindowContentsBeTransparent() const override;
120 void FrameTypeChanged() override;
121 Widget* GetWidget() override;
122 const Widget* GetWidget() const override;
123 gfx::NativeView GetNativeView() const override;
124 gfx::NativeWindow GetNativeWindow() const override;
125 Widget* GetTopLevelWidget() override;
126 const ui::Compositor* GetCompositor() const override;
127 const ui::Layer* GetLayer() const override;
128 void ReorderNativeViews() override;
129 void ViewRemoved(View* view) override;
130 void SetNativeWindowProperty(const char* name, void* value) override;
131 void* GetNativeWindowProperty(const char* name) const override;
132 TooltipManager* GetTooltipManager() const override;
133 void SetCapture() override;
134 void ReleaseCapture() override;
135 bool HasCapture() const override;
136 ui::InputMethod* GetInputMethod() override;
137 void CenterWindow(const gfx::Size& size) override;
138 void GetWindowPlacement(gfx::Rect* bounds,
139 ui::WindowShowState* maximized) const override;
140 bool SetWindowTitle(const base::string16& title) override;
141 void SetWindowIcons(const gfx::ImageSkia& window_icon,
142 const gfx::ImageSkia& app_icon) override;
143 void InitModalType(ui::ModalType modal_type) override;
144 gfx::Rect GetWindowBoundsInScreen() const override;
145 gfx::Rect GetClientAreaBoundsInScreen() const override;
146 gfx::Rect GetRestoredBounds() const override;
147 std::string GetWorkspace() const override;
148 void SetBounds(const gfx::Rect& bounds_in_screen) override;
149 void SetSize(const gfx::Size& size) override;
150 void StackAbove(gfx::NativeView native_view) override;
151 void StackAtTop() override;
152 void SetShape(std::unique_ptr<SkRegion> shape) override;
153 void Close() override;
154 void CloseNow() override;
155 void Show() override;
156 void Hide() override;
157 void ShowMaximizedWithBounds(const gfx::Rect& restored_bounds) override;
158 void ShowWithWindowState(ui::WindowShowState state) override;
159 bool IsVisible() const override;
160 void Activate() override;
161 void Deactivate() override;
162 bool IsActive() const override;
163 void SetAlwaysOnTop(bool always_on_top) override;
164 bool IsAlwaysOnTop() const override;
165 void SetVisibleOnAllWorkspaces(bool always_visible) override;
166 bool IsVisibleOnAllWorkspaces() const override;
167 void Maximize() override;
168 void Minimize() override;
169 bool IsMaximized() const override;
170 bool IsMinimized() const override;
171 void Restore() override;
172 void SetFullscreen(bool fullscreen) override;
173 bool IsFullscreen() const override;
174 void SetOpacity(float opacity) override;
175 void FlashFrame(bool flash_frame) override;
176 void RunShellDrag(View* view,
177 const ui::OSExchangeData& data,
178 const gfx::Point& location,
179 int drag_operations,
180 ui::DragDropTypes::DragEventSource source) override;
181 void SchedulePaintInRect(const gfx::Rect& rect) override;
182 void SetCursor(gfx::NativeCursor cursor) override;
183 bool IsMouseEventsEnabled() const override;
184 void ClearNativeFocus() override;
185 gfx::Rect GetWorkAreaBoundsInScreen() const override;
186 Widget::MoveLoopResult RunMoveLoop(
187 const gfx::Vector2d& drag_offset,
188 Widget::MoveLoopSource source,
189 Widget::MoveLoopEscapeBehavior escape_behavior) override;
190 void EndMoveLoop() override;
191 void SetVisibilityChangedAnimationsEnabled(bool value) override;
192 void SetVisibilityAnimationDuration(const base::TimeDelta& duration) override;
193 void SetVisibilityAnimationTransition(
194 Widget::VisibilityTransition transition) override;
195 bool IsTranslucentWindowOpacitySupported() const override;
196 void OnSizeConstraintsChanged() override;
197 void RepostNativeEvent(gfx::NativeEvent native_event) override;
198 std::string GetName() const override;
199
200 // Overridden from aura::WindowDelegate:
201 gfx::Size GetMinimumSize() const override;
202 gfx::Size GetMaximumSize() const override;
203 void OnBoundsChanged(const gfx::Rect& old_bounds,
204 const gfx::Rect& new_bounds) override;
205 gfx::NativeCursor GetCursor(const gfx::Point& point) override;
206 int GetNonClientComponent(const gfx::Point& point) const override;
207 bool ShouldDescendIntoChildForEventHandling(
208 aura::Window* child,
209 const gfx::Point& location) override;
210 bool CanFocus() override;
211 void OnCaptureLost() override;
212 void OnPaint(const ui::PaintContext& context) override;
213 void OnDeviceScaleFactorChanged(float device_scale_factor) override;
214 void OnWindowDestroying(aura::Window* window) override;
215 void OnWindowDestroyed(aura::Window* window) override;
216 void OnWindowTargetVisibilityChanged(bool visible) override;
217 bool HasHitTestMask() const override;
218 void GetHitTestMask(gfx::Path* mask) const override;
219
220 // Overridden from ui::EventHandler:
221 void OnKeyEvent(ui::KeyEvent* event) override;
222 void OnMouseEvent(ui::MouseEvent* event) override;
223 void OnScrollEvent(ui::ScrollEvent* event) override;
224 void OnGestureEvent(ui::GestureEvent* event) override;
225
226 // Overridden from aura::WindowTreeHostObserver:
227 void OnHostResized(const aura::WindowTreeHost* host) override;
228 void OnHostMovedInPixels(const aura::WindowTreeHost* host,
229 const gfx::Point& new_origin_in_pixels) override;
230 void OnHostCloseRequested(const aura::WindowTreeHost* host) override;
231
232 // Overridden from aura::client::DragDropDelegate:
233 void OnDragEntered(const ui::DropTargetEvent& event) override;
234 int OnDragUpdated(const ui::DropTargetEvent& event) override;
235 void OnDragExited() override;
236 int OnPerformDrop(const ui::DropTargetEvent& event) override;
237
238 // Overridden from ui::InputEventHandler:
239 void OnWindowInputEvent(
240 ui::Window* view,
241 const ui::Event& event,
242 std::unique_ptr<base::Callback<void(ui::mojom::EventResult)>>*
243 ack_callback) override;
244
245 private:
246 friend class NativeWidgetMusTest;
247 class MusWindowObserver;
248 class MusCaptureClient;
249
250 ui::PlatformWindowDelegate* platform_window_delegate() {
251 return window_tree_host();
252 }
253
254 // Returns true if this NativeWidgetMus exists on the window manager side
255 // to provide the frame decorations.
256 bool is_parallel_widget_in_window_manager() {
257 return compositor_frame_sink_type_ ==
258 ui::mojom::CompositorFrameSinkType::UNDERLAY;
259 }
260
261 void set_last_cursor(ui::mojom::Cursor cursor) { last_cursor_ = cursor; }
262 void SetShowState(ui::mojom::ShowState show_state);
263
264 void OnMusWindowVisibilityChanging(ui::Window* window, bool visible);
265 void OnMusWindowVisibilityChanged(ui::Window* window, bool visible);
266
267 // Propagates the widget hit test mask, if any, to the ui::Window.
268 // TODO(jamescook): Wire this through views::Widget so widgets can push
269 // updates if needed.
270 void UpdateHitTestMask();
271
272 ui::Window* window_;
273 ui::mojom::Cursor last_cursor_;
274
275 internal::NativeWidgetDelegate* native_widget_delegate_;
276
277 const ui::mojom::CompositorFrameSinkType compositor_frame_sink_type_;
278 ui::mojom::ShowState show_state_before_fullscreen_;
279
280 // See class documentation for Widget in widget.h for a note about ownership.
281 Widget::InitParams::Ownership ownership_;
282
283 // Functions with the same name require the ui::WindowObserver to be in
284 // a separate class.
285 std::unique_ptr<MusWindowObserver> mus_window_observer_;
286
287 // Receives drop events for |window_|.
288 std::unique_ptr<DropTargetMus> drop_target_;
289
290 // Aura configuration.
291 std::unique_ptr<WindowTreeHostMus> window_tree_host_;
292 aura::Window* content_;
293 std::unique_ptr<wm::FocusController> focus_client_;
294 std::unique_ptr<MusCaptureClient> capture_client_;
295 std::unique_ptr<aura::client::DragDropClient> drag_drop_client_;
296 std::unique_ptr<aura::client::WindowParentingClient> window_parenting_client_;
297 std::unique_ptr<aura::client::ScreenPositionClient> screen_position_client_;
298 std::unique_ptr<wm::CursorManager> cursor_manager_;
299
300 std::unique_ptr<DropHelper> drop_helper_;
301 int last_drop_operation_;
302
303 std::unique_ptr<corewm::TooltipController> tooltip_controller_;
304 std::unique_ptr<TooltipManagerAura> tooltip_manager_;
305
306 std::unique_ptr<InputMethodMus> input_method_;
307
308 base::WeakPtrFactory<NativeWidgetMus> close_widget_factory_;
309
310 DISALLOW_COPY_AND_ASSIGN(NativeWidgetMus);
311 };
312
313 } // namespace views
314
315 #endif // UI_VIEWS_MUS_NATIVE_WIDGET_MUS_H_
OLDNEW
« no previous file with comments | « ui/views/mus/interactive_ui_tests_mus.cc ('k') | ui/views/mus/native_widget_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698