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

Side by Side Diff: ui/ozone/platform/wayland/wayland_window.cc

Issue 2147523003: Rename WaylandDisplay to WaylandConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add argument name Created 4 years, 5 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/ozone/platform/wayland/wayland_window.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/ozone/platform/wayland/wayland_window.h" 5 #include "ui/ozone/platform/wayland/wayland_window.h"
6 6
7 #include <xdg-shell-unstable-v5-client-protocol.h> 7 #include <xdg-shell-unstable-v5-client-protocol.h>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
11 #include "ui/events/ozone/events_ozone.h" 11 #include "ui/events/ozone/events_ozone.h"
12 #include "ui/ozone/platform/wayland/wayland_display.h" 12 #include "ui/ozone/platform/wayland/wayland_connection.h"
13 #include "ui/platform_window/platform_window_delegate.h" 13 #include "ui/platform_window/platform_window_delegate.h"
14 14
15 namespace ui { 15 namespace ui {
16 16
17 WaylandWindow::WaylandWindow(PlatformWindowDelegate* delegate, 17 WaylandWindow::WaylandWindow(PlatformWindowDelegate* delegate,
18 WaylandDisplay* display, 18 WaylandConnection* connection,
19 const gfx::Rect& bounds) 19 const gfx::Rect& bounds)
20 : delegate_(delegate), display_(display), bounds_(bounds) {} 20 : delegate_(delegate), connection_(connection), bounds_(bounds) {}
21 21
22 WaylandWindow::~WaylandWindow() { 22 WaylandWindow::~WaylandWindow() {
23 if (xdg_surface_) { 23 if (xdg_surface_) {
24 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); 24 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
25 display_->RemoveWindow(surface_.id()); 25 connection_->RemoveWindow(surface_.id());
26 } 26 }
27 } 27 }
28 28
29 // static 29 // static
30 WaylandWindow* WaylandWindow::FromSurface(wl_surface* surface) { 30 WaylandWindow* WaylandWindow::FromSurface(wl_surface* surface) {
31 return static_cast<WaylandWindow*>( 31 return static_cast<WaylandWindow*>(
32 wl_proxy_get_user_data(reinterpret_cast<wl_proxy*>(surface))); 32 wl_proxy_get_user_data(reinterpret_cast<wl_proxy*>(surface)));
33 } 33 }
34 34
35 bool WaylandWindow::Initialize() { 35 bool WaylandWindow::Initialize() {
36 static const xdg_surface_listener xdg_surface_listener = { 36 static const xdg_surface_listener xdg_surface_listener = {
37 &WaylandWindow::Configure, &WaylandWindow::Close, 37 &WaylandWindow::Configure, &WaylandWindow::Close,
38 }; 38 };
39 39
40 surface_.reset(wl_compositor_create_surface(display_->compositor())); 40 surface_.reset(wl_compositor_create_surface(connection_->compositor()));
41 if (!surface_) { 41 if (!surface_) {
42 LOG(ERROR) << "Failed to create wl_surface"; 42 LOG(ERROR) << "Failed to create wl_surface";
43 return false; 43 return false;
44 } 44 }
45 wl_surface_set_user_data(surface_.get(), this); 45 wl_surface_set_user_data(surface_.get(), this);
46 xdg_surface_.reset( 46 xdg_surface_.reset(
47 xdg_shell_get_xdg_surface(display_->shell(), surface_.get())); 47 xdg_shell_get_xdg_surface(connection_->shell(), surface_.get()));
48 if (!xdg_surface_) { 48 if (!xdg_surface_) {
49 LOG(ERROR) << "Failed to create xdg_surface"; 49 LOG(ERROR) << "Failed to create xdg_surface";
50 return false; 50 return false;
51 } 51 }
52 xdg_surface_add_listener(xdg_surface_.get(), &xdg_surface_listener, this); 52 xdg_surface_add_listener(xdg_surface_.get(), &xdg_surface_listener, this);
53 display_->ScheduleFlush(); 53 connection_->ScheduleFlush();
54 54
55 display_->AddWindow(surface_.id(), this); 55 connection_->AddWindow(surface_.id(), this);
56 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); 56 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
57 delegate_->OnAcceleratedWidgetAvailable(surface_.id(), 1.f); 57 delegate_->OnAcceleratedWidgetAvailable(surface_.id(), 1.f);
58 58
59 return true; 59 return true;
60 } 60 }
61 61
62 void WaylandWindow::ApplyPendingBounds() { 62 void WaylandWindow::ApplyPendingBounds() {
63 if (pending_bounds_.IsEmpty()) 63 if (pending_bounds_.IsEmpty())
64 return; 64 return;
65 65
66 SetBounds(pending_bounds_); 66 SetBounds(pending_bounds_);
67 DCHECK(xdg_surface_); 67 DCHECK(xdg_surface_);
68 xdg_surface_ack_configure(xdg_surface_.get(), pending_configure_serial_); 68 xdg_surface_ack_configure(xdg_surface_.get(), pending_configure_serial_);
69 pending_bounds_ = gfx::Rect(); 69 pending_bounds_ = gfx::Rect();
70 display_->ScheduleFlush(); 70 connection_->ScheduleFlush();
71 } 71 }
72 72
73 void WaylandWindow::Show() {} 73 void WaylandWindow::Show() {}
74 74
75 void WaylandWindow::Hide() { 75 void WaylandWindow::Hide() {
76 NOTIMPLEMENTED(); 76 NOTIMPLEMENTED();
77 } 77 }
78 78
79 void WaylandWindow::Close() { 79 void WaylandWindow::Close() {
80 NOTIMPLEMENTED(); 80 NOTIMPLEMENTED();
81 } 81 }
82 82
83 void WaylandWindow::SetBounds(const gfx::Rect& bounds) { 83 void WaylandWindow::SetBounds(const gfx::Rect& bounds) {
84 if (bounds == bounds_) 84 if (bounds == bounds_)
85 return; 85 return;
86 bounds_ = bounds; 86 bounds_ = bounds;
87 delegate_->OnBoundsChanged(bounds); 87 delegate_->OnBoundsChanged(bounds);
88 } 88 }
89 89
90 gfx::Rect WaylandWindow::GetBounds() { 90 gfx::Rect WaylandWindow::GetBounds() {
91 return bounds_; 91 return bounds_;
92 } 92 }
93 93
94 void WaylandWindow::SetTitle(const base::string16& title) { 94 void WaylandWindow::SetTitle(const base::string16& title) {
95 DCHECK(xdg_surface_); 95 DCHECK(xdg_surface_);
96 xdg_surface_set_title(xdg_surface_.get(), UTF16ToUTF8(title).c_str()); 96 xdg_surface_set_title(xdg_surface_.get(), UTF16ToUTF8(title).c_str());
97 display_->ScheduleFlush(); 97 connection_->ScheduleFlush();
98 } 98 }
99 99
100 void WaylandWindow::SetCapture() { 100 void WaylandWindow::SetCapture() {
101 NOTIMPLEMENTED(); 101 NOTIMPLEMENTED();
102 } 102 }
103 103
104 void WaylandWindow::ReleaseCapture() { 104 void WaylandWindow::ReleaseCapture() {
105 NOTIMPLEMENTED(); 105 NOTIMPLEMENTED();
106 } 106 }
107 107
108 void WaylandWindow::ToggleFullscreen() { 108 void WaylandWindow::ToggleFullscreen() {
109 NOTIMPLEMENTED(); 109 NOTIMPLEMENTED();
110 } 110 }
111 111
112 void WaylandWindow::Maximize() { 112 void WaylandWindow::Maximize() {
113 DCHECK(xdg_surface_); 113 DCHECK(xdg_surface_);
114 xdg_surface_set_maximized(xdg_surface_.get()); 114 xdg_surface_set_maximized(xdg_surface_.get());
115 display_->ScheduleFlush(); 115 connection_->ScheduleFlush();
116 } 116 }
117 117
118 void WaylandWindow::Minimize() { 118 void WaylandWindow::Minimize() {
119 DCHECK(xdg_surface_); 119 DCHECK(xdg_surface_);
120 xdg_surface_set_minimized(xdg_surface_.get()); 120 xdg_surface_set_minimized(xdg_surface_.get());
121 display_->ScheduleFlush(); 121 connection_->ScheduleFlush();
122 } 122 }
123 123
124 void WaylandWindow::Restore() { 124 void WaylandWindow::Restore() {
125 DCHECK(xdg_surface_); 125 DCHECK(xdg_surface_);
126 xdg_surface_unset_maximized(xdg_surface_.get()); 126 xdg_surface_unset_maximized(xdg_surface_.get());
127 display_->ScheduleFlush(); 127 connection_->ScheduleFlush();
128 } 128 }
129 129
130 void WaylandWindow::SetCursor(PlatformCursor cursor) { 130 void WaylandWindow::SetCursor(PlatformCursor cursor) {
131 NOTIMPLEMENTED(); 131 NOTIMPLEMENTED();
132 } 132 }
133 133
134 void WaylandWindow::MoveCursorTo(const gfx::Point& location) { 134 void WaylandWindow::MoveCursorTo(const gfx::Point& location) {
135 NOTIMPLEMENTED(); 135 NOTIMPLEMENTED();
136 } 136 }
137 137
(...skipping 23 matching lines...) Expand all
161 // static 161 // static
162 void WaylandWindow::Configure(void* data, 162 void WaylandWindow::Configure(void* data,
163 xdg_surface* obj, 163 xdg_surface* obj,
164 int32_t width, 164 int32_t width,
165 int32_t height, 165 int32_t height,
166 wl_array* states, 166 wl_array* states,
167 uint32_t serial) { 167 uint32_t serial) {
168 WaylandWindow* window = static_cast<WaylandWindow*>(data); 168 WaylandWindow* window = static_cast<WaylandWindow*>(data);
169 169
170 // Rather than call SetBounds here for every configure event, just save the 170 // Rather than call SetBounds here for every configure event, just save the
171 // most recent bounds, and have WaylandDisplay call ApplyPendingBounds when it 171 // most recent bounds, and have WaylandConnection call ApplyPendingBounds
172 // has finished processing events. We may get many configure events in a row 172 // when it has finished processing events. We may get many configure events
173 // during an interactive resize, and only the last one matters. 173 // in a row during an interactive resize, and only the last one matters.
174 window->pending_bounds_ = gfx::Rect(0, 0, width, height); 174 window->pending_bounds_ = gfx::Rect(0, 0, width, height);
175 window->pending_configure_serial_ = serial; 175 window->pending_configure_serial_ = serial;
176 } 176 }
177 177
178 // static 178 // static
179 void WaylandWindow::Close(void* data, xdg_surface* obj) { 179 void WaylandWindow::Close(void* data, xdg_surface* obj) {
180 NOTIMPLEMENTED(); 180 NOTIMPLEMENTED();
181 } 181 }
182 182
183 } // namespace ui 183 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/wayland/wayland_window.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698