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

Side by Side Diff: views/widget/native_widget_wayland.h

Issue 7464027: Wayland support for views. views_desktop on Wayland. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updated files to latest and fixed changes for dependent CLs Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 VIEWS_WIDGET_NATIVE_WIDGET_WAYLAND_H_
6 #define VIEWS_WIDGET_NATIVE_WIDGET_WAYLAND_H_
7 #pragma once
8
9 #include <wayland-client.h>
10
11 #include "base/memory/scoped_vector.h"
12 #include "ui/gfx/gl/gl_context.h"
13 #include "ui/gfx/gl/gl_surface.h"
14 #include "ui/gfx/size.h"
15 #include "ui/wayland/wayland_widget.h"
16 #include "views/ime/input_method_delegate.h"
17 #include "views/widget/native_widget_private.h"
18 #include "views/widget/widget.h"
19
20 typedef struct _cairo_device cairo_device_t;
21 typedef struct _cairo_surface cairo_surface_t;
22
23 namespace gfx {
24 class Rect;
25 }
26
27 namespace ui {
28 class ViewProp;
29 class WaylandDisplay;
30 class WaylandInputDevice;
31 class WaylandWindow;
32 }
33
34 namespace views {
35
36 namespace internal {
37 class NativeWidgetDelegate;
38 }
39
40 // Widget implementation for Wayland
41 class NativeWidgetWayland : public internal::NativeWidgetPrivate,
42 public ui::WaylandWidget,
43 public internal::InputMethodDelegate {
44 public:
45 explicit NativeWidgetWayland(internal::NativeWidgetDelegate* delegate);
46 virtual ~NativeWidgetWayland();
47
48 // Overridden from NativeWidget:
49 virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
50 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE;
51 virtual void UpdateFrameAfterFrameChange() OVERRIDE;
52 virtual bool ShouldUseNativeFrame() const OVERRIDE;
53 virtual void FrameTypeChanged() OVERRIDE;
54 virtual Widget* GetWidget() OVERRIDE;
55 virtual const Widget* GetWidget() const OVERRIDE;
56 virtual gfx::NativeView GetNativeView() const OVERRIDE;
57 virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
58 virtual Widget* GetTopLevelWidget() OVERRIDE;
59 virtual const ui::Compositor* GetCompositor() const OVERRIDE;
60 virtual ui::Compositor* GetCompositor() OVERRIDE;
61 virtual void MarkLayerDirty() OVERRIDE;
62 virtual void CalculateOffsetToAncestorWithLayer(gfx::Point* offset,
63 View** ancestor) OVERRIDE;
64 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE;
65 virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE;
66 virtual void ViewRemoved(View* view) OVERRIDE;
67 virtual TooltipManager* GetTooltipManager() const OVERRIDE;
68 virtual bool IsScreenReaderActive() const OVERRIDE;
69 virtual void SendNativeAccessibilityEvent(
70 View* view,
71 ui::AccessibilityTypes::Event event_type) OVERRIDE;
72 virtual void SetMouseCapture() OVERRIDE;
73 virtual void ReleaseMouseCapture() OVERRIDE;
74 virtual bool HasMouseCapture() const OVERRIDE;
75 virtual void SetKeyboardCapture() OVERRIDE;
76 virtual void ReleaseKeyboardCapture() OVERRIDE;
77 virtual bool HasKeyboardCapture() const OVERRIDE;
78 virtual InputMethod* GetInputMethodNative() OVERRIDE;
79 virtual void ReplaceInputMethod(InputMethod* input_method) OVERRIDE;
80 virtual void CenterWindow(const gfx::Size& size) OVERRIDE;
81 virtual void GetWindowBoundsAndMaximizedState(gfx::Rect* bounds,
82 bool* maximized) const OVERRIDE;
83 virtual void SetWindowTitle(const std::wstring& title) OVERRIDE;
84 virtual void SetWindowIcons(const SkBitmap& window_icon,
85 const SkBitmap& app_icon) OVERRIDE;
86 virtual void SetAccessibleName(const std::wstring& name) OVERRIDE;
87 virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE;
88 virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE;
89 virtual void BecomeModal() OVERRIDE;
90 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE;
91 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE;
92 virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
93 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
94 virtual void SetSize(const gfx::Size& size) OVERRIDE;
95 virtual void SetBoundsConstrained(const gfx::Rect& bounds,
96 Widget* other_widget) OVERRIDE;
97 virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE;
98 virtual void MoveToTop() OVERRIDE;
99 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE;
100 virtual void Close() OVERRIDE;
101 virtual void CloseNow() OVERRIDE;
102 virtual void EnableClose(bool enable) OVERRIDE;
103 virtual void Show() OVERRIDE;
104 virtual void Hide() OVERRIDE;
105 virtual void ShowMaximizedWithBounds(
106 const gfx::Rect& restored_bounds) OVERRIDE;
107 virtual void ShowWithState(ShowState state) OVERRIDE;
108 virtual bool IsVisible() const OVERRIDE;
109 virtual void Activate() OVERRIDE;
110 virtual void Deactivate() OVERRIDE;
111 virtual bool IsActive() const OVERRIDE;
112 virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
113 virtual void Maximize() OVERRIDE;
114 virtual void Minimize() OVERRIDE;
115 virtual bool IsMaximized() const OVERRIDE;
116 virtual bool IsMinimized() const OVERRIDE;
117 virtual void Restore() OVERRIDE;
118 virtual void SetFullscreen(bool fullscreen) OVERRIDE;
119 virtual bool IsFullscreen() const OVERRIDE;
120 virtual void SetOpacity(unsigned char opacity) OVERRIDE;
121 virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE;
122 virtual bool IsAccessibleWidget() const OVERRIDE;
123 virtual bool ContainsNativeView(gfx::NativeView native_view) const OVERRIDE;
124 virtual void RunShellDrag(View* view,
125 const ui::OSExchangeData& data,
126 int operation) OVERRIDE;
127 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE;
128 virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE;
129 virtual void ClearNativeFocus() OVERRIDE;
130 virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE;
131
132 virtual void OnMotionNotify(ui::WaylandEvent event) OVERRIDE;
133 virtual void OnButtonNotify(ui::WaylandEvent event) OVERRIDE;
134 virtual void OnKeyNotify(ui::WaylandEvent event) OVERRIDE;
135 virtual void OnPointerFocus(ui::WaylandEvent event) OVERRIDE;
136 virtual void OnKeyboardFocus(ui::WaylandEvent event) OVERRIDE;
137
138 virtual void OnGeometryChange(ui::WaylandEvent event) OVERRIDE;
139
140 private:
141 typedef ScopedVector<ui::ViewProp> ViewProps;
142
143 // Overridden from NativeWidget
144 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
145
146 // Overridden from internal::InputMethodDelegate
147 virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE;
148
149 void OnPaint(gfx::Rect damage_area);
150
151 static gboolean IdleRedraw(void* ptr);
152
153 // A delegate implementation that handles events received here.
154 // See class documentation for Widget in widget.h for a note about ownership.
155 internal::NativeWidgetDelegate* delegate_;
156
157 scoped_ptr<TooltipManager> tooltip_manager_;
158
159 // The following factory is used to delay destruction.
160 ScopedRunnableMethodFactory<NativeWidgetWayland> close_widget_factory_;
161
162 // See class documentation for Widget in widget.h for a note about ownership.
163 Widget::InitParams::Ownership ownership_;
164
165 // Current window allocation
166 gfx::Rect allocation_;
167 // Previous allocation. Used to restore the size and location.
168 gfx::Rect saved_allocation_;
169
170 scoped_ptr<InputMethod> input_method_;
171
172 // The compositor for accelerated drawing.
173 scoped_refptr<ui::Compositor> compositor_;
174
175 ViewProps props_;
176
177 // Pointer to the Wayland display. This object doesn't own the pointer.
178 ui::WaylandDisplay* wayland_display_;
179
180 // Wayland window associated with this widget.
181 ui::WaylandWindow* wayland_window_;
182
183 // The accelerated surface associated with a Wayland window.
184 struct wl_egl_window* egl_window_;
185
186 cairo_device_t* device_;
187
188 // Cairo surface associated with the Wayland accelerated surface. This is
189 // used when we're not using the accelerated painting path.
190 cairo_surface_t* cairo_surface_;
191 const cairo_user_data_key_t surface_data_key_;
192
193 // Used to accumulate damaged area between repaints.
194 // Necessary since Wayland seems to expect at most one paint per frame.
195 gfx::Rect damage_area_;
196
197 // The GL surface and context used to render when we're using unaccelerated
198 // rendering. If we're using accelerated rendering, we'll have a compositor
199 // and the compositor will have these, so we don't need to worry about them.
200 scoped_refptr<gfx::GLSurface> surface_;
201 scoped_refptr<gfx::GLContext> context_;
202
203 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWayland);
204 };
205
206 } // namespace views
207
208 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698