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

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

Issue 1742883002: ozone/platform/wayland: Drop WaylandWindow::GetWidget() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wayland-test1
Patch Set: Created 4 years, 9 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/ozone/platform/wayland/wayland_display.h" 10 #include "ui/ozone/platform/wayland/wayland_display.h"
11 #include "ui/platform_window/platform_window_delegate.h" 11 #include "ui/platform_window/platform_window_delegate.h"
12 12
13 namespace ui { 13 namespace ui {
14 14
15 WaylandWindow::WaylandWindow(PlatformWindowDelegate* delegate, 15 WaylandWindow::WaylandWindow(PlatformWindowDelegate* delegate,
16 WaylandDisplay* display, 16 WaylandDisplay* display,
17 const gfx::Rect& bounds) 17 const gfx::Rect& bounds)
18 : delegate_(delegate), display_(display), bounds_(bounds) {} 18 : delegate_(delegate), display_(display), bounds_(bounds) {}
19 19
20 WaylandWindow::~WaylandWindow() { 20 WaylandWindow::~WaylandWindow() {
21 if (xdg_surface_) { 21 if (xdg_surface_) {
22 display_->RemoveWindow(this); 22 display_->RemoveWindow(surface_.id());
23 } 23 }
24 } 24 }
25 25
26 bool WaylandWindow::Initialize() { 26 bool WaylandWindow::Initialize() {
27 static const xdg_surface_listener xdg_surface_listener = { 27 static const xdg_surface_listener xdg_surface_listener = {
28 &WaylandWindow::Configure, &WaylandWindow::Close, 28 &WaylandWindow::Configure, &WaylandWindow::Close,
29 }; 29 };
30 30
31 surface_.reset(wl_compositor_create_surface(display_->compositor())); 31 surface_.reset(wl_compositor_create_surface(display_->compositor()));
32 if (!surface_) { 32 if (!surface_) {
33 LOG(ERROR) << "Failed to create wl_surface"; 33 LOG(ERROR) << "Failed to create wl_surface";
34 return false; 34 return false;
35 } 35 }
36 wl_surface_set_user_data(surface_.get(), this); 36 wl_surface_set_user_data(surface_.get(), this);
37 xdg_surface_.reset( 37 xdg_surface_.reset(
38 xdg_shell_get_xdg_surface(display_->shell(), surface_.get())); 38 xdg_shell_get_xdg_surface(display_->shell(), surface_.get()));
39 if (!xdg_surface_) { 39 if (!xdg_surface_) {
40 LOG(ERROR) << "Failed to create xdg_surface"; 40 LOG(ERROR) << "Failed to create xdg_surface";
41 return false; 41 return false;
42 } 42 }
43 xdg_surface_add_listener(xdg_surface_.get(), &xdg_surface_listener, this); 43 xdg_surface_add_listener(xdg_surface_.get(), &xdg_surface_listener, this);
44 44
45 display_->AddWindow(this); 45 display_->AddWindow(surface_.id(), this);
46 delegate_->OnAcceleratedWidgetAvailable(surface_.id(), 1.f); 46 delegate_->OnAcceleratedWidgetAvailable(surface_.id(), 1.f);
47 47
48 return true; 48 return true;
49 } 49 }
50 50
51 wl_surface* WaylandWindow::GetSurface() {
52 DCHECK(surface_);
53 return surface_.get();
54 }
55
56 gfx::AcceleratedWidget WaylandWindow::GetWidget() {
57 DCHECK(surface_);
58 return surface_.id();
59 }
60
61 void WaylandWindow::ApplyPendingBounds() { 51 void WaylandWindow::ApplyPendingBounds() {
62 if (pending_bounds_.IsEmpty()) 52 if (pending_bounds_.IsEmpty())
63 return; 53 return;
64 54
65 SetBounds(pending_bounds_); 55 SetBounds(pending_bounds_);
66 DCHECK(xdg_surface_); 56 DCHECK(xdg_surface_);
67 xdg_surface_ack_configure(xdg_surface_.get(), pending_configure_serial_); 57 xdg_surface_ack_configure(xdg_surface_.get(), pending_configure_serial_);
68 pending_bounds_ = gfx::Rect(); 58 pending_bounds_ = gfx::Rect();
69 } 59 }
70 60
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // during an interactive resize, and only the last one matters. 142 // during an interactive resize, and only the last one matters.
153 window->pending_bounds_ = gfx::Rect(0, 0, width, height); 143 window->pending_bounds_ = gfx::Rect(0, 0, width, height);
154 window->pending_configure_serial_ = serial; 144 window->pending_configure_serial_ = serial;
155 } 145 }
156 146
157 void WaylandWindow::Close(void* data, xdg_surface* obj) { 147 void WaylandWindow::Close(void* data, xdg_surface* obj) {
158 NOTIMPLEMENTED(); 148 NOTIMPLEMENTED();
159 } 149 }
160 150
161 } // namespace ui 151 } // 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