X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwayland.cpp;h=52b2371e805e5ae40641d9790cb3e668cd17bab1;hb=7a222198086e2c2ce7a19a989d1feee0cd31d8ab;hp=b81f1404a54876f9987938f43ae538662abae2eb;hpb=3121d0b9b553ddc709be8b67e91395a796cc6b6e;p=staging%2Fwindowmanager.git diff --git a/src/wayland.cpp b/src/wayland.cpp index b81f140..52b2371 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() { @@ -195,6 +200,14 @@ controller::controller(struct wl_registry *r, uint32_t name, uint32_t version) controller::~controller() {} +void controller::layer_create(uint32_t id, int32_t w, int32_t h) { + this->layers[id] = std::make_unique(id, w, h, this); +} + +void controller::surface_create(uint32_t id) { + this->surfaces[id] = std::make_unique(id, this); +} + void controller::controller_screen(uint32_t id, struct ivi_controller_screen *screen) { logdebug("genivi::controller @ %p screen %u (%x) @ %p", this->proxy, id, id, @@ -289,7 +302,11 @@ constexpr struct ivi_controller_layer_listener layer_listener = { } layer::layer(uint32_t i, struct controller *c) - : wayland_proxy(ivi_controller_layer_create(c->proxy, i, 0, 0)), + : layer(i, 0, 0, c) { +} + +layer::layer(uint32_t i, int32_t w, int32_t h, struct controller *c) + : wayland_proxy(ivi_controller_layer_create(c->proxy, i, w, h)), controlled_entity(c, i) { ivi_controller_layer_add_listener(this->proxy, &layer_listener, this); } @@ -442,7 +459,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 +477,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 +500,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) + 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); + add_task("fullscreen surface", [id, width, height](struct controller *c) { + }); } 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) { @@ -507,6 +550,10 @@ void controller::surface_destroyed(uint32_t id) { void controller::surface_content(uint32_t id, int32_t content_state) { logdebug("genivi::surface %s @ %p s %i", __func__, this->proxy, content_state); + if (content_state == IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED) { + add_task("remove surface", + [id](struct controller *c) { c->surfaces.erase(id); }); + } } // @@ -517,5 +564,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); +} }