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

Side by Side Diff: mojo/views/native_widget_mojo.h

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 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 | « mojo/views/input_method_mojo_linux.cc ('k') | mojo/views/native_widget_mojo.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 (c) 2012 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_WIDGET_NATIVE_WIDGET_MOJO_H_
6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_MOJO_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "mojo/services/view_manager/public/cpp/view_observer.h"
10 #include "ui/base/cursor/cursor.h"
11 #include "ui/compositor/layer_delegate.h"
12 #include "ui/compositor/layer_owner.h"
13 #include "ui/views/widget/native_widget_private.h"
14
15 namespace views {
16 class DropHelper;
17 class InputMethod;
18 class TooltipManager;
19 class NonClientFrameView;
20 class Widget;
21 namespace internal {
22 class InputMethodDelegate;
23 class NativeWidgetDelegate;
24 }
25 }
26
27 namespace ui {
28 class InputMethod;
29 }
30
31 namespace mojo {
32 class Shell;
33 class SurfaceContextFactory;
34 class View;
35
36 // A NativeWidget which interacts with a mojo::View.
37 class NativeWidgetMojo
38 : public views::internal::NativeWidgetPrivate,
39 public ui::EventHandler,
40 public ViewObserver,
41 public ui::LayerOwner,
42 public ui::LayerDelegate {
43 public:
44 NativeWidgetMojo(views::internal::NativeWidgetDelegate* delegate,
45 mojo::Shell* shell,
46 mojo::View* view);
47
48 // Overridden from internal::NativeWidgetPrivate:
49 virtual void InitNativeWidget(
50 const views::Widget::InitParams& params) override;
51 virtual views::NonClientFrameView* CreateNonClientFrameView() override;
52 virtual bool ShouldUseNativeFrame() const override;
53 virtual bool ShouldWindowContentsBeTransparent() const override;
54 virtual void FrameTypeChanged() override;
55 virtual views::Widget* GetWidget() override;
56 virtual const views::Widget* GetWidget() const override;
57 virtual gfx::NativeView GetNativeView() const override;
58 virtual gfx::NativeWindow GetNativeWindow() const override;
59 virtual views::Widget* GetTopLevelWidget() override;
60 virtual const ui::Compositor* GetCompositor() const override;
61 virtual ui::Compositor* GetCompositor() override;
62 virtual ui::Layer* GetLayer() override;
63 virtual void ReorderNativeViews() override;
64 virtual void ViewRemoved(views::View* view) override;
65 virtual void SetNativeWindowProperty(const char* name, void* value) override;
66 virtual void* GetNativeWindowProperty(const char* name) const override;
67 virtual views::TooltipManager* GetTooltipManager() const override;
68 virtual void SetCapture() override;
69 virtual void ReleaseCapture() override;
70 virtual bool HasCapture() const override;
71 virtual views::InputMethod* CreateInputMethod() override;
72 virtual views::internal::InputMethodDelegate* GetInputMethodDelegate()
73 override;
74 virtual ui::InputMethod* GetHostInputMethod() override;
75 virtual void CenterWindow(const gfx::Size& size) override;
76 virtual void GetWindowPlacement(
77 gfx::Rect* bounds,
78 ui::WindowShowState* maximized) const override;
79 virtual bool SetWindowTitle(const base::string16& title) override;
80 virtual void SetWindowIcons(const gfx::ImageSkia& window_icon,
81 const gfx::ImageSkia& app_icon) override;
82 virtual void InitModalType(ui::ModalType modal_type) override;
83 virtual gfx::Rect GetWindowBoundsInScreen() const override;
84 virtual gfx::Rect GetClientAreaBoundsInScreen() const override;
85 virtual gfx::Rect GetRestoredBounds() const override;
86 virtual void SetBounds(const gfx::Rect& bounds) override;
87 virtual void SetSize(const gfx::Size& size) override;
88 virtual void StackAbove(gfx::NativeView native_view) override;
89 virtual void StackAtTop() override;
90 virtual void StackBelow(gfx::NativeView native_view) override;
91 virtual void SetShape(gfx::NativeRegion shape) override;
92 virtual void Close() override;
93 virtual void CloseNow() override;
94 virtual void Show() override;
95 virtual void Hide() override;
96 virtual void ShowMaximizedWithBounds(
97 const gfx::Rect& restored_bounds) override;
98 virtual void ShowWithWindowState(ui::WindowShowState state) override;
99 virtual bool IsVisible() const override;
100 virtual void Activate() override;
101 virtual void Deactivate() override;
102 virtual bool IsActive() const override;
103 virtual void SetAlwaysOnTop(bool always_on_top) override;
104 virtual bool IsAlwaysOnTop() const override;
105 virtual void SetVisibleOnAllWorkspaces(bool always_visible) override;
106 virtual void Maximize() override;
107 virtual void Minimize() override;
108 virtual bool IsMaximized() const override;
109 virtual bool IsMinimized() const override;
110 virtual void Restore() override;
111 virtual void SetFullscreen(bool fullscreen) override;
112 virtual bool IsFullscreen() const override;
113 virtual void SetOpacity(unsigned char opacity) override;
114 virtual void SetUseDragFrame(bool use_drag_frame) override;
115 virtual void FlashFrame(bool flash_frame) override;
116 virtual void RunShellDrag(views::View* view,
117 const ui::OSExchangeData& data,
118 const gfx::Point& location,
119 int operation,
120 ui::DragDropTypes::DragEventSource source) override;
121 virtual void SchedulePaintInRect(const gfx::Rect& rect) override;
122 virtual void SetCursor(gfx::NativeCursor cursor) override;
123 virtual bool IsMouseEventsEnabled() const override;
124 virtual void ClearNativeFocus() override;
125 virtual gfx::Rect GetWorkAreaBoundsInScreen() const override;
126 virtual views::Widget::MoveLoopResult RunMoveLoop(
127 const gfx::Vector2d& drag_offset,
128 views::Widget::MoveLoopSource source,
129 views::Widget::MoveLoopEscapeBehavior escape_behavior) override;
130 virtual void EndMoveLoop() override;
131 virtual void SetVisibilityChangedAnimationsEnabled(bool value) override;
132 virtual ui::NativeTheme* GetNativeTheme() const override;
133 virtual void OnRootViewLayout() override;
134 virtual bool IsTranslucentWindowOpacitySupported() const override;
135 virtual void OnSizeConstraintsChanged() override;
136 virtual void RepostNativeEvent(gfx::NativeEvent native_event) override;
137
138 // Overridden from ui::EventHandler:
139 void OnKeyEvent(ui::KeyEvent* event) override;
140 void OnMouseEvent(ui::MouseEvent* event) override;
141 void OnScrollEvent(ui::ScrollEvent* event) override;
142 void OnGestureEvent(ui::GestureEvent* event) override;
143
144 // TODO(erg): Plumb activation events from the window manager to here. We
145 // should receive the equivalent of OnWindowActivated() and OnWindowFocused()
146 // here.
147
148 // TODO(erg): Handle drag/drop. Maybe an equivalent of
149 // aura::client::DragDropDelegate? Or a different design?
150
151 // Overridden from ViewObserver:
152 void OnViewDestroying(View* view) override;
153 void OnViewDestroyed(View* view) override;
154 void OnViewBoundsChanged(View* view,
155 const Rect& old_bounds,
156 const Rect& new_bounds) override;
157 void OnViewFocusChanged(View* gained_focus, View* lost_focus) override;
158 void OnViewInputEvent(View* view, const EventPtr& event) override;
159
160 // Overridden from LayerDelegate:
161 void OnPaintLayer(gfx::Canvas* canvas) override;
162 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override;
163 void OnDeviceScaleFactorChanged(float device_scale_factor) override;
164 base::Closure PrepareForLayerBoundsChange() override;
165
166 protected:
167 virtual ~NativeWidgetMojo();
168
169 views::internal::NativeWidgetDelegate* delegate() { return delegate_; }
170
171 private:
172 class ActiveWindowObserver;
173
174 void SetInitialFocus(ui::WindowShowState show_state);
175
176 views::internal::NativeWidgetDelegate* delegate_;
177
178 // See class documentation for Widget in widget.h for a note about ownership.
179 views::Widget::InitParams::Ownership ownership_;
180
181 mojo::View* view_;
182
183 // Are we in the destructor?
184 bool destroying_;
185
186 scoped_ptr<SurfaceContextFactory> context_factory_;
187 scoped_ptr<ui::Compositor> compositor_;
188
189 // The following factory is used for calls to close the NativeWidgetMojo
190 // instance.
191 base::WeakPtrFactory<NativeWidgetMojo> close_widget_factory_;
192
193 DISALLOW_COPY_AND_ASSIGN(NativeWidgetMojo);
194 };
195
196 } // namespace mojo
197
198 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_MOJO_H_
OLDNEW
« no previous file with comments | « mojo/views/input_method_mojo_linux.cc ('k') | mojo/views/native_widget_mojo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698