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

Side by Side Diff: ui/ozone/platform/wayland/wayland_screen.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: hide the use of the base::Closure 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_screen.h"
6
7 #include <wayland-client.h>
8
9 #include "base/run_loop.h"
10 #include "ui/display/screen.h"
11 #include "ui/ozone/platform/wayland/wayland_display.h"
12
13 namespace ui {
14
15 WaylandScreen::WaylandScreen(wl_registry* registry,
Michael Forney 2016/06/14 23:44:54 registry is unused.
joone 2016/06/20 22:22:42 Removed.
16 uint32_t name,
17 wl_output* output)
18 : output_(output), name_(name), rect_(0, 0, 0, 0) {
19 static const wl_output_listener output_listener = {
20 &WaylandScreen::OutputHandleGeometry, &WaylandScreen::OutputHandleMode,
21 };
22 wl_output_add_listener(output, &output_listener, this);
23 }
24
25 WaylandScreen::~WaylandScreen() {}
26
27 // static
28 void WaylandScreen::OutputHandleGeometry(void* data,
29 wl_output* output,
30 int32_t x,
31 int32_t y,
32 int32_t physical_width,
33 int32_t physical_height,
34 int32_t subpixel,
35 const char* make,
36 const char* model,
37 int32_t output_transform) {
38 WaylandScreen* screen = static_cast<WaylandScreen*>(data);
39 screen->rect_.set_origin(gfx::Point(x, y));
40 }
41
42 // static
43 void WaylandScreen::OutputHandleMode(void* data,
44 wl_output* wl_output,
45 uint32_t flags,
46 int32_t width,
47 int32_t height,
48 int32_t refresh) {
49 WaylandScreen* screen = static_cast<WaylandScreen*>(data);
50
51 if (flags & WL_OUTPUT_MODE_CURRENT) {
52 screen->rect_.set_width(width);
53 screen->rect_.set_height(height);
54
55 if (display::Screen::GetScreen())
56 display::Screen::GetScreen()->OnOutputGeometryChanged(screen->name_,
57 screen->rect_);
58 screen->OutputReadyForUse();
59 }
60 }
61
62 void WaylandScreen::WaitforOutputAvailable() {
rjkroege 2016/06/14 23:29:48 Do you need to use a RunLoop? It is better to avoi
joone 2016/06/20 22:22:42 RunLoop can be used in the test case so I will rem
63 base::RunLoop run_loop;
64 output_complete_closure_ = run_loop.QuitClosure();
65 run_loop.Run();
Michael Forney 2016/06/14 23:25:33 I think base::WaitableEvent may be more appropriat
joone 2016/06/16 22:44:23 I tried to use base::WaitableEvent instead of base
66 }
67
68 void WaylandScreen::OutputReadyForUse() {
69 if (!output_complete_closure_.is_null())
70 output_complete_closure_.Run();
71 }
72
73 } // namespace ui
OLDNEW
« ui/ozone/platform/wayland/wayland_screen.h ('K') | « ui/ozone/platform/wayland/wayland_screen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698