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

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: Removed the WaylandDisplay singleton 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 "ui/wayland/wayland_screen.h"
6
7 #include <wayland-client.h>
8
9 #include "ui/wayland/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 Rectangle WaylandScreen::GetAllocation() const {
24 Rectangle allocation;
25 allocation.x = position_.x;
26 allocation.y = position_.y;
27
28 // Find the active mode and pass its dimensions
29 for (Modes::const_iterator it = modes_.begin(); it != modes_.end(); it++) {
30 if ((*it).flags & WL_OUTPUT_MODE_CURRENT) {
31 allocation.width = (*it).width;
32 allocation.height = (*it).height;
33 break;
34 }
35 }
36
37 return allocation;
38 }
39
40 //static
41 const struct wl_output_listener WaylandScreen::output_listener = {
42 WaylandScreen::OutputHandleGeometry,
43 WaylandScreen::OutputHandleMode,
44 };
45
46 // static
47 void WaylandScreen::OutputHandleGeometry(void* data,
48 struct wl_output* output,
49 int32_t x,
50 int32_t y,
51 int32_t physical_width,
52 int32_t physical_height,
53 int32_t subpixel,
54 const char* make,
55 const char* model) {
56 WaylandScreen* screen = static_cast<WaylandScreen*>(data);
57 screen->position_.x = x;
58 screen->position_.y = y;
59 }
60
61 // static
62 void WaylandScreen::OutputHandleMode(void* data,
63 struct wl_output* wl_output,
64 uint32_t flags,
65 int32_t width,
66 int32_t height,
67 int32_t refresh) {
68 WaylandScreen* screen = static_cast<WaylandScreen*>(data);
69
70 Mode mode;
71 mode.width = width;
72 mode.height = height;
73 mode.refresh = refresh;
74 mode.flags = flags;
75
76 screen->modes_.push_back(mode);
77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698