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

Side by Side Diff: ui/wayland/wayland_screen.cc

Issue 17265006: wayland patch for inspection Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « ui/wayland/wayland_screen.h ('k') | ui/wayland/wayland_task.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 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/wayland/wayland_screen.h"
6
7 #include <wayland-client.h>
8
9 #include "ui/wayland/wayland_display.h"
10
11 namespace ui {
12
13 WaylandScreen::WaylandScreen(WaylandDisplay* display, uint32_t id)
14 : output_(NULL),
15 display_(display)
16 {
17 static const wl_output_listener kOutputListener = {
18 WaylandScreen::OutputHandleGeometry,
19 WaylandScreen::OutputHandleMode,
20 };
21
22 output_ = static_cast<wl_output*>(
23 wl_registry_bind(display_->registry(), id, &wl_output_interface, 1));
24 wl_output_add_listener(output_, &kOutputListener, this);
25 }
26
27 WaylandScreen::~WaylandScreen()
28 {
29 if (output_)
30 wl_output_destroy(output_);
31 }
32
33 gfx::Rect WaylandScreen::GetAllocation() const
34 {
35 gfx::Rect allocation;
36 allocation.set_origin(position_);
37
38 // Find the active mode and pass its dimensions.
39 for (Modes::const_iterator i = modes_.begin(); i != modes_.end(); ++i) {
40 if ((*i).flags & WL_OUTPUT_MODE_CURRENT) {
41 allocation.set_width((*i).width);
42 allocation.set_height((*i).height);
43 break;
44 }
45 }
46
47 return allocation;
48 }
49
50 // static
51 void WaylandScreen::OutputHandleGeometry(void *data,
52 wl_output *output, int32_t x, int32_t y,
53 int32_t physical_width, int32_t physical_height,
54 int32_t subpixel, const char* make,
55 const char* model, int32_t output_transform)
56 {
57 WaylandScreen* screen = static_cast<WaylandScreen*>(data);
58 screen->position_.SetPoint(x, y);
59 }
60
61 // static
62 void WaylandScreen::OutputHandleMode(void* data,
63 wl_output* wl_output, uint32_t flags,
64 int32_t width, int32_t height,
65 int32_t refresh)
66 {
67 WaylandScreen* screen = static_cast<WaylandScreen*>(data);
68
69 Mode mode;
70 mode.width = width;
71 mode.height = height;
72 mode.refresh = refresh;
73 mode.flags = flags;
74
75 screen->modes_.push_back(mode);
76 }
77
78 } // namespace ui
OLDNEW
« no previous file with comments | « ui/wayland/wayland_screen.h ('k') | ui/wayland/wayland_task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698