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

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

Issue 2042503002: ozone/platform/wayland: Add support for wl_output_interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WaylandDisplay => WaylandConnection, WaylandScreen => WaylandOutput Created 4 years, 6 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/ozone/platform/wayland/wayland_output.h"
6
7 #include <wayland-client.h>
8
9 #include "ui/display/screen.h"
10 #include "ui/ozone/platform/wayland/wayland_connection.h"
11
12 namespace ui {
13
14 WaylandOutput::WaylandOutput(uint32_t name, wl_output* output)
15 : name_(name), output_(output), rect_(0, 0, 0, 0), observer_(nullptr) {
16 static const wl_output_listener output_listener = {
17 &WaylandOutput::OutputHandleGeometry, &WaylandOutput::OutputHandleMode,
18 };
19 wl_output_add_listener(output, &output_listener, this);
20 }
21
22 WaylandOutput::~WaylandOutput() {}
23
24 // static
25 void WaylandOutput::OutputHandleGeometry(void* data,
26 wl_output* output,
27 int32_t x,
28 int32_t y,
29 int32_t physical_width,
30 int32_t physical_height,
31 int32_t subpixel,
32 const char* make,
33 const char* model,
34 int32_t output_transform) {
35 WaylandOutput* wayland_output = static_cast<WaylandOutput*>(data);
36 wayland_output->rect_.set_origin(gfx::Point(x, y));
37 }
38
39 // static
40 void WaylandOutput::OutputHandleMode(void* data,
41 wl_output* wl_output,
42 uint32_t flags,
43 int32_t width,
44 int32_t height,
45 int32_t refresh) {
46 WaylandOutput* output = static_cast<WaylandOutput*>(data);
47
48 if (flags & WL_OUTPUT_MODE_CURRENT) {
49 output->rect_.set_width(width);
50 output->rect_.set_height(height);
51
52 if (display::Screen::GetScreen())
53 display::Screen::GetScreen()->OnOutputGeometryChanged(output->name_,
54 output->rect_);
55 if (output->observer())
56 output->observer()->OnOutputReadyForUse();
57 }
58 }
59
60 WaylandOutput::Observer::Observer(const base::Closure& closure,
61 WaylandOutput* output)
62 : closure_(closure) {
63 DCHECK(!closure_.is_null());
64 output->SetObserver(this);
65 }
66
67 WaylandOutput::Observer::~Observer() {}
68
69 void WaylandOutput::Observer::OnOutputReadyForUse() {
70 if (!closure_.is_null())
71 closure_.Run();
72 }
73
74 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698