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

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

Issue 7457023: Adding a Wayland basic toolkit (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: More comments and Chrome style formatting Created 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 "wayland_screen.h"
6
7 #include <wayland-client.h>
8
9 #include "wayland_display.h"
10
11 WaylandScreen::WaylandScreen(WaylandDisplay* display, uint32_t id)
12 : output_(NULL),
13 display_(display) {
14 output_ = wl_output_create(display_->GetNativeDisplay(), id, 1);
15 wl_output_add_listener(output_, &output_listener, this);
16 }
17
18 WaylandScreen::~WaylandScreen() {
19 if (output_) {
20 wl_output_destroy(output_);
21 }
22 }
23
24 Rectangle WaylandScreen::GetAllocation() const {
25 Rectangle allocation;
26 allocation.x = position_.x;
27 allocation.y = position_.y;
28
29 // Find the active mode and pass its dimensions
30 for (Modes::const_iterator it = modes_.begin(); it != modes_.end(); it++) {
31 if ((*it).flags & WL_OUTPUT_MODE_CURRENT) {
32 allocation.width = (*it).width;
33 allocation.height = (*it).height;
34 break;
35 }
36 }
37
38 return allocation;
39 }
40
41 //static
42 const struct wl_output_listener WaylandScreen::output_listener = {
43 WaylandScreen::OutputHandleGeometry,
44 WaylandScreen::OutputHandleMode,
45 };
46
47 // static
48 void WaylandScreen::OutputHandleGeometry(void* data,
49 struct wl_output* output,
50 int32_t x,
51 int32_t y,
52 int32_t physical_width,
53 int32_t physical_height,
54 int32_t subpixel,
55 const char* make,
56 const char* model) {
57 WaylandScreen* screen = static_cast<WaylandScreen*>(data);
58 screen->position_.x = x;
59 screen->position_.y = y;
60 }
61
62 // static
63 void WaylandScreen::OutputHandleMode(void* data,
64 struct wl_output* wl_output,
65 uint32_t flags,
66 int32_t width,
67 int32_t height,
68 int32_t refresh) {
69 WaylandScreen* screen = static_cast<WaylandScreen*>(data);
70
71 Mode mode;
72 mode.width = width;
73 mode.height = height;
74 mode.refresh = refresh;
75 mode.flags = flags;
76
77 screen->modes_.push_back(mode);
78 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698