diff options
author | Marcus Fritzsch <marcus_fritzsch@mentor.com> | 2017-06-22 16:21:26 +0200 |
---|---|---|
committer | Marcus Fritzsch <marcus_fritzsch@mentor.com> | 2017-08-08 17:24:00 +0200 |
commit | 47b4446227ac06b2873118717a4c868325b64162 (patch) | |
tree | 345a9c7da0e204a8ae7aac561489099a923e57df | |
parent | 5e8b656af6c13323f91907f38f38863da873014c (diff) |
wayland: storing output mode and surface properties
The events for this are received by the controller, the data however is
stored in the surface proxe wrappers.
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
-rw-r--r-- | src/wayland.cpp | 37 | ||||
-rw-r--r-- | src/wayland.hpp | 4 |
2 files changed, 39 insertions, 2 deletions
diff --git a/src/wayland.cpp b/src/wayland.cpp index 38092e3..5b526ec 100644 --- a/src/wayland.cpp +++ b/src/wayland.cpp @@ -129,6 +129,11 @@ void output::geometry(int32_t x, int32_t y, int32_t pw, int32_t ph, void output::mode(uint32_t flags, int32_t w, int32_t h, int32_t r) { logdebug("wl::output %s @ %p f %x w %i h %i r %i", __func__, this->proxy, flags, w, h, r); + if (flags & WL_OUTPUT_MODE_CURRENT) { + this->width = w; + this->height = h; + this->refresh = r; + } } void output::done() { @@ -442,7 +447,13 @@ constexpr struct ivi_controller_surface_listener surface_listener = { surface::surface(uint32_t i, struct controller *c) : wayland_proxy(ivi_controller_surface_create(c->proxy, i)), - controlled_entity(c, i) { + controlled_entity(c, i), + dst_rect{}, + src_rect{}, + size{}, + orientation{}, + visibility{}, + opacity{1.f} { ivi_controller_surface_add_listener(this->proxy, &surface_listener, this); } @@ -454,16 +465,22 @@ surface::~surface() { void controller::surface_visibility(uint32_t id, int32_t visibility) { logdebug("genivi::surface %s @ %p v %i", __func__, this->proxy, visibility); + struct surface *s = this->surfaces[id].get(); + s->visibility = visibility; } void controller::surface_opacity(uint32_t id, float opacity) { logdebug("genivi::surface %s @ %p o %f", __func__, this->proxy, opacity); + struct surface *s = this->surfaces[id].get(); + s->opacity = opacity; } void controller::surface_source_rectangle(uint32_t id, int32_t x, int32_t y, int32_t width, int32_t height) { logdebug("genivi::surface %s @ %p x %i y %i w %i h %i", __func__, this->proxy, x, y, width, height); + struct surface *s = this->surfaces[id].get(); + s->src_rect = rect{uint32_t(width), uint32_t(height), x, y}; } void controller::surface_destination_rectangle(uint32_t id, int32_t x, @@ -471,16 +488,30 @@ void controller::surface_destination_rectangle(uint32_t id, int32_t x, int32_t height) { logdebug("genivi::surface %s @ %p x %i y %i w %i h %i", __func__, this->proxy, x, y, width, height); + struct surface *s = this->surfaces[id].get(); + s->dst_rect = rect{uint32_t(width), uint32_t(height), x, y}; } void controller::surface_configuration(uint32_t id, int32_t width, int32_t height) { logdebug("genivi::surface %s @ %p w %i h %i", __func__, this->proxy, width, height); + struct surface *s = this->surfaces[id].get(); + bool center = s->size.w != width && s->size.h != height; + s->size = size{uint32_t(width), uint32_t(height)}; + if (center) + add_task([id, width, height](struct controller *c) { + auto const s = c->surfaces.find(id); + if (s != c->surfaces.end()) + s->second->set_destination_rectangle( + 800 / 2 - width / 2, 600 / 2 - height / 2, width, height); + }); } void controller::surface_orientation(uint32_t id, int32_t orientation) { logdebug("genivi::surface %s @ %p o %i", __func__, this->proxy, orientation); + struct surface *s = this->surfaces[id].get(); + s->orientation = orientation; } void controller::surface_pixelformat(uint32_t id, int32_t pixelformat) { @@ -521,5 +552,7 @@ void controller::surface_content(uint32_t id, int32_t content_state) { // screen::screen(uint32_t i, struct controller *c, struct ivi_controller_screen *p) - : wayland_proxy(p), controlled_entity(c, i) {} + : wayland_proxy(p), controlled_entity(c, i) { + logdebug("genivi::screen @ %p id %u", p, i); +} } diff --git a/src/wayland.hpp b/src/wayland.hpp index f58ada0..3914e38 100644 --- a/src/wayland.hpp +++ b/src/wayland.hpp @@ -88,6 +88,10 @@ struct registry : public wayland_proxy<struct wl_registry> { // \___/ \__,_|\__| .__/ \__,_|\__| // |_| struct output : wayland_proxy<struct wl_output> { + int width; + int height; + int refresh; + output(struct wl_registry *registry, uint32_t name, uint32_t version); // Events |