Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 namespace ui { | |
| 12 | |
| 13 WaylandScreen::WaylandScreen(WaylandDisplay* display, uint32_t id) | |
| 14 : output_(NULL), | |
| 15 display_(display) { | |
| 16 static const wl_output_listener kOutputListener = { | |
|
tfarina
2011/07/25 21:11:46
I mean, the whole body of this ctor should be inde
| |
| 17 WaylandScreen::OutputHandleGeometry, | |
| 18 WaylandScreen::OutputHandleMode, | |
| 19 }; | |
| 20 | |
| 21 output_ = wl_output_create(display_->GetNativeDisplay(), id, 1); | |
| 22 wl_output_add_listener(output_, &kOutputListener, this); | |
| 23 } | |
| 24 | |
| 25 WaylandScreen::~WaylandScreen() { | |
| 26 if (output_) | |
| 27 wl_output_destroy(output_); | |
| 28 } | |
| 29 | |
| 30 gfx::Rect WaylandScreen::GetAllocation() const { | |
| 31 gfx::Rect allocation; | |
| 32 allocation.set_origin(position_); | |
| 33 | |
| 34 // Find the active mode and pass its dimensions. | |
| 35 for (Modes::const_iterator i = modes_.begin(); i != modes_.end(); ++i) { | |
| 36 if ((*i).flags & WL_OUTPUT_MODE_CURRENT) { | |
| 37 allocation.set_width((*i).width); | |
| 38 allocation.set_height((*i).height); | |
| 39 break; | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 return allocation; | |
| 44 } | |
| 45 | |
| 46 // static | |
| 47 void WaylandScreen::OutputHandleGeometry(void* data, | |
| 48 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_.SetPoint(x, y); | |
| 58 } | |
| 59 | |
| 60 // static | |
| 61 void WaylandScreen::OutputHandleMode(void* data, | |
| 62 wl_output* wl_output, | |
| 63 uint32_t flags, | |
| 64 int32_t width, | |
| 65 int32_t height, | |
| 66 int32_t refresh) { | |
| 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 | |
| OLD | NEW |