diff options
-rw-r--r-- | session.vim | 27 | ||||
-rw-r--r-- | src/main.cpp | 24 | ||||
-rw-r--r-- | src/wayland.cpp | 215 | ||||
-rw-r--r-- | src/wayland.hpp | 114 |
4 files changed, 346 insertions, 34 deletions
diff --git a/session.vim b/session.vim index d02e460..b3b296a 100644 --- a/session.vim +++ b/session.vim @@ -7,17 +7,18 @@ if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == '' let s:wipebuf = bufnr('%') endif set shortmess=aoO -badd +10 src/CMakeLists.txt -badd +46 CMakeLists.txt -badd +19 src/util.c -badd +14 src/util.h -badd +36 term://.//9732:/usr/bin/fish -badd +80 src/main.cpp -badd +11 src/genivi.hpp +badd +7 src/CMakeLists.txt +badd +43 CMakeLists.txt +badd +57 src/util.c +badd +12 src/util.h +badd +45 src/main.cpp +badd +221 src/wayland.hpp +badd +212 src/wayland.cpp +badd +0 term://.//6935:/usr/bin/fish argglobal silent! argdel * argadd src/main.c -edit src/genivi.hpp +edit src/wayland.hpp set splitbelow splitright wincmd _ | wincmd | vsplit @@ -38,15 +39,15 @@ setlocal fdl=0 setlocal fml=1 setlocal fdn=20 setlocal fen -let s:l = 11 - ((10 * winheight(0) + 33) / 66) +let s:l = 44 - ((43 * winheight(0) + 33) / 66) if s:l < 1 | let s:l = 1 | endif exe s:l normal! zt -11 +44 normal! 0 wincmd w argglobal -edit term://.//9732:/usr/bin/fish +edit term://.//6935:/usr/bin/fish setlocal fdm=marker setlocal fde=0 setlocal fmr={{{,}}} @@ -55,11 +56,11 @@ setlocal fdl=0 setlocal fml=1 setlocal fdn=20 setlocal fen -let s:l = 91 - ((63 * winheight(0) + 33) / 66) +let s:l = 465 - ((42 * winheight(0) + 33) / 66) if s:l < 1 | let s:l = 1 | endif exe s:l normal! zt -91 +465 normal! 0 wincmd w exe 'vert 1resize ' . ((&columns * 137 + 137) / 274) diff --git a/src/main.cpp b/src/main.cpp index 0c010ea..1d92338 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,14 +12,8 @@ struct conn { std::vector<std::unique_ptr<wl::output>> outputs; std::unique_ptr<genivi::controller> c; - - ~conn(); }; -conn::~conn() { - this->outputs.clear(); -} - int main(int argc, char **argv) { lognotice("WinMan ver. %s", WINMAN_VERSION_STRING); @@ -27,25 +21,27 @@ int main(int argc, char **argv) { fatal("Environment variable XDG_RUNTIME_DIR not set"); auto d = std::make_unique<wl::display>(); - if (!d->d) + if (!d->ok()) fatal("Could not connect to compositor"); struct conn c = {}; - d->r->add_global_handler("ivi_controller", [&](wl_registry *r, uint32_t name, uint32_t v) { - c.c = std::make_unique<genivi::controller>(r, name, v); - }); + d->r->add_global_handler( + "ivi_controller", [&](wl_registry *r, uint32_t name, uint32_t v) { + c.c = std::make_unique<genivi::controller>(r, name, v); + }); - d->r->add_global_handler("wl_output", [&](wl_registry *r, uint32_t name, uint32_t v) { - c.outputs.emplace_back(std::make_unique<wl::output>(r, name, v)); - }); + d->r->add_global_handler( + "wl_output", [&](wl_registry *r, uint32_t name, uint32_t v) { + c.outputs.emplace_back(std::make_unique<wl::output>(r, name, v)); + }); // First level objects d->roundtrip(); // Second level objects d->roundtrip(); // Third level objects - /* wl_display_roundtrip(c.d); */ + d->roundtrip(); if (!c.c) fatal("ivi_controller global not available"); diff --git a/src/wayland.cpp b/src/wayland.cpp index c88b5c6..f8db0a6 100644 --- a/src/wayland.cpp +++ b/src/wayland.cpp @@ -19,6 +19,10 @@ display::display() wl_display_connect(NULL), wl_display_disconnect)), r(std::make_unique<registry>(d.get())) {} +bool display::ok() const { + return d.get() != nullptr && wl_display_get_error(d.get()) == 0; +} + void display::roundtrip() { wl_display_roundtrip(this->d.get()); } // _ _ @@ -45,8 +49,8 @@ void registry::event_global(uint32_t name, char const *iface, uint32_t v) { if (b != this->bindings.end()) b->second(this->proxy, name, v); else - logdebug("registry @ %p global n %u i %s v %u", this->proxy, name, iface, - v); + logdebug("wl::registry @ %p global n %u i %s v %u", this->proxy, name, + iface, v); } void registry::event_global_remove(uint32_t name) {} @@ -210,6 +214,90 @@ layer::~layer() { this->proxy = nullptr; } +void layer::event_visibility(int32_t visibility) { + logdebug("genivi::layer %s @ %p v %i", __func__, this->proxy, visibility); +} + +void layer::event_opacity(wl_fixed_t opacity) { + logdebug("genivi::layer %s @ %p o %i", __func__, this->proxy, opacity); +} + +void layer::event_source_rectangle(int32_t x, int32_t y, int32_t width, + int32_t height) { + logdebug("genivi::layer %s @ %p x %i y %i w %i h %i", __func__, this->proxy, + x, y, width, height); +} + +void layer::event_destination_rectangle(int32_t x, int32_t y, int32_t width, + int32_t height) { + logdebug("genivi::layer %s @ %p x %i y %i w %i h %i", __func__, this->proxy, + x, y, width, height); +} + +void layer::event_configuration(int32_t width, int32_t height) { + logdebug("genivi::layer %s @ %p w %i h %i", __func__, this->proxy, width, + height); +} + +void layer::event_orientation(int32_t orientation) { + logdebug("genivi::layer %s @ %p o %i", __func__, this->proxy, orientation); +} + +void layer::event_screen(struct wl_output *screen) { + logdebug("genivi::layer %s @ %p s %p", __func__, this->proxy, screen); +} + +void layer::event_destroyed() { + logdebug("genivi::layer %s @ %p", __func__, this->proxy); +} + +void layer::s_visibility(void *data, + struct ivi_controller_layer *ivi_controller_layer, + int32_t visibility) { + static_cast<layer *>(data)->event_visibility(visibility); +} + +void layer::s_opacity(void *data, + struct ivi_controller_layer *ivi_controller_layer, + wl_fixed_t opacity) { + static_cast<layer *>(data)->event_opacity(opacity); +} + +void layer::s_source_rectangle( + void *data, struct ivi_controller_layer *ivi_controller_layer, int32_t x, + int32_t y, int32_t width, int32_t height) { + static_cast<layer *>(data)->event_source_rectangle(x, y, width, height); +} + +void layer::s_destination_rectangle( + void *data, struct ivi_controller_layer *ivi_controller_layer, int32_t x, + int32_t y, int32_t width, int32_t height) { + static_cast<layer *>(data)->event_destination_rectangle(x, y, width, height); +} + +void layer::s_configuration(void *data, + struct ivi_controller_layer *ivi_controller_layer, + int32_t width, int32_t height) { + static_cast<layer *>(data)->event_configuration(width, height); +} + +void layer::s_orientation(void *data, + struct ivi_controller_layer *ivi_controller_layer, + int32_t orientation) { + static_cast<layer *>(data)->event_orientation(orientation); +} + +void layer::s_screen(void *data, + struct ivi_controller_layer *ivi_controller_layer, + struct wl_output *screen) { + static_cast<layer *>(data)->event_screen(screen); +} + +void layer::s_destroyed(void *data, + struct ivi_controller_layer *ivi_controller_layer) { + static_cast<layer *>(data)->event_destroyed(); +} + constexpr ivi_controller_layer_listener layer::listener; // __ @@ -229,6 +317,129 @@ surface::~surface() { this->proxy = nullptr; } +void surface::event_visibility(int32_t visibility) { + logdebug("genivi::surface %s @ %p v %i", __func__, this->proxy, visibility); +} + +void surface::event_opacity(wl_fixed_t opacity) { + logdebug("genivi::surface %s @ %p o %i", __func__, this->proxy, opacity); +} + +void surface::event_source_rectangle(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); +} + +void surface::event_destination_rectangle(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); +} + +void surface::event_configuration(int32_t width, int32_t height) { + logdebug("genivi::surface %s @ %p w %i h %i", __func__, this->proxy, width, + height); +} + +void surface::event_orientation(int32_t orientation) { + logdebug("genivi::surface %s @ %p o %i", __func__, this->proxy, orientation); +} + +void surface::event_pixelformat(int32_t pixelformat) { + logdebug("genivi::surface %s @ %p f %i", __func__, this->proxy, pixelformat); +} + +void surface::event_layer(struct ivi_controller_layer *layer) { + logdebug("genivi::surface %s @ %p l @ %p", __func__, this->proxy, layer); +} + +void surface::event_stats(uint32_t redraw_count, uint32_t frame_count, + uint32_t update_count, uint32_t pid, + const char *process_name) { + logdebug("genivi::surface %s @ %p r %u f %u u %u pid %u p %s", __func__, + this->proxy, redraw_count, frame_count, update_count, pid, + process_name); +} + +void surface::event_destroyed() { + logdebug("genivi::surface %s @ %p", __func__, this->proxy); +} + +void surface::event_content(int32_t content_state) { + logdebug("genivi::surface %s @ %p s %i", __func__, this->proxy, + content_state); +} + +void surface::s_visibility( + void *data, struct ivi_controller_surface *ivi_controller_surface, + int32_t visibility) { + static_cast<surface *>(data)->event_visibility(visibility); +} + +void surface::s_opacity(void *data, + struct ivi_controller_surface *ivi_controller_surface, + wl_fixed_t opacity) { + static_cast<surface *>(data)->event_opacity(opacity); +} + +void surface::s_source_rectangle( + void *data, struct ivi_controller_surface *ivi_controller_surface, int32_t x, + int32_t y, int32_t width, int32_t height) { + static_cast<surface *>(data)->event_source_rectangle(x, y, width, height); +} + +void surface::s_destination_rectangle( + void *data, struct ivi_controller_surface *ivi_controller_surface, int32_t x, + int32_t y, int32_t width, int32_t height) { + static_cast<surface *>(data)->event_destination_rectangle(x, y, width, + height); +} + +void surface::s_configuration( + void *data, struct ivi_controller_surface *ivi_controller_surface, + int32_t width, int32_t height) { + static_cast<surface *>(data)->event_configuration(width, height); +} + +void surface::s_orientation( + void *data, struct ivi_controller_surface *ivi_controller_surface, + int32_t orientation) { + static_cast<surface *>(data)->event_orientation(orientation); +} + +void surface::s_pixelformat( + void *data, struct ivi_controller_surface *ivi_controller_surface, + int32_t pixelformat) { + static_cast<surface *>(data)->event_pixelformat(pixelformat); +} + +void surface::s_layer(void *data, + struct ivi_controller_surface *ivi_controller_surface, + struct ivi_controller_layer *layer) { + static_cast<surface *>(data)->event_layer(layer); +} + +void surface::s_stats(void *data, + struct ivi_controller_surface *ivi_controller_surface, + uint32_t redraw_count, uint32_t frame_count, + uint32_t update_count, uint32_t pid, + const char *process_name) { + static_cast<surface *>(data)->event_stats(redraw_count, frame_count, + update_count, pid, process_name); +} + +void surface::s_destroyed( + void *data, struct ivi_controller_surface *ivi_controller_surface) { + static_cast<surface *>(data)->event_destroyed(); +} + +void surface::s_content(void *data, + struct ivi_controller_surface *ivi_controller_surface, + int32_t content_state) { + static_cast<surface *>(data)->event_content(content_state); +} + constexpr ivi_controller_surface_listener surface::listener; // diff --git a/src/wayland.hpp b/src/wayland.hpp index 5cafd1a..54d0bd5 100644 --- a/src/wayland.hpp +++ b/src/wayland.hpp @@ -24,8 +24,8 @@ struct wayland_proxy { virtual ~wayland_proxy() { // If this is the nullptr, then it means it already was destroyed by a // custom wayland dtor - logdebug("%s %p @ %p", __func__, this, this->proxy); - if (proxy) { + if (this->proxy) { + logdebug("%s %p @ %p", __func__, this, this->proxy); wl_proxy_destroy(reinterpret_cast<wl_proxy *>(proxy)); } } @@ -51,6 +51,7 @@ struct display { std::unique_ptr<registry> r; display(); + bool ok() const; void roundtrip(); }; @@ -113,7 +114,7 @@ struct output : wayland_proxy<wl_output> { static constexpr wl_output_listener listener = {s_geometry, s_mode, s_done, s_scale}; }; -}; +} // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___ // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \ @@ -140,7 +141,70 @@ struct surface : public wayland_proxy<ivi_controller_surface> { surface(uint32_t i, ivi_controller *c); ~surface() override; - static constexpr ivi_controller_surface_listener listener = {}; + void event_visibility(int32_t visibility); + void event_opacity(wl_fixed_t opacity); + void event_source_rectangle(int32_t x, int32_t y, int32_t width, + int32_t height); + void event_destination_rectangle(int32_t x, int32_t y, int32_t width, + int32_t height); + void event_configuration(int32_t width, int32_t height); + void event_orientation(int32_t orientation); + void event_pixelformat(int32_t pixelformat); + void event_layer(struct ivi_controller_layer *layer); + void event_stats(uint32_t redraw_count, uint32_t frame_count, + uint32_t update_count, uint32_t pid, + const char *process_name); + void event_destroyed(); + void event_content(int32_t content_state); + + static void s_visibility( + void *data, struct ivi_controller_surface *ivi_controller_surface, + int32_t visibility); + static void s_opacity(void *data, + struct ivi_controller_surface *ivi_controller_surface, + wl_fixed_t opacity); + static void s_source_rectangle( + void *data, struct ivi_controller_surface *ivi_controller_surface, + int32_t x, int32_t y, int32_t width, int32_t height); + static void s_destination_rectangle( + void *data, struct ivi_controller_surface *ivi_controller_surface, + int32_t x, int32_t y, int32_t width, int32_t height); + static void s_configuration( + void *data, struct ivi_controller_surface *ivi_controller_surface, + int32_t width, int32_t height); + static void s_orientation( + void *data, struct ivi_controller_surface *ivi_controller_surface, + int32_t orientation); + static void s_pixelformat( + void *data, struct ivi_controller_surface *ivi_controller_surface, + int32_t pixelformat); + static void s_layer(void *data, + struct ivi_controller_surface *ivi_controller_surface, + struct ivi_controller_layer *layer); + static void s_stats(void *data, + struct ivi_controller_surface *ivi_controller_surface, + uint32_t redraw_count, uint32_t frame_count, + uint32_t update_count, uint32_t pid, + const char *process_name); + static void s_destroyed( + void *data, struct ivi_controller_surface *ivi_controller_surface); + static void s_content(void *data, + struct ivi_controller_surface *ivi_controller_surface, + int32_t content_state); + + static constexpr ivi_controller_surface_listener listener = { + s_visibility, + s_opacity, + s_source_rectangle, + s_destination_rectangle, + s_configuration, + s_orientation, + s_pixelformat, + s_layer, + s_stats, + s_destroyed, + s_content, + }; }; // _ @@ -155,7 +219,47 @@ struct layer : public wayland_proxy<ivi_controller_layer> { layer(uint32_t i, ivi_controller *c); ~layer() override; - static constexpr ivi_controller_layer_listener listener = {}; + void event_visibility(int32_t visibility); + void event_opacity(wl_fixed_t opacity); + void event_source_rectangle(int32_t x, int32_t y, int32_t width, + int32_t height); + void event_destination_rectangle(int32_t x, int32_t y, int32_t width, + int32_t height); + void event_configuration(int32_t width, int32_t height); + void event_orientation(int32_t orientation); + void event_screen(struct wl_output *screen); + void event_destroyed(); + + static void s_visibility(void *data, + struct ivi_controller_layer *ivi_controller_layer, + int32_t visibility); + static void s_opacity(void *data, + struct ivi_controller_layer *ivi_controller_layer, + wl_fixed_t opacity); + static void s_source_rectangle( + void *data, struct ivi_controller_layer *ivi_controller_layer, int32_t x, + int32_t y, int32_t width, int32_t height); + static void s_destination_rectangle( + void *data, struct ivi_controller_layer *ivi_controller_layer, int32_t x, + int32_t y, int32_t width, int32_t height); + static void s_configuration( + void *data, struct ivi_controller_layer *ivi_controller_layer, + int32_t width, int32_t height); + static void s_orientation(void *data, + struct ivi_controller_layer *ivi_controller_layer, + int32_t orientation); + static void s_screen(void *data, + struct ivi_controller_layer *ivi_controller_layer, + struct wl_output *screen); + static void s_destroyed(void *data, + struct ivi_controller_layer *ivi_controller_layer); + + static constexpr ivi_controller_layer_listener listener = { + s_visibility, s_opacity, + s_source_rectangle, s_destination_rectangle, + s_configuration, s_orientation, + s_screen, s_destroyed, + }; }; // |